Skip to content

Commit

Permalink
Add test report once at the end of the build
Browse files Browse the repository at this point in the history
Issue: ZENKO-4876
  • Loading branch information
francoisferrand committed Oct 9, 2024
1 parent 94dc966 commit a5c8766
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 17 deletions.
41 changes: 28 additions & 13 deletions .github/actions/archive-artifacts/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ inputs:
required: true
stage:
description: Stage name
default: ${{ github.job }}.${{ github.run_attempt }}
default: ${{ github.job }}
required: true
trunk_token:
description: Trunk token
Expand All @@ -35,10 +35,20 @@ runs:
- name: Publish test report
uses: mikepenz/action-junit-report@v4
with:
check_name: ${{ inputs.stage}}
annotate_only: true
check_name: ${{ inputs.stage }}
job_summary: false
report_paths: ${{ inputs.junit-paths }}
continue-on-error: true

- name: Upload test reports
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.stage }}-test-report
path: ${{ inputs.junit-paths }}
overwrite: true
retention-days: 5

- name: Upload results
if: inputs.trunk_token && job.status != 'cancelled'
uses: trunk-io/analytics-uploader@v1.4.0
Expand All @@ -51,17 +61,22 @@ runs:
- name: Archive artifact logs and data
shell: bash
run: |-
set -exu;
mkdir -p /tmp/artifacts/data/${STAGE}/kind-logs;
kubectl get pods -A -o yaml > /tmp/artifacts/data/${STAGE}/kind-logs/all-pods.log;
kubectl get events -A -o yaml > /tmp/artifacts/data/${STAGE}/kind-logs/all-events.log;
kubectl get zenko -A -o yaml > /tmp/artifacts/data/${STAGE}/kind-logs/all-zenkos.log;
kubectl get zenkodrsource -A -o yaml > /tmp/artifacts/data/${STAGE}/kind-logs/all-zenkodrsources.log;
kubectl get zenkodrsink -A -o yaml > /tmp/artifacts/data/${STAGE}/kind-logs/all-zenkodrsinks.log;
kind export logs /tmp/artifacts/data/${STAGE}/kind-logs/kind-export;
tar zcvf /tmp/artifacts/${{ github.sha }}-${STAGE}-logs-volumes.tgz /tmp/artifacts/data/${STAGE}/kind-logs;
set -exu
mkdir -p /tmp/artifacts/data/${STAGE}/kind-logs
kubectl get pods -A -o yaml > /tmp/artifacts/data/${STAGE}/kind-logs/all-pods.log
kubectl get events -A -o yaml > /tmp/artifacts/data/${STAGE}/kind-logs/all-events.log
kubectl get zenko -A -o yaml > /tmp/artifacts/data/${STAGE}/kind-logs/all-zenkos.log
kubectl get zenkodrsource -A -o yaml > /tmp/artifacts/data/${STAGE}/kind-logs/all-zenkodrsources.log
kubectl get zenkodrsink -A -o yaml > /tmp/artifacts/data/${STAGE}/kind-logs/all-zenkodrsinks.log
kind export logs /tmp/artifacts/data/${STAGE}/kind-logs/kind-export
tar zcvf /tmp/artifacts/${{ github.sha }}-${STAGE}-logs-volumes.tgz
/tmp/artifacts/data/${STAGE}/kind-logs
mkdir -p /tmp/artifacts/data/${STAGE}/tests
cp -r ${JUNIT_PATHS} /tmp/artifacts/data/${STAGE}/tests
env:
STAGE: ${{ inputs.stage }}
STAGE: ${{ inputs.stage }}.${{ github.run_attempt }}
JUNIT_PATHS: ${{ inputs.junit-paths }}
continue-on-error: true

- name: Dump kafka
Expand Down Expand Up @@ -91,7 +106,7 @@ runs:
kcat -L -b ${KAFKA_SERVICE} -t {} -C -o beginning -e -q -J \
> /tmp/artifacts/data/${STAGE}/kafka-messages-{}.log"
env:
STAGE: ${{ inputs.stage }}
STAGE: ${{ inputs.stage }}.${{ github.run_attempt }}
NAMESPACE: ${{ inputs.zenko-namespace }}
ZENKO_NAME: ${{ inputs.zenko-name }}
continue-on-error: true
Expand Down
3 changes: 1 addition & 2 deletions .github/actions/debug-wait/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ runs:
using: composite
steps:
- name: "Debug: SSH to runner"
uses: scality/actions/action-ssh-to-runner@1.8.0
uses: scality/actions/action-ssh-to-runner@1.9.0
continue-on-error: true
with:
tmate-server-host: ${{ env.TMATE_SERVER_HOST }}
tmate-server-port: ${{ env.TMATE_SERVER_PORT }}
tmate-server-rsa-fingerprint: ${{ env.TMATE_SERVER_RSA_FINGERPRINT }}
tmate-server-ed25519-fingerprint: ${{ env.TMATE_SERVER_ED25519_FINGERPRINT }}
if: job.status == 'failure' && runner.debug == '1'
58 changes: 56 additions & 2 deletions .github/workflows/end2end.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ jobs:
- name: Debug wait
uses: ./.github/actions/debug-wait
timeout-minutes: 60
if: failure() && runner.debug == '1'
- name: Archive and publish artifacts
uses: ./.github/actions/archive-artifacts
with:
Expand Down Expand Up @@ -475,6 +476,7 @@ jobs:
- name: Debug wait
uses: ./.github/actions/debug-wait
timeout-minutes: 60
if: failure() && runner.debug == '1'
- name: Archive and publish artifacts
uses: ./.github/actions/archive-artifacts
with:
Expand Down Expand Up @@ -526,6 +528,7 @@ jobs:
- name: Debug wait
uses: ./.github/actions/debug-wait
timeout-minutes: 60
if: failure() && runner.debug == '1'
- name: Archive and publish artifacts
uses: ./.github/actions/archive-artifacts
with:
Expand Down Expand Up @@ -565,6 +568,7 @@ jobs:
- name: Debug wait
uses: ./.github/actions/debug-wait
timeout-minutes: 60
if: failure() && runner.debug == '1'
- name: Archive and publish artifacts
uses: ./.github/actions/archive-artifacts
with:
Expand Down Expand Up @@ -611,6 +615,7 @@ jobs:
- name: Debug wait
uses: ./.github/actions/debug-wait
timeout-minutes: 60
if: failure() && runner.debug == '1'
- name: Archive and publish artifacts
uses: ./.github/actions/archive-artifacts
with:
Expand All @@ -635,11 +640,60 @@ jobs:
- end2end-sharded
- end2end-pra
- ctst-end2end-sharded
if: always()
permissions:
checks: write
steps:
- name: Upload final status
uses: scality/actions/upload_final_status@1.8.0
uses: scality/actions/upload_final_status@1.9.0
with:
ARTIFACTS_USER: ${{ secrets.ARTIFACTS_USER }}
ARTIFACTS_PASSWORD: ${{ secrets.ARTIFACTS_PASSWORD }}
JOBS_RESULTS: ${{ join(needs.*.result) }}
if: always()

- name: Download all workflow run artifacts
uses: actions/download-artifact@v4

- name: List test reports
run: |
REPORT_PATHS=
CHECK_NAMES=
for REPORT in *-test-report ; do
REPORT_PATHS="${REPORT_PATHS}\n${REPORT}/*.xml"
CHECK_NAMES="${CHECK_NAMES}\n${REPORT%-test-report}"
done
echo -e "REPORT_PATHS<<EOF$REPORT_PATHS\nEOF" >> "$GITHUB_ENV"
echo -e "CHECK_NAMES<<EOF$CHECK_NAMES\nEOF" >> "$GITHUB_ENV"
- name: Generate test summary
uses: mikepenz/action-junit-report@v4
id: summary
with:
annotate_only: true # Do not generate a Check or summary
check_retries: true # Check for retries
job_summary: false # No job summary
report_paths: ${{ env.REPORT_PATHS }}
check_name: ${{ env.CHECK_NAMES }}

- name: Publish summary
run: |
NO_ERROR='<tr><td>-</td><td>No test annotations available</td><td>-</td></tr>'
DETAILED_SUMMARY=${DETAILED_SUMMARY//$NO_ERROR}
FLAKY_SUMMARY=${FLAKY_SUMMARY//$NO_ERROR}
SUMMARY="${SUMMARY} ${DETAILED_SUMMARY} ${FLAKY_SUMMARY}"
echo "${SUMMARY}" >> $GITHUB_STEP_SUMMARY
echo "SUMMARY=${SUMMARY}" >> $GITHUB_ENV
env:
SUMMARY: ${{ steps.summary.outputs.summary }}
DETAILED_SUMMARY: ${{ steps.summary.outputs.detailed_summary }}
FLAKY_SUMMARY: ${{ steps.summary.outputs.flaky_summary }}

- name: Publish check with test results
uses: mikepenz/action-junit-report@v4
with:
check_name: 🧪 Test results # Create a new aggregate check
job_summary: false # No job summary
summary: ${{ env.SUMMARY }} # Use the summary from the previous step (in the check)
report_paths: '*-test-report/*.xml'

0 comments on commit a5c8766

Please sign in to comment.