Add Linux build, run checks on both OSes #10
Workflow file for this run
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: CI | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| branches: [master] | |
| permissions: | |
| contents: write | |
| jobs: | |
| check: | |
| strategy: | |
| matrix: | |
| os: [windows-latest, ubuntu-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| architecture: x64 | |
| - name: Install dependencies | |
| run: uv sync | |
| - name: Ruff check | |
| run: uv run ruff check src/ tests/ | |
| - name: Ruff format | |
| run: uv run ruff format --check src/ tests/ | |
| - name: Mypy | |
| run: uv run mypy src/ | |
| - name: Tests with coverage | |
| run: uv run pytest -m "" --cov=src --cov-branch --cov-report=term-missing --cov-report=xml --cov-fail-under=100 --junitxml=junit.xml -o junit_family=legacy | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: coverage.xml | |
| - name: Upload test results to Codecov | |
| if: ${{ !cancelled() }} | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| report_type: test_results | |
| files: junit.xml | |
| build-windows: | |
| needs: check | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| architecture: x64 | |
| - name: Install dependencies | |
| run: uv sync | |
| - name: Cache Nuitka | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~\AppData\Local\Nuitka | |
| key: nuitka-windows-py3.12-${{ hashFiles('uv.lock') }} | |
| - name: Build | |
| run: | | |
| uv run nuitka --standalone --prefer-source-code --mingw64 --assume-yes-for-downloads --show-scons --output-dir=build --include-module=_cffi_backend src\snapjaw.py | |
| New-Item -ItemType directory -Name snapjaw\snapjaw -Path build | |
| Get-Item -Path build\snapjaw.dist\* | Move-Item -Destination build\snapjaw\snapjaw | |
| - name: Package | |
| run: Compress-Archive -Path build\snapjaw\* -DestinationPath snapjaw-windows-x86_64.zip | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: snapjaw-windows-x86_64 | |
| path: snapjaw-windows-x86_64.zip | |
| build-linux: | |
| needs: check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| architecture: x64 | |
| - name: Install dependencies | |
| run: uv sync | |
| - name: Cache Nuitka | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cache/Nuitka | |
| key: nuitka-linux-py3.12-${{ hashFiles('uv.lock') }} | |
| - name: Build | |
| run: uv run nuitka --onefile --prefer-source-code --assume-yes-for-downloads --show-scons --output-dir=build --include-module=_cffi_backend src/snapjaw.py | |
| - name: Package | |
| run: | | |
| mv build/snapjaw.bin snapjaw | |
| tar czf snapjaw-linux-x86_64.tar.gz snapjaw | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: snapjaw-linux-x86_64 | |
| path: snapjaw-linux-x86_64.tar.gz | |
| release: | |
| needs: [build-windows, build-linux] | |
| if: github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: Get date | |
| id: date | |
| run: echo "date=$(date +%Y.%m.%d)" >> "$GITHUB_OUTPUT" | |
| - name: Rename artifacts | |
| env: | |
| VERSION: ${{ steps.date.outputs.date }}.${{ github.run_number }} | |
| run: | | |
| mv snapjaw-windows-x86_64/snapjaw-windows-x86_64.zip snapjaw-${VERSION}-windows-x86_64.zip | |
| mv snapjaw-linux-x86_64/snapjaw-linux-x86_64.tar.gz snapjaw-${VERSION}-linux-x86_64.tar.gz | |
| - name: Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.date.outputs.date }}.${{ github.run_number }} | |
| name: ${{ steps.date.outputs.date }}.${{ github.run_number }} | |
| files: | | |
| snapjaw-${{ steps.date.outputs.date }}.${{ github.run_number }}-windows-x86_64.zip | |
| snapjaw-${{ steps.date.outputs.date }}.${{ github.run_number }}-linux-x86_64.tar.gz |