feat: Add code coverage (#50) #69
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
| --- | |
| name: Release Please | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| release-please: | |
| name: Release Please | |
| runs-on: ubuntu-24.04 | |
| outputs: | |
| release_created: ${{ steps.release.outputs.release_created }} | |
| tag_name: ${{ steps.release.outputs.tag_name }} | |
| steps: | |
| - name: Release Please | |
| if: ${{ !env.ACT }} | |
| uses: googleapis/release-please-action@v4 | |
| id: release | |
| with: | |
| token: ${{ secrets.PAT }} | |
| build-release: | |
| name: Build Release Artifacts | |
| needs: release-please | |
| if: ${{ needs.release-please.outputs.release_created == 'true' || needs.release-please.outputs.release_created == true }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-24.04 | |
| name: linux-x86_64 | |
| target: linux | |
| - os: ubuntu-24.04-arm | |
| name: linux-aarch64 | |
| target: linux | |
| - os: macos-latest | |
| name: macos-arm64 | |
| target: macos | |
| - os: macos-latest | |
| name: macos-x86_64 | |
| target: macos | |
| - os: windows-latest | |
| name: windows-x86_64 | |
| target: windows | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| shell: ${{ matrix.target == 'windows' && 'msys2 {0}' || 'bash' }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup MSYS2 (Windows) | |
| if: matrix.target == 'windows' | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: UCRT64 | |
| update: true | |
| install: >- | |
| git | |
| make | |
| unzip | |
| mingw-w64-ucrt-x86_64-gcc | |
| mingw-w64-ucrt-x86_64-cmake | |
| mingw-w64-ucrt-x86_64-lua | |
| mingw-w64-ucrt-x86_64-lua-luarocks | |
| - name: Install System Dependencies (Linux) | |
| if: matrix.target == 'linux' | |
| run: | | |
| sudo apt-get update -qq | |
| sudo apt-get install -y -qq build-essential cmake luarocks lua5.4 liblua5.4-dev | |
| - name: Install System Dependencies (macOS) | |
| if: matrix.target == 'macos' | |
| run: | | |
| brew install cmake luarocks lua@5.4 | |
| - name: Install Lux | |
| uses: lumen-oss/gh-actions-lux@v1 | |
| with: | |
| version: 0.28.0 | |
| - name: Copy Lux to MSYS2 (Windows) | |
| if: matrix.target == 'windows' | |
| run: cp "/c/Program Files/lux/lx.exe" /usr/bin/lx.exe | |
| - name: Install just (Unix) | |
| if: matrix.target != 'windows' | |
| uses: extractions/setup-just@v2 | |
| - name: Install just (Windows) | |
| if: matrix.target == 'windows' | |
| run: | | |
| mkdir -p /tmp/just | |
| curl -L https://github.com/casey/just/releases/download/1.48.1/just-1.48.1-x86_64-pc-windows-msvc.zip -o /tmp/just/just.zip | |
| unzip /tmp/just/just.zip -d /tmp/just | |
| mv /tmp/just/just.exe /usr/bin/ | |
| rm -rf /tmp/just | |
| - name: Build Executable | |
| env: | |
| LUA_VERSION: "5.4" | |
| run: | | |
| if [ "${{ matrix.target }}" = "linux" ]; then | |
| export LUA_PREFIX="/usr" | |
| MULTIARCH=$(dpkg-architecture -qDEB_HOST_MULTIARCH) | |
| export LUA_LIB="/usr/lib/${MULTIARCH}/liblua5.4.a" | |
| just build | |
| elif [ "${{ matrix.target }}" = "macos" ] && [ "${{ matrix.name }}" = "macos-x86_64" ]; then | |
| export MACOSX_DEPLOYMENT_TARGET="11.0" | |
| # Build Lua 5.4 from source for x86_64 | |
| # (Homebrew lua@5.4 on ARM64 only provides arm64 libraries) | |
| LUA_SRC_DIR="${{ runner.temp }}/lua-5.4.7" | |
| curl -sL https://www.lua.org/ftp/lua-5.4.7.tar.gz | tar xz -C "${{ runner.temp }}" | |
| cd "$LUA_SRC_DIR" | |
| make macosx CC="clang -arch x86_64" AR="ar rc" MYCFLAGS="-arch x86_64" MYLDFLAGS="-arch x86_64" | |
| make local | |
| cd "${{ github.workspace }}" | |
| export LUA_PREFIX="$LUA_SRC_DIR/install" | |
| export LUA_LIB="$LUA_SRC_DIR/install/lib/liblua.a" | |
| export LUA_INCLUDE="$LUA_SRC_DIR/install/include" | |
| export CMAKE_OSX_ARCHITECTURES="x86_64" | |
| export CC="clang -arch x86_64" | |
| just build | |
| elif [ "${{ matrix.target }}" = "macos" ]; then | |
| export LUA_PREFIX="$(brew --prefix lua@5.4)" | |
| export LUA_LIB="$LUA_PREFIX/lib/liblua.a" | |
| export MACOSX_DEPLOYMENT_TARGET="11.0" | |
| just build | |
| else | |
| export LUA_PREFIX="/ucrt64" | |
| export LUA_LIB="/ucrt64/lib/liblua.a" | |
| export LUA_INCLUDE="/ucrt64/include" | |
| just --shell bash build | |
| fi | |
| - name: Package Artifacts | |
| run: | | |
| mkdir -p staging | |
| if [ "${{ matrix.target }}" = "windows" ]; then | |
| cp roda.exe staging/ 2>/dev/null || cp roda staging/roda.exe | |
| cp LICENSE README.md staging/ 2>/dev/null || true | |
| cd staging | |
| zip -r ../roda-${{ matrix.name }}.zip * | |
| cd .. | |
| sha256sum roda-${{ matrix.name }}.zip > roda-${{ matrix.name }}.zip.sha256 | |
| else | |
| cp roda staging/ | |
| cp LICENSE README.md staging/ 2>/dev/null || true | |
| cd staging | |
| tar -czvf ../roda-${{ matrix.name }}.tar.gz * | |
| cd .. | |
| if command -v sha256sum >/dev/null 2>&1; then | |
| sha256sum roda-${{ matrix.name }}.tar.gz > roda-${{ matrix.name }}.tar.gz.sha256 | |
| else | |
| shasum -a 256 roda-${{ matrix.name }}.tar.gz > roda-${{ matrix.name }}.tar.gz.sha256 | |
| fi | |
| fi | |
| - name: Verify Binary Architecture | |
| if: matrix.target == 'macos' | |
| run: | | |
| EXPECTED_ARCH="${{ matrix.name == 'macos-arm64' && 'arm64' || 'x86_64' }}" | |
| ACTUAL_ARCH=$(lipo -archs roda) | |
| echo "Expected: $EXPECTED_ARCH, Got: $ACTUAL_ARCH" | |
| if [ "$ACTUAL_ARCH" != "$EXPECTED_ARCH" ]; then | |
| echo "::error::Binary architecture mismatch! Expected $EXPECTED_ARCH, got $ACTUAL_ARCH" | |
| exit 1 | |
| fi | |
| file roda | |
| - name: Generate Rockspec | |
| if: matrix.name == 'linux-x86_64' | |
| run: | | |
| lx generate-rockspec | |
| - name: Validate Rockspec | |
| if: matrix.name == 'linux-x86_64' | |
| run: | | |
| luarocks lint *.rockspec | |
| - name: Upload Release Artifacts (with rockspec) | |
| if: ${{ !env.ACT && matrix.name == 'linux-x86_64' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release upload ${{ needs.release-please.outputs.tag_name }} \ | |
| roda-${{ matrix.name }}.tar.gz roda-${{ matrix.name }}.tar.gz.sha256 *.rockspec --clobber | |
| - name: Upload Release Artifacts (Linux aarch64) | |
| if: ${{ !env.ACT && matrix.name == 'linux-aarch64' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release upload ${{ needs.release-please.outputs.tag_name }} \ | |
| roda-${{ matrix.name }}.tar.gz roda-${{ matrix.name }}.tar.gz.sha256 --clobber | |
| - name: Upload Release Artifacts (Windows) | |
| if: ${{ !env.ACT && matrix.target == 'windows' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release upload ${{ needs.release-please.outputs.tag_name }} \ | |
| roda-${{ matrix.name }}.zip roda-${{ matrix.name }}.zip.sha256 --clobber | |
| - name: Upload Release Artifacts (macOS) | |
| if: ${{ !env.ACT && matrix.target == 'macos' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release upload ${{ needs.release-please.outputs.tag_name }} \ | |
| roda-${{ matrix.name }}.tar.gz roda-${{ matrix.name }}.tar.gz.sha256 --clobber |