Skip to content

Commit cfa0ad8

Browse files
SNOW-2021009: Improving CICD, flakiness fixes (#2569)
1 parent 7708f1b commit cfa0ad8

File tree

2 files changed

+35
-14
lines changed

2 files changed

+35
-14
lines changed

.github/workflows/build_test.yml

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ on:
1818
required: true
1919
tags:
2020
description: "Test scenario tags"
21+
required: false
22+
type: string
23+
24+
permissions:
25+
contents: read
26+
actions: read
27+
checks: write
28+
pull-requests: write
2129

2230
concurrency:
2331
# older builds for the same pull request number or branch should be cancelled
@@ -216,7 +224,6 @@ jobs:
216224
# To run a single test on GHA use the below command:
217225
# run: python -m tox run -e `echo py${PYTHON_VERSION/\./}-single-ci | sed 's/ /,/g'`
218226
run: python -m tox run -e `echo py${PYTHON_VERSION/\./}-{extras,unit-parallel,integ-parallel,pandas-parallel,sso}-ci | sed 's/ /,/g'`
219-
220227
env:
221228
PYTHON_VERSION: ${{ matrix.python-version }}
222229
cloud_provider: ${{ matrix.cloud-provider }}
@@ -225,17 +232,16 @@ jobs:
225232
# To specify the test name (in single test mode) pass this env variable:
226233
# SINGLE_TEST_NAME: test/path/filename.py::test_name
227234
shell: bash
228-
- name: Combine coverages
229-
run: python -m tox run -e coverage --skip-missing-interpreters false
230-
shell: bash
231235
- uses: actions/upload-artifact@v4
236+
if: always()
232237
with:
233238
include-hidden-files: true
234239
name: coverage_${{ matrix.os.download_name }}-${{ matrix.python-version }}-${{ matrix.cloud-provider }}
235240
path: |
236241
.tox/.coverage
237242
.tox/coverage.xml
238243
- uses: actions/upload-artifact@v4
244+
if: always()
239245
with:
240246
include-hidden-files: true
241247
name: junit_${{ matrix.os.download_name }}-${{ matrix.python-version }}-${{ matrix.cloud-provider }}
@@ -363,13 +369,15 @@ jobs:
363369
TOX_PARALLEL_NO_SPINNER: 1
364370
shell: bash
365371
- uses: actions/upload-artifact@v4
372+
if: always()
366373
with:
367374
include-hidden-files: true
368375
name: coverage_linux-fips-3.9-${{ matrix.cloud-provider }}
369376
path: |
370377
.coverage
371378
coverage.xml
372379
- uses: actions/upload-artifact@v4
380+
if: always()
373381
with:
374382
include-hidden-files: true
375383
name: junit_linux-fips-3.9-${{ matrix.cloud-provider }}
@@ -423,21 +431,23 @@ jobs:
423431
TOX_PARALLEL_NO_SPINNER: 1
424432
shell: bash
425433
- uses: actions/upload-artifact@v4
434+
if: always()
426435
with:
427436
include-hidden-files: true
428437
name: coverage_linux-lambda-${{ matrix.python-version }}-${{ matrix.cloud-provider }}
429438
path: |
430439
.coverage.py${{ env.shortver }}-lambda-ci
431440
junit.py${{ env.shortver }}-lambda-ci-dev.xml
432441
- uses: actions/upload-artifact@v4
442+
if: always()
433443
with:
434444
include-hidden-files: true
435445
name: junit_linux-lambda-${{ matrix.python-version }}-${{ matrix.cloud-provider }}
436446
path: |
437447
junit.py${{ env.shortver }}-lambda-ci-dev.xml
438448
439449
combine-coverage:
440-
if: ${{ success() || failure() }}
450+
if: always()
441451
name: Combine coverage
442452
needs: [lint, test, test-fips, test-lambda]
443453
runs-on: ubuntu-latest
@@ -469,6 +479,7 @@ jobs:
469479
dst_file = dst_dir / ".coverage.{}".format(src_file.parent.name[9:])
470480
print("{} copy to {}".format(src_file, dst_file))
471481
shutil.copy(str(src_file), str(dst_file))'
482+
472483
- name: Collect all JUnit XML files to one dir
473484
run: |
474485
python -c '
@@ -478,33 +489,43 @@ jobs:
478489
src_dir = Path("artifacts")
479490
dst_dir = Path(".") / "junit_results"
480491
dst_dir.mkdir()
481-
# Collect all JUnit XML files with different naming patterns
482-
for pattern in ["*/junit.*.xml", "*/junit.py*-lambda-ci-dev.xml"]:
483-
for src_file in src_dir.glob(pattern):
484-
dst_file = dst_dir / src_file.name
485-
print("{} copy to {}".format(src_file, dst_file))
486-
shutil.copy(str(src_file), str(dst_file))'
492+
for src_file in src_dir.glob("*/junit*.xml"):
493+
artifact_name = src_file.parent.name
494+
dst_file = dst_dir / f"{artifact_name}_{src_file.name}"
495+
print("{} copy to {}".format(src_file, dst_file))
496+
shutil.copy(str(src_file), str(dst_file))'
487497
- name: Combine coverages
488-
run: python -m tox run -e coverage
498+
run: |
499+
if [ -d ".tox" ] && [ "$(find .tox -name ".coverage*" -type f | wc -l)" -gt 0 ]; then
500+
python -m tox run -e coverage
501+
else
502+
echo "No coverage files found, skipping coverage combination"
503+
fi
489504
- name: Publish html coverage
505+
if: ${{ success() }}
490506
uses: actions/upload-artifact@v4
491507
with:
492508
include-hidden-files: true
493509
name: overall_cov_html
494510
path: .tox/htmlcov
495511
- name: Publish xml coverage
512+
if: ${{ success() }}
496513
uses: actions/upload-artifact@v4
497514
with:
498515
include-hidden-files: true
499516
name: overall_cov_xml
500517
path: .tox/coverage.xml
501518
- uses: codecov/codecov-action@v4
519+
if: ${{ success() }}
502520
with:
503521
files: .tox/coverage.xml
504522
token: ${{ secrets.CODECOV_TOKEN }}
523+
name: coverage-${{ github.run_id }}
524+
fail_ci_if_error: false
525+
verbose: true
505526
- name: Upload test results to Codecov
506527
if: ${{ !cancelled() }}
507528
uses: codecov/test-results-action@v1
508529
with:
509530
token: ${{ secrets.CODECOV_TOKEN }}
510-
files: junit_results/junit.*.xml
531+
files: junit_results/*.xml

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ depends = py39, py310, py311, py312, py313
164164
[pytest]
165165
log_level = info
166166
addopts = -ra --strict-markers
167-
junit_family = legacy
167+
junit_family = xunit2
168168
filterwarnings =
169169
error::UserWarning:cryptography.*
170170
error::cryptography.utils.CryptographyDeprecationWarning

0 commit comments

Comments
 (0)