Skip to content

Commit d9b81b8

Browse files
authored
[CI] Set read-all for workflows top-level token-permissions (#1777)
disable_all --------- Co-authored-by: mengfeil <test>
1 parent 44edfca commit d9b81b8

11 files changed

+85
-7
lines changed

.github/workflows/_linux_accelerate.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,37 @@ on:
3939
default: 'v4.51.3'
4040
description: Transformers version
4141

42+
permissions: read-all
43+
4244
concurrency:
4345
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
4446
cancel-in-progress: true
4547

4648
jobs:
49+
conditions-filter:
50+
name: conditions-filter
51+
if: ${{ github.event.pull_request.draft == false }}
52+
runs-on: ubuntu-22.04
53+
timeout-minutes: 10
54+
env:
55+
GH_TOKEN: ${{ github.token }}
56+
outputs:
57+
disabled_tests: ${{ steps.check-pr-desc.outputs.disabled_tests }}
58+
steps:
59+
- name: Check PR infos
60+
id: check-pr-desc
61+
run: |
62+
set -x -e -o pipefail
63+
sudo apt update && sudo apt install -y dos2unix
64+
gh --repo ${GITHUB_REPOSITORY} pr view ${{ github.event.pull_request.number }} 2>&1 |tee pr-info.txt
65+
dos2unix pr-info.txt
66+
disabled_tests="$(awk '/disable_/{printf("%s ", $0)}' pr-info.txt)"
67+
echo "disabled_tests=${disabled_tests}" |tee "${GITHUB_OUTPUT}"
68+
4769
Torch-XPU-Accelerate-Tests:
4870
runs-on: ${{ inputs.runner != '' && inputs.runner || 'linux.idc.xpu' }}
71+
needs: conditions-filter
72+
if: ${{ !(contains(needs.conditions-filter.outputs.disabled_tests, 'disable_all') || contains(needs.conditions-filter.outputs.disabled_tests, 'disable_accelerate')) }}
4973
env:
5074
WORK_DIR: 'accelerate'
5175
NEOReadDebugKeys: 0

.github/workflows/_linux_build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ on:
3838
description: The commit id of the torch build
3939
value: ${{ jobs.build.outputs.TORCH_COMMIT_ID }}
4040

41+
permissions: read-all
42+
4143
jobs:
4244
build:
4345
runs-on: ${{ inputs.runner }}

.github/workflows/_linux_op_benchmark.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ on:
3434
default: 'rolling'
3535
description: Driver lts/rolling
3636

37+
permissions: read-all
38+
3739
jobs:
3840
op_benchmark_test:
3941
runs-on: ${{ inputs.runner }}

.github/workflows/_linux_transformers.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ on:
4444
default: 'v4.51.3'
4545
description: Transformers version
4646

47+
permissions: read-all
48+
4749
concurrency:
4850
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
4951
cancel-in-progress: true
@@ -72,8 +74,30 @@ env:
7274
TORCH_INDEX: '--pre --index-url https://download.pytorch.org/whl/nightly/xpu'
7375

7476
jobs:
77+
conditions-filter:
78+
name: conditions-filter
79+
if: ${{ github.event.pull_request.draft == false }}
80+
runs-on: ubuntu-22.04
81+
timeout-minutes: 10
82+
env:
83+
GH_TOKEN: ${{ github.token }}
84+
outputs:
85+
disabled_tests: ${{ steps.check-pr-desc.outputs.disabled_tests }}
86+
steps:
87+
- name: Check PR infos
88+
id: check-pr-desc
89+
run: |
90+
set -x -e -o pipefail
91+
sudo apt update && sudo apt install -y dos2unix
92+
gh --repo ${GITHUB_REPOSITORY} pr view ${{ github.event.pull_request.number }} 2>&1 |tee pr-info.txt
93+
dos2unix pr-info.txt
94+
disabled_tests="$(awk '/disable_/{printf("%s ", $0)}' pr-info.txt)"
95+
echo "disabled_tests=${disabled_tests}" |tee "${GITHUB_OUTPUT}"
96+
7597
prepare:
7698
runs-on: ${{ inputs.runner != '' && inputs.runner || 'linux.idc.xpu' }}
99+
needs: conditions-filter
100+
if: ${{ !(contains(needs.conditions-filter.outputs.disabled_tests, 'disable_all') || contains(needs.conditions-filter.outputs.disabled_tests, 'disable_transformers')) }}
77101
outputs:
78102
torch: ${{ steps.getver.outputs.torch }}
79103
torchvision: ${{ steps.getver.outputs.torchvision }}
@@ -313,7 +337,7 @@ jobs:
313337

314338
report:
315339
needs: tests
316-
if: ${{ always() }}
340+
if: ${{ success() || failure() }}
317341
runs-on: ${{ inputs.runner != '' && inputs.runner || 'linux.idc.xpu' }}
318342
steps:
319343
- name: Download reports

.github/workflows/_linux_ut.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ on:
4444
default: 'lts'
4545
description: Driver lts/rolling
4646

47+
permissions: read-all
48+
4749
jobs:
4850
ut_test:
4951
runs-on: ${{ inputs.runner }}
@@ -65,7 +67,8 @@ jobs:
6567
rm -rf $(dirname ${CONDA_EXE})/../envs/xpu_op_${ZE_AFFINITY_MASK}
6668
conda create -n xpu_op_${ZE_AFFINITY_MASK} python=${{ inputs.python }} cmake ninja -y
6769
source activate xpu_op_${ZE_AFFINITY_MASK}
68-
cd ../ && rm -rf pytorch
70+
cd ../
71+
rm -rf pytorch || sudo rm -rf pytorch
6972
pip install requests
7073
git clone https://github.com/pytorch/pytorch pytorch
7174
if [ "${{ inputs.pytorch }}" != "nightly_wheel" ]; then

.github/workflows/_performance_comparison.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ on:
1414
default: ''
1515
description: Baseline run id
1616

17+
permissions: read-all
18+
1719
jobs:
1820
Performance-Comparison:
1921
env:

.github/workflows/_windows_ut.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ on:
4444
default: 'false'
4545
description: Check if labelled
4646

47+
permissions: read-all
48+
4749
env:
4850
USE_XPU: 1
4951

.github/workflows/nightly_ondemand.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ on:
5959
default: '3.10'
6060
description: Python version
6161

62+
permissions: read-all
63+
6264
concurrency:
6365
group: ${{ github.workflow }}-${{ github.sha }}-${{ github.event_name }}-${{ inputs.pytorch }}-${{ inputs.keep_torch_xpu_ops }}-${{ inputs.ut }}-${{ inputs.triton }}-${{ inputs.suite }}-${{ inputs.dt }}-${{ inputs.mode }}-${{ inputs.scenario }}-${{ inputs.model }}-${{ inputs.python }}
6466
cancel-in-progress: ${{ github.event_name != 'schedule' }}
@@ -129,7 +131,8 @@ jobs:
129131
- name: Prepare Stock Pytorch
130132
run: |
131133
pwd
132-
cd ../ && rm -rf pytorch
134+
cd ../
135+
rm -rf pytorch || sudo rm -rf pytorch
133136
source activate e2e_ci
134137
git clone https://github.com/pytorch/pytorch pytorch
135138
cd pytorch && git checkout $(echo ${{ env.pytorch }} |awk '{print $1}')
@@ -369,6 +372,8 @@ jobs:
369372
Tests-Failure-And-Report:
370373
if: ${{ ! cancelled() }}
371374
runs-on: [ self-hosted, Linux ]
375+
permissions:
376+
issues: write
372377
env:
373378
GH_TOKEN: ${{ github.token }}
374379
python: ${{ github.event_name == 'schedule' && '3.10' || inputs.python }}

.github/workflows/nightly_ondemand_rolling.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ on:
5959
default: '3.10'
6060
description: Python version
6161

62+
permissions: read-all
63+
6264
concurrency:
6365
group: ${{ github.workflow }}-${{ github.sha }}-${{ github.event_name }}-${{ inputs.pytorch }}-${{ inputs.keep_torch_xpu_ops }}-${{ inputs.ut }}-${{ inputs.triton }}-${{ inputs.suite }}-${{ inputs.dt }}-${{ inputs.mode }}-${{ inputs.scenario }}-${{ inputs.model }}-${{ inputs.python }}
6466
cancel-in-progress: ${{ github.event_name != 'schedule' }}
@@ -145,7 +147,8 @@ jobs:
145147
- name: Prepare Stock Pytorch
146148
run: |
147149
pwd
148-
cd ../ && rm -rf pytorch
150+
cd ../
151+
rm -rf pytorch || sudo rm -rf pytorch
149152
source activate e2e_ci
150153
git clone https://github.com/pytorch/pytorch pytorch
151154
cd pytorch && git checkout $(echo ${{ env.pytorch }} |awk '{print $1}')
@@ -383,6 +386,8 @@ jobs:
383386
Tests-Failure-And-Report:
384387
if: ${{ ! cancelled() }}
385388
runs-on: [ self-hosted, Linux ]
389+
permissions:
390+
issues: write
386391
env:
387392
GH_TOKEN: ${{ github.token }}
388393
python: ${{ github.event_name == 'schedule' && '3.10' || inputs.python }}

.github/workflows/nightly_ondemand_whl.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ on:
4949
default: '3.10'
5050
description: Python version
5151

52+
permissions: read-all
53+
5254
concurrency:
5355
group: ${{ github.workflow }}-${{ github.sha }}-${{ github.event_name }}-${{ inputs.pytorch }}-${{ inputs.ut }}-${{ inputs.suite }}-${{ inputs.dt }}-${{ inputs.mode }}-${{ inputs.scenario }}-${{ inputs.model }}-${{ inputs.python }}
5456
cancel-in-progress: ${{ github.event_name != 'schedule' }}
@@ -108,7 +110,8 @@ jobs:
108110
echo "TORCH_BRANCH_ID=$(python -c 'import torch; print(torch.__version__)')" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}"
109111
TORCH_COMMIT_ID=$(python -c 'import torch; print(torch.version.git_version)')
110112
echo "TORCH_COMMIT_ID=${TORCH_COMMIT_ID}" |tee -a "${GITHUB_OUTPUT}" >> "${GITHUB_ENV}"
111-
cd ../ && rm -rf pytorch
113+
cd ../
114+
rm -rf pytorch || sudo rm -rf pytorch
112115
git clone https://github.com/pytorch/pytorch pytorch
113116
cd pytorch && git checkout ${TORCH_COMMIT_ID}
114117
# apply PRs for stock pytorch
@@ -320,6 +323,8 @@ jobs:
320323
Tests-Failure-And-Report:
321324
if: ${{ ! cancelled() }}
322325
runs-on: [ self-hosted, Linux ]
326+
permissions:
327+
issues: write
323328
env:
324329
GH_TOKEN: ${{ github.token }}
325330
python: ${{ github.event_name == 'schedule' && '3.10' || inputs.python }}

0 commit comments

Comments
 (0)