devops: add upload report action (#24222)

* Fix report downloading from Azure (reports are now zipped)
* Extracted upload logic into an action
* Extracted PR number file generation into its own job
This commit is contained in:
Yury Semikhatsky 2023-07-14 08:21:15 -07:00 committed by GitHub
parent 98f3ca05b9
commit 1b1cf87e0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 64 deletions

View File

@ -23,7 +23,7 @@ runs:
OUTPUT_DIR='${{ inputs.output_dir }}'
mkdir -p $OUTPUT_DIR
LIST=$(az storage blob list -c '$web' --prefix ${{ inputs.blob_prefix }} --connection-string "${{ inputs.connection_string }}")
for name in $(echo $LIST | jq --raw-output '.[].name | select(test(".jsonl$"))');
for name in $(echo $LIST | jq --raw-output '.[].name | select(test("report-.*\\.zip$"))');
do
az storage blob download -c '$web' --name $name -f $OUTPUT_DIR/$(basename $name) --connection-string "${{ inputs.connection_string }}"
done
done

View File

@ -0,0 +1,28 @@
name: 'Upload blob report'
description: 'Upload blob to Azure blob storage or to GitHub artifacts (for pull requests)'
inputs:
report_dir:
description: 'Directory containing blob report'
required: true
type: string
default: 'test-results/blob-report'
connection_string:
description: 'Azure connection string'
required: true
type: string
runs:
using: "composite"
steps:
- name: Upload blob report to Azure
if: always() && github.event_name == 'push'
shell: bash
run: |
REPORT_DIR='run-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.sha }}'
az storage blob upload-batch -s "${{ inputs.report_dir }}" -d "\$web/$REPORT_DIR" --connection-string "${{ inputs.connection_string }}"
- name: Upload blob report to GitHub
if: always() && github.event_name == 'pull_request'
uses: actions/upload-artifact@v3
with:
name: blob-report-${{ github.run_attempt }}
path: ${{ inputs.report_dir }}
retention-days: 30

View File

@ -28,14 +28,6 @@ jobs:
with:
name: 'blob-report-${{ github.event.workflow_run.run_attempt }}'
path: 'blob-report'
- name: Read pull request number
if: ${{ always() && github.event.workflow_run.event == 'pull_request' }}
uses: ./.github/actions/download-artifact
with:
name: 'pull-request'
path: './'
- name: Download blob report from Azure
if: ${{ always() && github.event.workflow_run.event == 'push' }}
uses: ./.github/actions/download-blob-report-from-azure
@ -60,6 +52,13 @@ jobs:
REPORT_DIR='run-${{ github.event.workflow_run.id }}-${{ github.event.workflow_run.run_attempt }}-${{ github.sha }}'
az storage blob upload-batch -s blob-report -d "\$web/$REPORT_DIR" --connection-string "${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}"
- name: Read pull request number
if: ${{ always() && github.event.workflow_run.event == 'pull_request' }}
uses: ./.github/actions/download-artifact
with:
name: 'pull-request'
path: './'
- name: Comment on PR
uses: actions/github-script@v6
with:
@ -80,6 +79,10 @@ jobs:
...context.repo,
commit_sha: context.sha,
});
if (!data.length) {
core.info(`No pull request found for commit ${context.sha}. Not publishing anything.`);
return;
}
prNumber = data[0].number;
} else {
core.error('Unsupported workflow trigger event: ' + context.payload.workflow_run.event);

View File

@ -61,25 +61,12 @@ jobs:
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
if: always()
shell: bash
- name: Upload blob report to Azure
if: always() && github.event_name == 'push'
run: az storage blob upload-batch -s test-results/blob-report -d '$web/run-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.sha }}' --connection-string "${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}"
- name: Upload blob report to GitHub
uses: actions/upload-artifact@v3
if: always() && github.event_name == 'pull_request'
- name: Upload blob report
if: always()
uses: ./.github/actions/upload-blob-report
with:
name: blob-report-${{ github.run_attempt }}
path: test-results/blob-report
retention-days: 30
- name: Write the pull request number in an file
if: always() && github.event_name == 'pull_request'
run: echo '${{ github.event.number }}' > pull_request_number.txt;
- name: Upload artifact with pull request number
uses: actions/upload-artifact@v3
if: always() && github.event_name == 'pull_request'
with:
name: pull-request
path: pull_request_number.txt
report_dir: test-results/blob-report
connection_string: '${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}'
test_linux_chromium_tot:
name: ${{ matrix.os }} (chromium tip-of-tree)
@ -102,6 +89,8 @@ jobs:
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test -- --project=chromium
env:
PWTEST_CHANNEL: chromium-tip-of-tree
PWTEST_BLOB_REPORT: 1
PWTEST_BLOB_SUFFIX: "-${{ matrix.os }}-chromium-tip-of-tree"
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
if: always()
shell: bash
@ -151,25 +140,12 @@ jobs:
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
if: always()
shell: bash
- name: Upload blob report to Azure
if: always() && github.event_name == 'push'
run: az storage blob upload-batch -s test-results/blob-report -d '$web/run-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.sha }}' --connection-string "${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}"
- name: Upload blob report to GitHub
uses: actions/upload-artifact@v3
if: always() && github.event_name == 'pull_request'
- name: Upload blob report
if: always()
uses: ./.github/actions/upload-blob-report
with:
name: blob-report-${{ github.run_attempt }}
path: test-results/blob-report
retention-days: 30
- name: Write the pull request number in an file
if: always() && github.event_name == 'pull_request'
run: echo '${{ github.event.number }}' > pull_request_number.txt;
- name: Upload artifact with pull request number
uses: actions/upload-artifact@v3
if: always() && github.event_name == 'pull_request'
with:
name: pull-request
path: pull_request_number.txt
report_dir: test-results/blob-report
connection_string: '${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}'
test_web_components:
name: Web Components
@ -245,3 +221,16 @@ jobs:
if: always()
shell: bash
write-pull-request-number:
name: Write PR number
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Write triggering pull request number in a file
shell: bash
run: echo '${{ github.event.number }}' > pull_request_number.txt;
- name: Upload artifact with the pull request number
uses: actions/upload-artifact@v3
with:
name: pull-request
path: pull_request_number.txt

View File

@ -208,25 +208,12 @@ jobs:
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
if: always()
shell: bash
- name: Upload blob report to Azure
if: always() && github.event_name == 'push'
run: az storage blob upload-batch -s test-results/blob-report -d '$web/run-${{ github.run_id }}-${{ github.run_attempt }}-${{ github.sha }}' --connection-string "${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}"
- name: Upload blob report to GitHub
uses: actions/upload-artifact@v3
if: always() && github.event_name == 'pull_request'
- name: Upload blob report
if: always()
uses: ./.github/actions/upload-blob-report
with:
name: blob-report-${{ github.run_attempt }}
path: test-results/blob-report
retention-days: 30
- name: Write the pull request number in an file
if: always() && github.event_name == 'pull_request'
run: echo '${{ github.event.number }}' > pull_request_number.txt;
- name: Upload artifact with pull request number
uses: actions/upload-artifact@v3
if: always() && github.event_name == 'pull_request'
with:
name: pull-request
path: pull_request_number.txt
report_dir: test-results/blob-report
connection_string: '${{ secrets.AZURE_CONNECTION_STRING_FOR_BLOB_REPORT }}'
chrome_stable_linux:
name: "Chrome Stable (Linux)"
@ -686,3 +673,17 @@ jobs:
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
if: always()
shell: bash
write-pull-request-number:
name: Write PR number
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Write triggering pull request number in a file
shell: bash
run: echo '${{ github.event.number }}' > pull_request_number.txt;
- name: Upload artifact with the pull request number
uses: actions/upload-artifact@v3
with:
name: pull-request
path: pull_request_number.txt