Skip to content

Commit

Permalink
Fix conditionals that trigger Artifact upload (#38236)
Browse files Browse the repository at this point in the history
#### Description
After the revert done in
#38230
and
#38231,
I'm looking yet again on what went wrong there.

I'm solving this in small parts, and this PR focuses on ensuring JUnit
Artifacts are uploaded correctly.

#### Link to tracking issue
Still related to
#36761


#### Testing
I plan to test this by looking at the artifacts produced in this PR. The
JUnit files need to be there. See
https://github.com/actions/upload-artifact?tab=readme-ov-file#where-does-the-upload-go

---------

Signed-off-by: Arthur Silva Sens <arthursens2005@gmail.com>
  • Loading branch information
ArthurSens authored Feb 27, 2025
1 parent 7ec4927 commit 6b0a752
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,22 +286,31 @@ jobs:
path: ~/.cache/go-build
key: go-test-build-${{ runner.os }}-${{ matrix.go-version }}-${{ matrix.runner }}-${{ hashFiles('**/go.sum') }}
- name: Run Unit Tests
if: startsWith( matrix.go-version, '1.23' ) != true
id: tests
if: github.ref != 'refs/heads/main' # Runs on every PR and both go versions
run: make gotest GROUP=${{ matrix.group }}
- name: Run Unit Tests With JUnit and Coverage
if: startsWith( matrix.go-version, '1.23' ) # only run junit/coverage on one version
id: tests-with-junit
if: startsWith( matrix.go-version, '~1.23' ) && github.ref == 'refs/heads/main' && github.event_name == 'push' # only run junit/coverage on one version and only on main
continue-on-error: true # Allow uploading artifacts even if the test fails
run: make gotest-with-junit-and-cover GROUP=${{ matrix.group }}
- uses: actions/upload-artifact@v4
if: startsWith( matrix.go-version, '1.23' ) # only upload artifact for one version
if: startsWith( matrix.go-version, '~1.23' ) && github.ref == 'refs/heads/main' && github.event_name == 'push' # only upload artifact for one version and only on main
with:
name: coverage-artifacts-${{ matrix.go-version }}-${{ matrix.runner }}-${{ matrix.group }}
path: ${{ matrix.group }}-coverage.txt
- uses: actions/upload-artifact@v4
if: startsWith( matrix.go-version, '1.23' ) # only upload artifact for one version
if: startsWith( matrix.go-version, '~1.23' ) && github.ref == 'refs/heads/main' && github.event_name == 'push' # only upload artifact for one version and only on main
with:
name: test-results-${{ matrix.go-version }}-${{ matrix.runner }}-${{ matrix.group }}
path: internal/tools/testresults/
retention-days: 4
- name: Fail workflow if tests fails
if: steps.tests-with-junit.outcome == 'failure' || steps.tests.outcome == 'failure'
run: |
echo "Tests failed. Failing workflow."
exit 1
unittest:
if: ${{ github.actor != 'dependabot[bot]' && always() }}
runs-on: ubuntu-24.04
Expand Down

0 comments on commit 6b0a752

Please sign in to comment.