Skip to content

Publish-Test-Results #4015

Publish-Test-Results

Publish-Test-Results #4015

name: Publish-Test-Results
on:
workflow_run:
workflows: ["K8s-CI"]
types:
- completed
env:
AWS_REGION: "eu-west-1"
ALLURE_S3_BUCKET: "s3://csp-allure-reports/allure_reports/cloudbeat/prs"
S3_BUCKET_ALLURE_REPORT_AP: "http://csp-allure-reports.s3.amazonaws.com/allure_reports/cloudbeat/prs"
jobs:
publish_results:
timeout-minutes: 40
name: Publish Results
runs-on: ubuntu-20.04
if: github.event.workflow_run.conclusion != 'skipped'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
permissions:
checks: write
# needed unless run with comment_mode: off
pull-requests: write
# required by download step to access artifacts API
actions: read
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download and Extract Artifacts
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p tests/allure/results
mkdir -p artifacts && cd artifacts
artifacts_url=${{ github.event.workflow_run.artifacts_url }}
gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
do
IFS=$'\t' read name url <<< "$artifact"
gh api $url > "$name.zip"
unzip -o "$name.zip" -d "../tests/allure/results"
done
- name: Get pr info
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUM=$(gh api -X GET search/issues -f q='elastic/cloudbeat is:open is:pr is:unmerged ${{ github.event.workflow_run.head_sha }}' | jq '.items[0].number' )
echo "PR_NUMBER=$PR_NUM"
echo "PR_NUMBER=$PR_NUM" >> $GITHUB_ENV
- name: Publish allure report
if: always()
uses: andrcuns/allure-publish-action@v2.3.0
env:
GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
storageType: s3
resultsGlob: "tests/allure/results"
updatePr: actions
collapseSummary: false
summary: suites
summaryTableType: markdown
copyLatest: true
bucket: csp-allure-reports
prefix: allure_reports/cloudbeat/prs/${{ env.PR_NUMBER }}
ignoreMissingResults: true
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2.1.0
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Copy allure report json from S3
run: |
aws s3 cp ${{ env.ALLURE_S3_BUCKET }}/${{ env.PR_NUMBER }}/history/history-trend.json .
- name: Output to Job Summary
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
allure_result=./history-trend.json
allure_url=${{ env.S3_BUCKET_ALLURE_REPORT_AP }}/${{ env.PR_NUMBER }}/index.html
./.ci/scripts/allure-report-summary.sh "$allure_result" "$allure_url"
allure_summary=$(./.ci/scripts/allure-report-summary.sh "$allure_result" "$allure_url")
# posting result into job summary
echo "$allure_summary" >> $GITHUB_STEP_SUMMARY
# saving result into env variable (with multiline handling)
echo "ALLURE_SUMMARY<<EOF" >> $GITHUB_ENV
echo "$allure_summary" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Comment test success result
uses: marocchino/sticky-pull-request-comment@v2
if: ${{ github.event.workflow_run.event == 'pull_request' }}
with:
header: Test Results
number: ${{ env.PR_NUMBER }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: |
${{ env.ALLURE_SUMMARY }}