Skip to content

Commit

Permalink
fix(ci): modify JUnit output file to properly name packages for Build…
Browse files Browse the repository at this point in the history
… Pulse

When you go test ./itests/path_to_test.go then your binary is named
"command-line-arguments" thanks to a Go quirk. This hack is to just fix that
directly in the JUnit output before we upload it so we have proper naming.
  • Loading branch information
rvagg committed Sep 6, 2024
1 parent dd08023 commit 605a160
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ jobs:
submodules: 'recursive'
- uses: ./.github/actions/install-system-dependencies
- uses: ./.github/actions/install-go
- run: go install gotest.tools/gotestsum@latest
- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
- name: Restore cached make deps outputs
uses: actions/cache/restore@v4
with:
Expand All @@ -257,10 +258,12 @@ jobs:
path: ${{ needs.cache.outputs.fetch_params_path }}
fail-on-cache-miss: true
# TODO: Install statediff (used to be used for conformance)
- id: reports
- name: Create temporary directory for reports
id: reports
run: mktemp -d | xargs -0 -I{} echo "path={}" | tee -a $GITHUB_OUTPUT
# TODO: Track coverage (used to be tracked for conformance)
- env:
- name: Run tests
env:
NAME: ${{ matrix.name }}
LOTUS_SRC_DIR: ${{ github.workspace }}
REPORTS_PATH: ${{ steps.reports.outputs.path }}
Expand All @@ -275,6 +278,25 @@ jobs:
--jsonfile "$REPORTS_PATH/$NAME.json" \
--packages="$PACKAGES" \
-- ${{ matrix.go_test_flags || '' }}
- name: Modify junit.xml for BuildPulse
env:
NAME: ${{ matrix.name }}
REPORTS_PATH: ${{ steps.reports.outputs.path }}
PACKAGES: ${{ join(matrix.packages, ' ') }}
if: always()
run: |
# Modify test suite name and classname attributes in JUnit XML for better grouping
# in BuildPulse. itests are run with go test ./itests/file_test.go and therefore Go
# assigns the name and classname attributes to "command-line-arguments". Others get the
# package name for both.
if [[ "${{ matrix.name }}" == itest-* ]]; then
PACKAGE_NAME=$(basename "$PACKAGES" .go)
sed -i 's/ name="command-line-arguments"/ name="itests"/g' "$REPORTS_PATH/$NAME.xml"
sed -i 's/classname="command-line-arguments"/classname="'"$PACKAGE_NAME"'"/g' "$REPORTS_PATH/$NAME.xml"
else
sed -i 's# name="github.com/filecoin-project/lotus/\(.*\)"# name="'${{ matrix.name }}':\1"#g' "$REPORTS_PATH/$NAME.xml"
fi
cat "$REPORTS_PATH/$NAME.xml"
- if: success() || failure()
uses: actions/upload-artifact@v4
with:
Expand Down

0 comments on commit 605a160

Please sign in to comment.