Skip to content

Commit 0de203f

Browse files
committed
refactor: extract check-bypass to a reusable workflow
1 parent e754e03 commit 0de203f

4 files changed

Lines changed: 70 additions & 64 deletions

File tree

.github/actions/check-bypass/action.yml

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

.github/workflows/Codestyle-Check.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,20 @@ on:
66
- develop
77

88
jobs:
9+
check-bypass:
10+
name: Check bypass
11+
uses: ./.github/workflows/check-bypass.yml
12+
with:
13+
workflow-name: codestyle
14+
secrets:
15+
github-token: ${{ secrets.GITHUB_TOKEN }}
16+
917
pre-commit:
1018
name: Pre Commit
19+
needs: check-bypass
20+
if: needs.check-bypass.outputs.can-skip != 'true'
1121
runs-on: ubuntu-latest
22+
timeout-minutes: 10
1223
env:
1324
PR_ID: ${{ github.event.pull_request.number }}
1425
BRANCH: develop
@@ -24,33 +35,22 @@ jobs:
2435
ref: ${{ github.event.pull_request.base.ref }}
2536
fetch-depth: 1000
2637

27-
- name: Check bypass
28-
id: check-bypass
29-
uses: ./.github/actions/check-bypass
30-
with:
31-
github-token: ${{ secrets.GITHUB_TOKEN }}
32-
workflow-name: codestyle
33-
3438
- name: Merge PR to test branch
35-
if: steps.check-bypass.outputs.can-skip != 'true'
3639
run: |
3740
git fetch origin pull/${PR_ID}/merge
3841
git checkout -b test FETCH_HEAD
3942
4043
- name: Setup python3.10
41-
if: steps.check-bypass.outputs.can-skip != 'true'
4244
uses: actions/setup-python@v6
4345
with:
4446
python-version: '3.10'
4547
cache: 'pip'
4648

4749
- name: Install dependencies
48-
if: steps.check-bypass.outputs.can-skip != 'true'
4950
run: |
5051
pip install pre-commit==2.17.0
5152
5253
- name: Check pre-commit
53-
if: steps.check-bypass.outputs.can-skip != 'true'
5454
run: |
5555
set +e
5656
bash -x tools/codestyle/pre_commit.sh;EXCODE=$?

.github/workflows/Validate-GPU.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,21 @@ defaults:
2020
shell: bash
2121

2222
jobs:
23+
check-bypass:
24+
name: Check bypass
25+
uses: ./.github/workflows/check-bypass.yml
26+
with:
27+
workflow-name: validate
28+
secrets:
29+
github-token: ${{ secrets.GITHUB_TOKEN }}
30+
2331
validate:
2432
name: Validate
25-
if: ${{ inputs.can-skip != 'true' }}
33+
needs: check-bypass
34+
if: needs.check-bypass.outputs.can-skip != 'true'
2635
runs-on:
2736
group: BD_BJ-V100
37+
timeout-minutes: 120
2838
steps:
2939
- name: Clone GraphNet
3040
uses: actions/checkout@v6
@@ -33,15 +43,7 @@ jobs:
3343
submodules: 'recursive'
3444
fetch-depth: 1000
3545

36-
- name: Check bypass
37-
id: check-bypass
38-
uses: ./.github/actions/check-bypass
39-
with:
40-
github-token: ${{ secrets.GITHUB_TOKEN }}
41-
workflow-name: validate
42-
4346
- name: Merge PR to test branch
44-
if: steps.check-bypass.outputs.can-skip != 'true'
4547
run: |
4648
git fetch origin pull/${PR_ID}/merge
4749
git checkout -b test FETCH_HEAD
@@ -50,7 +52,6 @@ jobs:
5052
env:
5153
work_dir: ${{ github.workspace }}
5254
CACHE_DIR: /home/data/cfs/.cache
53-
if: steps.check-bypass.outputs.can-skip != 'true'
5455
run: |
5556
container_name=${TASK}-${core_index}-$(date +%Y%m%d-%H%M%S)
5657
echo "container_name=${container_name}" >> ${{ github.env }}
@@ -78,7 +79,6 @@ jobs:
7879
- name: Run check
7980
env:
8081
work_dir: ${{ github.workspace }}
81-
if: steps.check-bypass.outputs.can-skip != 'true'
8282
run: |
8383
docker exec -t ${{ env.container_name }} /bin/bash -c '
8484
source ${{ github.workspace }}/../../../proxy
@@ -88,7 +88,6 @@ jobs:
8888
- name: Run Unit Test
8989
env:
9090
work_dir: ${{ github.workspace }}
91-
if: steps.check-bypass.outputs.can-skip != 'true'
9291
run: |
9392
docker exec -t ${{ env.container_name }} /bin/bash -c '
9493
source ${{ github.workspace }}/../../../proxy

.github/workflows/check-bypass.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
workflow-name:
5+
required: true
6+
type: string
7+
secrets:
8+
github-token:
9+
required: true
10+
outputs:
11+
can-skip:
12+
description: "Whether the workflow can be skipped"
13+
value: ${{ jobs.check-bypass.outputs.can-skip }}
14+
15+
jobs:
16+
check-bypass:
17+
name: Check Bypass
18+
runs-on: ubuntu-slim
19+
permissions:
20+
contents: read
21+
env:
22+
CI_TEAM_MEMBERS: '["lixinqi", "Xreki"]'
23+
outputs:
24+
can-skip: ${{ steps.check-bypass.outputs.can-skip }}
25+
timeout-minutes: 3
26+
steps:
27+
- name: Check bypass
28+
id: check-bypass
29+
uses: PFCCLab/ci-bypass@v2
30+
with:
31+
github-token: ${{ secrets.github-token }}
32+
non-pull-request-event-strategy: 'always-skipped'
33+
type: 'composite'
34+
composite-rule: |
35+
{
36+
"any": [
37+
{
38+
"type": "labeled",
39+
"label": ["skip-ci: ${{ inputs.workflow-name }}", "skip-ci: all"],
40+
"username": ${{ env.CI_TEAM_MEMBERS }}
41+
},
42+
{
43+
"type": "commented",
44+
"comment-pattern": [".*/skip-ci ${{ inputs.workflow-name }}.*", ".*/skip-ci all.*"],
45+
"username": ${{ env.CI_TEAM_MEMBERS }}
46+
}
47+
]
48+
}

0 commit comments

Comments
 (0)