forked from springfall2008/batpred
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (128 loc) · 4.43 KB
/
Copy pathcode-quality.yml
File metadata and controls
130 lines (128 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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