Skip to content

Commit d63a467

Browse files
dante159753mag1c-h
andauthored
add pr gate workflow (#662)
# Purpose - add workflow runs on pr, do build/unittest/install/e2e inference - only allow ucm team member to modify the workflow content - add test utils for offline inference Co-authored-by: Mag1c.H <hemajun815@163.com>
1 parent f5261e9 commit d63a467

18 files changed

Lines changed: 1238 additions & 166 deletions

.github/actionlint.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ self-hosted-runner:
22
# Labels of self-hosted runner in array of strings.
33
labels:
44
- default
5-
- arc-runner-ucm
5+
- gpu
6+
- npu

.github/workflows/cpp-linter.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/e2e_test.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: 'Lint and Unit Tests'
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
cpp-linter:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
persist-credentials: false
13+
- uses: cpp-linter/cpp-linter-action@main
14+
id: linter
15+
continue-on-error: true
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
with:
19+
style: file
20+
tidy-checks: '-*'
21+
files-changed-only: true
22+
lines-changed-only: diff
23+
format-review: false
24+
version: 20
25+
26+
- name: Fail fast?!
27+
if: steps.linter.outputs.checks-failed != 0
28+
run: |
29+
echo "some linter checks failed. ${{ steps.linter.outputs.checks-failed }}"
30+
exit 1
31+
32+
py-linter:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
38+
- name: Set up Python
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: "3.12"
42+
43+
- name: Add matchers for better error display
44+
run: |
45+
echo "::add-matcher::.github/workflows/matchers/actionlint.json"
46+
echo "::add-matcher::.github/workflows/matchers/mypy.json"
47+
48+
- name: Run pre-commit checks on all files
49+
uses: pre-commit/action@v3.0.1
50+
env:
51+
SHELLCHECK_OPTS: "--exclude=SC2046,SC2006,SC2086"
52+
with:
53+
extra_args: --all-files --hook-stage manual
54+
55+
cpp_gtest:
56+
runs-on: ubuntu-latest
57+
env:
58+
BUILD_TYPE: Debug
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Install googletest
63+
run: |
64+
git clone https://github.com/google/googletest.git --depth=1 --branch=v1.17.0
65+
cd googletest
66+
mkdir build && cd build
67+
cmake -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=True ..
68+
sudo make install -j
69+
70+
- name: Configure CMake
71+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_UCM_SPARSE=OFF -DBUILD_UNIT_TESTS=ON -DRUNTIME_ENVIRONMENT=simu
72+
73+
- name: Build
74+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j
75+
76+
- name: Test
77+
working-directory: ${{github.workspace}}/build
78+
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure

.github/workflows/pre-commit.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/pull-request.yml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: 'Pull Request Gate'
2+
3+
on:
4+
pull_request:
5+
branches: [ "dev*", "main", "*release", "feature*" ]
6+
7+
jobs:
8+
# protect the workflows dir, only allow specific users to modify
9+
protect-workflows-dir:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
allowed: ${{ steps.check.outputs.allowed }}
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- id: check
19+
env:
20+
ACTOR: ${{ github.actor }}
21+
run: |
22+
# get the target branch contents
23+
git fetch origin ${{ github.base_ref }}
24+
25+
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
26+
echo "CHANGED_FILES=$CHANGED_FILES"
27+
28+
if ! echo "$CHANGED_FILES" | grep -q '^\.github/workflows/'; then
29+
echo "No .github/workflows changes, allow."
30+
echo "allowed=true" >> $GITHUB_OUTPUT
31+
exit 0
32+
fi
33+
34+
ALLOWED_USERS=("dante159753" "mag1c-h")
35+
36+
echo ".github changes detected, check if user is allowed..."
37+
ACTOR="${{ github.actor }}"
38+
echo "PR author: $ACTOR"
39+
40+
for u in "${ALLOWED_USERS[@]}"; do
41+
if [[ "$ACTOR" == "$u" ]]; then
42+
echo "Authorized user, allowing change."
43+
echo "allowed=true" >> $GITHUB_OUTPUT
44+
exit 0
45+
fi
46+
done
47+
48+
echo "ERROR: Only privileged users may modify .github/workflows/"
49+
echo "allowed=false" >> $GITHUB_OUTPUT
50+
exit 1
51+
52+
lint-and-unit-tests:
53+
needs: protect-workflows-dir
54+
if: needs.protect-workflows-dir.outputs.allowed == 'true'
55+
uses: ./.github/workflows/lint-and-test.yml
56+
57+
test-e2e-pc-gpu:
58+
runs-on: gpu
59+
needs: lint-and-unit-tests
60+
env:
61+
BUILD_TYPE: Release
62+
permissions:
63+
checks: write
64+
pull-requests: write
65+
steps:
66+
- name: Clean repo
67+
run: |
68+
if [ -d "${{github.workspace}}" ]; then
69+
cd ${{github.workspace}}
70+
rm -rf ./*
71+
rm -rf .[!.]*
72+
fi
73+
- uses: actions/checkout@v4
74+
- name: Build
75+
run: |
76+
cd ${{github.workspace}}
77+
export PLATFORM=cuda
78+
pip install -v -e . --no-build-isolation
79+
- name: Test E2E
80+
run: |
81+
cd ${{github.workspace}}
82+
cd test
83+
pip install pytest pytest-cov pynvml pandas
84+
python3 -m pytest --stage=1 --feature=offline_inference --junitxml=offline-inference.xml
85+
- name: Upload pytest results
86+
uses: EnricoMi/publish-unit-test-result-action/linux@v2
87+
if: (!cancelled())
88+
with:
89+
files: |
90+
${{github.workspace}}/test/offline-inference.xml
91+
check_name: Prefix cache test results
92+
93+
test-e2e-sparse-gpu:
94+
runs-on: gpu
95+
needs: lint-and-unit-tests
96+
env:
97+
BUILD_TYPE: Release
98+
permissions:
99+
checks: write
100+
pull-requests: write
101+
steps:
102+
- name: Clean repo
103+
run: |
104+
if [ -d "${{github.workspace}}" ]; then
105+
cd ${{github.workspace}}
106+
rm -rf ./*
107+
rm -rf .[!.]*
108+
fi
109+
- uses: actions/checkout@v4
110+
- name: Build
111+
run: |
112+
cd ${{github.workspace}}
113+
export PLATFORM=cuda
114+
export ENABLE_SPARSE=TRUE
115+
pip install -v -e . --no-build-isolation
116+
- name: Test E2E
117+
run: |
118+
cd ${{github.workspace}}
119+
cd test
120+
pip install pytest pytest-cov pynvml pandas
121+
python3 -m pytest --stage=1 --feature=offline_inference_sparse --junitxml=offline-inference-sparse.xml
122+
- name: Upload pytest results
123+
uses: EnricoMi/publish-unit-test-result-action/linux@v2
124+
if: (!cancelled())
125+
with:
126+
files: |
127+
${{github.workspace}}/test/offline-inference-sparse.xml
128+
check_name: Sparse attention test results
129+

.github/workflows/push-check.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: 'Push Commit Checks'
2+
3+
on:
4+
push:
5+
branches: [ "**" ] # ** matches all branches, while * matches only top-level branches without '/'
6+
7+
jobs:
8+
lint-and-unit-tests:
9+
uses: ./.github/workflows/lint-and-test.yml

.github/workflows/ucmstore.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

.github/workflows/unifiedcache_test.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)