create functional test, integrate into workflow #35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| permissions: | |
| contents: write | |
| name: Build OpenWrt Package | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| name: Functional tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Run functional tests | |
| run: bash tests/run_tests.sh | |
| build: | |
| name: Build for ${{ matrix.version }} / ${{ matrix.target }} | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| env: | |
| REPO_APK_KEY: ${{ secrets.REPO_APK_KEY }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - version: openwrt-24.10 | |
| target: x86_64 | |
| - version: openwrt-24.10 | |
| target: aarch64_cortex-a53 | |
| - version: openwrt-24.10 | |
| target: aarch64_generic | |
| - version: openwrt-24.10 | |
| target: arm_cortex-a7 | |
| - version: openwrt-24.10 | |
| target: arm_cortex-a9 | |
| - version: openwrt-24.10 | |
| target: mips_24kc | |
| - version: openwrt-24.10 | |
| target: mipsel_24kc | |
| - version: openwrt-25.12 | |
| target: x86_64 | |
| - version: openwrt-25.12 | |
| target: aarch64_cortex-a53 | |
| - version: openwrt-25.12 | |
| target: aarch64_generic | |
| - version: openwrt-25.12 | |
| target: arm_cortex-a7 | |
| - version: openwrt-25.12 | |
| target: arm_cortex-a9 | |
| - version: openwrt-25.12 | |
| target: mips_24kc | |
| - version: openwrt-25.12 | |
| target: mipsel_24kc | |
| steps: | |
| - name: ๐งพ Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: ๐ Set PKG_NAME from repo | |
| run: echo "PKG_NAME=${{ github.event.repository.name }}" >> "$GITHUB_ENV" | |
| - name: ๐งฐ Set up melmac feed structure | |
| run: | | |
| # Create a proper OpenWrt feed layout where each package lives in its own subdir | |
| mkdir -p feed/${PKG_NAME} | |
| # Copy the package sources into the feed subdir (exclude CI and feed itself) | |
| rsync -av \ | |
| --exclude='.git' \ | |
| --exclude='feed' \ | |
| --exclude='.github' \ | |
| ./ feed/${PKG_NAME}/ | |
| - name: โ Validate shell script syntax | |
| run: | | |
| echo "๐ Checking shell script syntax..." | |
| find feed/${PKG_NAME}/files/etc/init.d/ -type f -name '*' 2>/dev/null | while read -r script; do | |
| if [ -f "$script" ]; then | |
| echo "Checking syntax of: $script" | |
| bash -n "$script" || { echo "โ Syntax error in $script"; exit 1; } | |
| echo "โ $script syntax OK" | |
| fi | |
| done | |
| echo "โ All shell scripts passed syntax validation" | |
| - name: ๐งฎ Compute ARCH | |
| run: | | |
| if [ "${{ matrix.version }}" = "snapshots" ]; then | |
| echo "ARCH=${{ matrix.target }}-SNAPSHOT" >> "$GITHUB_ENV" | |
| else | |
| echo "ARCH=${{ matrix.target }}-${{ matrix.version }}" >> "$GITHUB_ENV" | |
| fi | |
| - name: ๐๏ธ Build with OpenWrt SDK | |
| uses: openwrt/gh-action-sdk@v8 | |
| env: | |
| ARCH: ${{ env.ARCH }} | |
| FEEDNAME: melmac | |
| PACKAGES: ${{ env.PKG_NAME }} | |
| INDEX: 0 | |
| FEED_DIR: ${{ github.workspace }}/feed | |
| NO_SHFMT_CHECK: 1 | |
| NO_REFRESH_CHECK: 1 | |
| PRIVATE_KEY: ${{ secrets.REPO_APK_KEY }} | |
| # - name: ๐ Debug build output | |
| # run: | | |
| # echo "=== Build directory structure ===" | |
| # find . -name "*.ipk" -type f 2>/dev/null || echo "No .ipk files found" | |
| # echo "=== bin directory structure ===" | |
| # ls -la bin/ 2>/dev/null || echo "No bin directory found" | |
| # if [ -d "bin/packages" ]; then | |
| # echo "=== packages directory structure ===" | |
| # find bin/packages/ -type f -name "*.ipk" 2>/dev/null || echo "No .ipk files in packages directory" | |
| # echo "=== Full packages directory tree ===" | |
| # ls -laR bin/packages/ 2>/dev/null || echo "No packages directory" | |
| # fi | |
| - name: ๐ท๏ธ Rename APK with version and target | |
| run: | | |
| set -euo pipefail | |
| PKG_VERSION=$(grep -E '^PKG_VERSION *:?=' Makefile | head -n1 | cut -d= -f2 | tr -d '[:space:]') | |
| PKG_RELEASE=$(grep -E '^PKG_RELEASE *:?=' Makefile | head -n1 | cut -d= -f2 | tr -d '[:space:]') | |
| for ext in ipk apk; do | |
| for f in $(find bin/packages -type f -path "*/melmac/*.${ext}"); do | |
| dir=$(dirname "$f") | |
| if [ -n "${{ matrix.suffix }}" ]; then | |
| mv -v "$f" "$dir/${PKG_NAME}-${PKG_VERSION}-${PKG_RELEASE}_${{ matrix.version }}_${{ matrix.suffix }}.${ext}" | |
| else | |
| mv -v "$f" "$dir/${PKG_NAME}-${PKG_VERSION}-${PKG_RELEASE}_${{ matrix.version }}_${{ matrix.target }}.${ext}" | |
| fi | |
| done | |
| done | |
| - name: ๐ฆ Upload artifact for ${{ matrix.target }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.PKG_NAME }}-${{ matrix.target }}-${{ matrix.version }} | |
| path: | | |
| bin/packages/*/melmac/${{ env.PKG_NAME }}*.ipk | |
| bin/packages/*/melmac/${{ env.PKG_NAME }}*.apk | |
| # bin/packages/*/melmac/Packages* | |
| # bin/packages/*/melmac/index.json | |
| # bin/packages/*/melmac/packages.adb | |
| if-no-files-found: ignore | |
| release: | |
| name: Release ${{ github.repository }} | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: ๐งพ Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: ๐ Extract version and release from Makefile | |
| id: version | |
| run: | | |
| PKG_VERSION=$(grep -E '^PKG_VERSION *:?=' Makefile | head -n1 | cut -d= -f2 | tr -d '[:space:]') | |
| PKG_RELEASE=$(grep -E '^PKG_RELEASE *:?=' Makefile | head -n1 | cut -d= -f2 | tr -d '[:space:]') | |
| COMBINED_VERSION="${PKG_VERSION}-${PKG_RELEASE}" | |
| echo "๐ฆ Version: $COMBINED_VERSION" | |
| echo "version=$COMBINED_VERSION" >> "$GITHUB_OUTPUT" | |
| - name: โฌ๏ธ Download all build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./release-assets | |
| - name: ๐๏ธ Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| name: Build v${{ steps.version.outputs.version }} | |
| files: | | |
| ./release-assets/**/*.ipk | |
| ./release-assets/**/*.apk | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |