Skip to content

Commit 4fdb8dc

Browse files
ydshiehAbdennacer-Badaoui
authored andcommitted
Cleanup workflow - part 1 (huggingface#42023)
* part 1 * part 2 * part 3 * part 4 * part 5 * fix 1 * check 1 * part 6 * part 7 * part 8 * part 9 * part 10: rename file * OK: new_model_pr_merged_notification.yml * part 11 * fix 2 * revert check * fix * fix * fix --------- Co-authored-by: ydshieh <[email protected]>
1 parent 066e102 commit 4fdb8dc

File tree

10 files changed

+262
-135
lines changed

10 files changed

+262
-135
lines changed

.github/workflows/check_failed_tests.yml

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,15 @@ jobs:
6464
- name: Check file
6565
id: check_file
6666
working-directory: /transformers
67+
env:
68+
job: ${{ inputs.job }}
6769
run: |
68-
if [ -f ci_results_${{ inputs.job }}/new_failures.json ]; then
69-
echo "`ci_results_${{ inputs.job }}/new_failures.json` exists, continue ..."
70+
if [ -f "ci_results_${job}/new_failures.json" ]; then
71+
echo "\`ci_results_${job}/new_failures.json\` exists, continue ..."
7072
echo "process=true" >> $GITHUB_ENV
7173
echo "process=true" >> $GITHUB_OUTPUT
7274
else
73-
echo "`ci_results_${{ inputs.job }}/new_failures.json` doesn't exist, abort."
75+
echo "\`ci_results_${job}/new_failures.json\` doesn't exist, abort."
7476
echo "process=false" >> $GITHUB_ENV
7577
echo "process=false" >> $GITHUB_OUTPUT
7678
fi
@@ -94,15 +96,18 @@ jobs:
9496
- name: Update clone
9597
working-directory: /transformers
9698
if: ${{ env.process == 'true' }}
99+
env:
100+
commit_sha: ${{ inputs.commit_sha || github.sha }}
97101
run: |
98-
git fetch origin ${{ inputs.commit_sha || github.sha }}
99-
git fetch && git checkout ${{ inputs.commit_sha || github.sha }}
102+
git fetch origin "$commit_sha" && git checkout "$commit_sha"
100103
101104
- name: Get `START_SHA`
102105
working-directory: /transformers/utils
103106
if: ${{ env.process == 'true' }}
107+
env:
108+
commit_sha: ${{ inputs.commit_sha || github.sha }}
104109
run: |
105-
echo "START_SHA=${{ inputs.commit_sha || github.sha }}" >> $GITHUB_ENV
110+
echo "START_SHA=$commit_sha" >> $GITHUB_ENV
106111
107112
# This is used if the CI is triggered from a pull request `self-comment-ci.yml` (after security check is verified)
108113
- name: Extract the base commit on `main` (of the merge commit created by Github) if it is a PR
@@ -130,16 +135,20 @@ jobs:
130135
- name: Get `END_SHA` from previous CI runs of the same workflow
131136
working-directory: /transformers/utils
132137
if: ${{ env.process == 'true' && inputs.pr_number == '' }}
138+
env:
139+
ACCESS_TOKEN: ${{ secrets.ACCESS_REPO_INFO_TOKEN }}
133140
run: |
134-
echo "END_SHA=$(TOKEN=${{ secrets.ACCESS_REPO_INFO_TOKEN }} python3 -c 'import os; from get_previous_daily_ci import get_last_daily_ci_run_commit; commit=get_last_daily_ci_run_commit(token=os.environ["TOKEN"], workflow_run_id=os.environ["PREV_WORKFLOW_RUN_ID"]); print(commit)')" >> $GITHUB_ENV
141+
echo "END_SHA=$(TOKEN="$ACCESS_TOKEN" python3 -c 'import os; from get_previous_daily_ci import get_last_daily_ci_run_commit; commit=get_last_daily_ci_run_commit(token=os.environ["TOKEN"], workflow_run_id=os.environ["PREV_WORKFLOW_RUN_ID"]); print(commit)')" >> $GITHUB_ENV
135142
136143
# However, for workflow runs triggered by `issue_comment` (for pull requests), we want to check against the
137144
# parent commit (on `main`) of the `merge_commit` (dynamically created by GitHub). In this case, the goal is to
138145
# see if a reported failing test is actually ONLY failing on the `merge_commit`.
139146
- name: Set `END_SHA`
140147
if: ${{ env.process == 'true' && inputs.pr_number != '' }}
148+
env:
149+
merge_commit_base_sha: ${{ steps.pr_info.outputs.merge_commit_base_sha }}
141150
run: |
142-
echo "END_SHA=${{ steps.pr_info.outputs.merge_commit_base_sha }}" >> $GITHUB_ENV
151+
echo "END_SHA=$merge_commit_base_sha" >> $GITHUB_ENV
143152
144153
- name: Reinstall transformers in edit mode (remove the one installed during docker image build)
145154
working-directory: /transformers
@@ -169,14 +178,20 @@ jobs:
169178
- name: Check failed tests
170179
working-directory: /transformers
171180
if: ${{ env.process == 'true' }}
172-
run: python3 utils/check_bad_commit.py --start_commit ${{ env.START_SHA }} --end_commit ${{ env.END_SHA }} --file ci_results_${{ inputs.job }}/new_failures.json --output_file new_failures_with_bad_commit_${{ inputs.job }}_${{ matrix.run_idx }}.json
181+
env:
182+
job: ${{ inputs.job }}
183+
run_idx: ${{ matrix.run_idx }}
184+
run: python3 utils/check_bad_commit.py --start_commit "$START_SHA" --end_commit "$END_SHA" --file "ci_results_${job}/new_failures.json" --output_file "new_failures_with_bad_commit_${job}_${run_idx}.json"
173185

174186
- name: Show results
175187
working-directory: /transformers
176188
if: ${{ env.process == 'true' }}
189+
env:
190+
job: ${{ inputs.job }}
191+
run_idx: ${{ matrix.run_idx }}
177192
run: |
178-
ls -l new_failures_with_bad_commit_${{ inputs.job }}_${{ matrix.run_idx }}.json
179-
cat new_failures_with_bad_commit_${{ inputs.job }}_${{ matrix.run_idx }}.json
193+
ls -l "new_failures_with_bad_commit_${job}_${run_idx}.json"
194+
cat "new_failures_with_bad_commit_${job}_${run_idx}.json"
180195
181196
- name: Upload artifacts
182197
uses: actions/upload-artifact@v4
@@ -209,23 +224,28 @@ jobs:
209224

210225
- name: Check files
211226
working-directory: /transformers
227+
env:
228+
job: ${{ inputs.job }}
212229
run: |
213230
ls -la /transformers
214-
ls -la /transformers/new_failures_with_bad_commit_${{ inputs.job }}
231+
ls -la "/transformers/new_failures_with_bad_commit_${job}"
215232
216233
# Currently, we only run with a single runner by using `run_idx: [1]`. We might try to run with multiple runners
217234
# to further reduce the false positive caused by flaky tests, which requires further processing to merge reports.
218235
- name: Merge files
219236
shell: bash
220237
working-directory: /transformers
238+
env:
239+
job: ${{ inputs.job }}
221240
run: |
222-
cp /transformers/new_failures_with_bad_commit_${{ inputs.job }}/new_failures_with_bad_commit_${{ inputs.job }}_1.json new_failures_with_bad_commit.json
241+
cp "/transformers/new_failures_with_bad_commit_${job}/new_failures_with_bad_commit_${job}_1.json" new_failures_with_bad_commit.json
223242
224243
- name: Update clone
225244
working-directory: /transformers
245+
env:
246+
commit_sha: ${{ inputs.commit_sha || github.sha }}
226247
run: |
227-
git fetch origin ${{ inputs.commit_sha || github.sha }}
228-
git fetch && git checkout ${{ inputs.commit_sha || github.sha }}
248+
git fetch origin "$commit_sha" && git checkout "$commit_sha"
229249
230250
- name: Process report
231251
shell: bash
@@ -267,9 +287,12 @@ jobs:
267287

268288
- name: Prepare Slack report title
269289
working-directory: /transformers
290+
env:
291+
ci_event: ${{ inputs.ci_event }}
292+
job: ${{ inputs.job }}
270293
run: |
271294
pip install slack_sdk
272-
echo "title=$(python3 -c 'import sys; sys.path.append("utils"); from utils.notification_service import job_to_test_map; ci_event = "${{ inputs.ci_event }}"; job = "${{ inputs.job }}"; test_name = job_to_test_map[job]; title = f"New failed tests of {ci_event}" + ":" + f" {test_name}"; print(title)')" >> $GITHUB_ENV
295+
echo "title=$(python3 -c 'import sys; import os; sys.path.append("utils"); from utils.notification_service import job_to_test_map; ci_event = os.environ["ci_event"]; job = os.environ["job"]; test_name = job_to_test_map[job]; title = f"New failed tests of {ci_event}" + ":" + f" {test_name}"; print(title)')" >> $GITHUB_ENV
273296
274297
- name: Send processed report
275298
if: ${{ !endsWith(env.REPORT_TEXT, '{}') }}

.github/workflows/get-pr-info.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,15 @@ jobs:
153153
154154
- name: Convert dates to timestamps
155155
id: get_timestamps
156+
env:
157+
head_commit_date: ${{ steps.pr_info.outputs.head_commit_date }}
158+
merge_commit_date: ${{ steps.pr_info.outputs.merge_commit_date }}
156159
run: |
157-
head_commit_date=${{ steps.pr_info.outputs.head_commit_date }}
158-
merge_commit_date=${{ steps.pr_info.outputs.merge_commit_date }}
159-
echo $head_commit_date
160-
echo $merge_commit_date
160+
echo "$head_commit_date"
161+
echo "$merge_commit_date"
161162
head_commit_timestamp=$(date -d "$head_commit_date" +%s)
162163
merge_commit_timestamp=$(date -d "$merge_commit_date" +%s)
163-
echo $head_commit_timestamp
164-
echo $merge_commit_timestamp
164+
echo "$head_commit_timestamp"
165+
echo "$merge_commit_timestamp"
165166
echo "head_commit_timestamp=$head_commit_timestamp" >> $GITHUB_OUTPUT
166-
echo "merge_commit_timestamp=$merge_commit_timestamp" >> $GITHUB_OUTPUT
167+
echo "merge_commit_timestamp=$merge_commit_timestamp" >> $GITHUB_OUTPUT

.github/workflows/get-pr-number.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,28 @@ jobs:
1515
steps:
1616
- name: Get PR number
1717
shell: bash
18+
env:
19+
issue_number: ${{ github.event.issue.number }}
20+
is_pull_request_issue: ${{ github.event.issue.pull_request != null }}
21+
pr_number: ${{ github.event.pull_request.number }}
22+
is_pull_request: ${{ github.event.pull_request != null }}
23+
event_number: ${{ github.event.number }}
1824
run: |
19-
if [[ "${{ github.event.issue.number }}" != "" && "${{ github.event.issue.pull_request }}" != "" ]]; then
20-
echo "PR_NUMBER=${{ github.event.issue.number }}" >> $GITHUB_ENV
21-
elif [[ "${{ github.event.pull_request.number }}" != "" ]]; then
22-
echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
23-
elif [[ "${{ github.event.pull_request }}" != "" ]]; then
24-
echo "PR_NUMBER=${{ github.event.number }}" >> $GITHUB_ENV
25+
if [[ "$issue_number" != "" && "$is_pull_request_issue" == "true" ]]; then
26+
echo "PR_NUMBER=$issue_number" >> $GITHUB_ENV
27+
elif [[ "$pr_number" != "" ]]; then
28+
echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV
29+
elif [[ "$is_pull_request" == "true" ]]; then
30+
echo "PR_NUMBER=$event_number" >> $GITHUB_ENV
2531
else
2632
echo "PR_NUMBER=" >> $GITHUB_ENV
2733
fi
2834
2935
- name: Check PR number
3036
shell: bash
3137
run: |
32-
echo "${{ env.PR_NUMBER }}"
38+
echo "$PR_NUMBER"
3339
3440
- name: Set PR number
3541
id: set_pr_number
36-
run: echo "PR_NUMBER=${{ env.PR_NUMBER }}" >> "$GITHUB_OUTPUT"
42+
run: echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_OUTPUT"

.github/workflows/model_jobs.yml

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,33 @@ jobs:
6262
steps:
6363
- name: Echo input and matrix info
6464
shell: bash
65+
env:
66+
folder_slices: ${{ inputs.folder_slices }}
67+
matrix_folders: ${{ matrix.folders }}
68+
slice_data: ${{ toJson(fromJson(inputs.folder_slices)[inputs.slice_id]) }}
6569
run: |
66-
echo "${{ inputs.folder_slices }}"
67-
echo "${{ matrix.folders }}"
68-
echo "${{ toJson(fromJson(inputs.folder_slices)[inputs.slice_id]) }}"
70+
echo "$folder_slices"
71+
echo "$matrix_folders"
72+
echo "$slice_data"
6973
7074
- name: Echo folder ${{ matrix.folders }}
7175
shell: bash
7276
# For folders like `models/bert`, set an env. var. (`matrix_folders`) to `models_bert`, which will be used to
7377
# set the artifact folder names (because the character `/` is not allowed).
78+
env:
79+
matrix_folders_raw: ${{ matrix.folders }}
7480
run: |
75-
echo "${{ matrix.folders }}"
76-
matrix_folders=${{ matrix.folders }}
77-
matrix_folders=${matrix_folders/'models/'/'models_'}
81+
echo "$matrix_folders_raw"
82+
matrix_folders="${matrix_folders_raw/'models/'/'models_'}"
7883
echo "$matrix_folders"
7984
echo "matrix_folders=$matrix_folders" >> $GITHUB_ENV
8085
8186
- name: Update clone
8287
working-directory: /transformers
88+
env:
89+
commit_sha: ${{ inputs.commit_sha || github.sha }}
8390
run: |
84-
git fetch origin ${{ inputs.commit_sha || github.sha }}
85-
git fetch && git checkout ${{ inputs.commit_sha || github.sha }}
91+
git fetch origin "$commit_sha" && git checkout "$commit_sha"
8692
8793
- name: Reinstall transformers in edit mode (remove the one installed during docker image build)
8894
working-directory: /transformers
@@ -117,15 +123,17 @@ jobs:
117123
id: set_machine_type
118124
working-directory: /transformers
119125
shell: bash
126+
env:
127+
input_machine_type: ${{ inputs.machine_type }}
120128
run: |
121-
echo "${{ inputs.machine_type }}"
129+
echo "$input_machine_type"
122130
123-
if [ "${{ inputs.machine_type }}" = "aws-g5-4xlarge-cache" ]; then
131+
if [ "$input_machine_type" = "aws-g5-4xlarge-cache" ]; then
124132
machine_type=single-gpu
125-
elif [ "${{ inputs.machine_type }}" = "aws-g5-12xlarge-cache" ]; then
133+
elif [ "$input_machine_type" = "aws-g5-12xlarge-cache" ]; then
126134
machine_type=multi-gpu
127135
else
128-
machine_type=${{ inputs.machine_type }}
136+
machine_type="$input_machine_type"
129137
fi
130138
131139
echo "$machine_type"
@@ -134,15 +142,21 @@ jobs:
134142
135143
- name: Create report directory if it doesn't exist
136144
shell: bash
145+
env:
146+
report_name_prefix: ${{ inputs.report_name_prefix }}
137147
run: |
138-
mkdir -p /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports
139-
echo "dummy" > /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports/dummy.txt
140-
ls -la /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports
148+
mkdir -p "/transformers/reports/${machine_type}_${report_name_prefix}_${matrix_folders}_test_reports"
149+
echo "dummy" > "/transformers/reports/${machine_type}_${report_name_prefix}_${matrix_folders}_test_reports/dummy.txt"
150+
ls -la "/transformers/reports/${machine_type}_${report_name_prefix}_${matrix_folders}_test_reports"
141151
142152
- name: Run all tests on GPU
143153
working-directory: /transformers
154+
env:
155+
report_name_prefix: ${{ inputs.report_name_prefix }}
156+
pytest_marker: ${{ inputs.pytest_marker }}
157+
model: ${{ matrix.folders }}
144158
run: |
145-
script -q -c "PATCH_TESTING_METHODS_TO_COLLECT_OUTPUTS=yes _PATCHED_TESTING_METHODS_OUTPUT_DIR=/transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports python3 -m pytest -rsfE -v -m '${{ inputs.pytest_marker }}' --make-reports=${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports tests/${{ matrix.folders }}" test_outputs.txt
159+
script -q -c "PATCH_TESTING_METHODS_TO_COLLECT_OUTPUTS=yes _PATCHED_TESTING_METHODS_OUTPUT_DIR=/transformers/reports/${machine_type}_${report_name_prefix}_${matrix_folders}_test_reports python3 -m pytest -rsfE -v -m '${pytest_marker}' --make-reports=${machine_type}_${report_name_prefix}_${matrix_folders}_test_reports tests/${model}" test_outputs.txt
146160
ls -la
147161
# Extract the exit code from the output file
148162
EXIT_CODE=$(tail -1 test_outputs.txt | grep -o 'COMMAND_EXIT_CODE="[0-9]*"' | cut -d'"' -f2)
@@ -153,19 +167,25 @@ jobs:
153167
# This step is only to show information on Github Actions log.
154168
# Always mark this step as successful, even if the report directory or the file `failures_short.txt` in it doesn't exist
155169
continue-on-error: true
156-
run: cat /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports/failures_short.txt
170+
env:
171+
report_name_prefix: ${{ inputs.report_name_prefix }}
172+
run: cat "/transformers/reports/${machine_type}_${report_name_prefix}_${matrix_folders}_test_reports/failures_short.txt"
157173

158174
- name: Captured information
159175
if: ${{ failure() }}
160176
continue-on-error: true
177+
env:
178+
report_name_prefix: ${{ inputs.report_name_prefix }}
161179
run: |
162-
cat /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports/captured_info.txt
180+
cat "/transformers/reports/${machine_type}_${report_name_prefix}_${matrix_folders}_test_reports/captured_info.txt"
163181
164182
- name: Copy test_outputs.txt
165183
if: ${{ always() }}
166184
continue-on-error: true
185+
env:
186+
report_name_prefix: ${{ inputs.report_name_prefix }}
167187
run: |
168-
cp /transformers/test_outputs.txt /transformers/reports/${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports
188+
cp /transformers/test_outputs.txt "/transformers/reports/${machine_type}_${report_name_prefix}_${matrix_folders}_test_reports"
169189
170190
- name: "Test suite reports artifacts: ${{ env.machine_type }}_${{ inputs.report_name_prefix }}_${{ env.matrix_folders }}_test_reports"
171191
if: ${{ always() }}

.github/workflows/pr_run_slow_ci.yml renamed to .github/workflows/pr_slow_ci_suggestion.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PR slow CI
1+
name: PR slow CI - Suggestion
22
on:
33
pull_request_target:
44
types: [opened, synchronize, reopened]
@@ -59,27 +59,35 @@ jobs:
5959
fetch-depth: "0"
6060

6161
- name: Write pr_files file
62+
env:
63+
PR_FILES: ${{ needs.get-pr-info.outputs.PR_FILES }}
6264
run: |
63-
cat > pr_files.txt << 'EOF'
64-
${{ needs.get-pr-info.outputs.PR_FILES }}
65+
cat > pr_files.txt << EOF
66+
$PR_FILES
6567
EOF
6668
6769
- name: Write tests_dir file
70+
env:
71+
tests_dir: ${{ steps.repo_content.outputs.tests_dir }}
6872
run: |
69-
cat > tests_dir.txt << 'EOF'
70-
${{ steps.repo_content.outputs.tests_dir }}
73+
cat > tests_dir.txt << EOF
74+
$tests_dir
7175
EOF
7276
7377
- name: Write tests_models_dir file
78+
env:
79+
tests_models_dir: ${{ steps.repo_content.outputs.tests_models_dir }}
7480
run: |
75-
cat > tests_models_dir.txt << 'EOF'
76-
${{ steps.repo_content.outputs.tests_models_dir }}
81+
cat > tests_models_dir.txt << EOF
82+
$tests_models_dir
7783
EOF
7884
7985
- name: Write tests_quantization_dir file
86+
env:
87+
tests_quantization_dir: ${{ steps.repo_content.outputs.tests_quantization_dir }}
8088
run: |
81-
cat > tests_quantization_dir.txt << 'EOF'
82-
${{ steps.repo_content.outputs.tests_quantization_dir }}
89+
cat > tests_quantization_dir.txt << EOF
90+
$tests_quantization_dir
8391
EOF
8492
8593
- name: Run script to get jobs to run

0 commit comments

Comments
 (0)