Validate Freeze Export loss patch #123
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: code-quality | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| pre-commit: | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.x | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - uses: pre-commit/action@v3.0.0 | |
| - uses: pre-commit-ci/lite-action@v1.1.0 | |
| if: always() | |
| - name: Build prediction kernel | |
| run: bash apps/predbat/build_kernel.sh | |
| - name: Run unit tests (quick mode) | |
| env: | |
| PREDBAT_KERNEL_REQUIRED: "1" | |
| run: | | |
| cd coverage | |
| python3 ../apps/predbat/unit_test.py --quick | |
| - name: Verify checked-in x86_64 kernel binary | |
| run: | | |
| cd coverage | |
| python3 ../apps/predbat/verify_kernel_binary.py ../apps/predbat/prediction_kernel_lib_x86_64.so | |
| # Cross-build the prediction kernel binaries for every platform and commit them | |
| # back to the PR branch when they change (same auto-fix pattern as pre-commit) | |
| kernel-binaries: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| - uses: mlugg/setup-zig@v2 | |
| with: | |
| version: 0.16.0 | |
| - name: Cross-build prediction kernel binaries | |
| run: bash apps/predbat/build_kernel_cross.sh | |
| - name: Commit updated kernel binaries | |
| run: | | |
| git add apps/predbat/prediction_kernel_lib_*.so | |
| if git diff --cached --quiet; then | |
| echo "Kernel binaries unchanged" | |
| else | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git commit -m "chore: update prediction kernel binaries for all platforms" | |
| git push | |
| fi | |
| apply-freeze-export-ac-flow: | |
| if: github.event_name == 'push' && startsWith(github.event.head_commit.message, '[apply-freeze-ac-flow]') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: 3.x | |
| - uses: mlugg/setup-zig@v2 | |
| with: | |
| version: 0.16.0 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pre-commit | |
| - name: Apply revised Freeze Export accounting | |
| run: python3 tools/apply_freeze_export_ac_flow.py | |
| - name: Format and check touched text files | |
| run: | | |
| pre-commit run --files \ | |
| apps/predbat/predbat.py \ | |
| apps/predbat/prediction.py \ | |
| apps/predbat/prediction_kernel.cpp \ | |
| apps/predbat/prediction_kernel.py \ | |
| apps/predbat/tests/test_model.py || \ | |
| pre-commit run --files \ | |
| apps/predbat/predbat.py \ | |
| apps/predbat/prediction.py \ | |
| apps/predbat/prediction_kernel.cpp \ | |
| apps/predbat/prediction_kernel.py \ | |
| apps/predbat/tests/test_model.py | |
| - name: Build native prediction kernel | |
| run: bash apps/predbat/build_kernel.sh | |
| - name: Run quick tests with kernel required | |
| env: | |
| PREDBAT_KERNEL_REQUIRED: "1" | |
| run: | | |
| cd coverage | |
| python3 ../apps/predbat/unit_test.py --quick | |
| - name: Cross-build all checked-in kernel binaries | |
| run: bash apps/predbat/build_kernel_cross.sh | |
| - name: Verify checked-in x86_64 kernel | |
| run: | | |
| cd coverage | |
| python3 ../apps/predbat/verify_kernel_binary.py ../apps/predbat/prediction_kernel_lib_x86_64.so | |
| - name: Publish one clean main commit | |
| env: | |
| BASE_SHA: 842d69946d28d6fba46dc02f5ccacaf3db627b7c | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| rm -f tools/apply_freeze_export_ac_flow.py | |
| git checkout "$BASE_SHA" -- .github/workflows/code-quality.yml | |
| git reset --soft "$BASE_SHA" | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "No final patch produced" | |
| exit 1 | |
| fi | |
| git commit -m "fix(prediction): model Freeze Export residual AC flow" | |
| git push --force-with-lease origin HEAD:main |