Skip to content

Commit

Permalink
CI: replace test execution handler with conditional (#502)
Browse files Browse the repository at this point in the history
* replace test execution handler with conditional

* reorder env

* forgot rules of this repo
  • Loading branch information
ykim-akamai authored May 9, 2024
1 parent 7c73ad6 commit 87593bd
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,42 +55,25 @@ jobs:
- name: Install go-junit-report
run: go install github.com/jstemmer/go-junit-report/v2@latest

- name: Set report filename
run: echo "REPORT_FILENAME=$(date +'%Y%m%d%H%M')_linodego_test_report.xml" >> $GITHUB_ENV

- name: Run tests and save test report
run: |
timestamp=$(date +'%Y%m%d%H%M')
report_filename="${timestamp}_linodego_test_report.xml"
if ! make test | go-junit-report -set-exit-code > "$report_filename"; then
echo "EXIT_STATUS=1" >> $GITHUB_ENV
fi
cat "$report_filename"
make test | go-junit-report -set-exit-code -iocopy -out $REPORT_FILENAME
env:
SKIP_LINT: 1

- name: Add additional information to XML report
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
- name: Upload test results to bucket
if: github.ref == 'refs/heads/main' && github.event_name == 'push' && always()
run: |
filename=$(ls | grep -E '^[0-9]{12}_linodego_test_report\.xml$')
python tod_scripts/add_to_xml_test_report.py \
--branch_name "${GITHUB_REF#refs/*/}" \
--gha_run_id "$GITHUB_RUN_ID" \
--gha_run_number "$GITHUB_RUN_NUMBER" \
--xmlfile "${filename}"
- name: Upload test results to bucket
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
--xmlfile "$REPORT_FILENAME"
sync
python tod_scripts/test_report_upload_script.py "$REPORT_FILENAME"
env:
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
run: |
report_filename=$(ls | grep -E '^[0-9]{12}_linodego_test_report\.xml$')
python tod_scripts/test_report_upload_script.py "${report_filename}"
- name: Test Execution Status Handler
run: |
if [[ "$EXIT_STATUS" != 0 ]]; then
echo "Test execution contains failure(s)"
exit $EXIT_STATUS
else
echo "Tests passed!"
fi

0 comments on commit 87593bd

Please sign in to comment.