Skip to content

Commit

Permalink
Clean up upload workflow
Browse files Browse the repository at this point in the history
b/290997541
  • Loading branch information
oxve committed Jul 20, 2023
1 parent 014483a commit 3d07d01
Showing 1 changed file with 16 additions and 30 deletions.
46 changes: 16 additions & 30 deletions .github/workflows/unit_test_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,11 @@ jobs:
runs-on: ubuntu-latest
name: Upload Unit Test Reports
steps:
- name: Collect Unit Test Reports
- name: Download Unit Test Results
id: collect-report
uses: actions/github-script@v6
with:
script: |
console.log('context', context);
console.log('context.payload.workflow_run.pull_requests', context.payload.workflow_run.pull_requests);
console.log('context.payload.workflow_run.head_commit', context.payload.workflow_run.head_commit);
// The `download-artifact` action can only access artifacts that
// were uploaded in the same workflow. Since it was not this
// workflow that uploaded the artifacts we must use rest api
Expand All @@ -49,49 +45,42 @@ jobs:
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
console.log(allArtifacts);
let matchArtifacts = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "unit-test-results"
});
console.log(matchArtifacts)
if (matchArtifacts.length == 0) {
// No reports were uploaded.
console.log('No unit test reports were uploaded');
return false;
}
let download = await github.rest.actions.downloadArtifact({
if (matchArtifacts.length == 1) {
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifacts[0].id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/unit-test-results.zip`, Buffer.from(download.data));
return true;
- run: unzip unit-test-results.zip -d unit-test-results
if: ${{ steps.collect-report.outputs.result == 'true' }}
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/unit-test-results.zip`, Buffer.from(download.data));
} else {
// TODO: Comment on PR?
core.setFailed('Expected exactly ');
}
- name: Extract Archived Unit Test Results
run: unzip unit-test-results.zip -d unit-test-results
- name: Install node
if: steps.collect-report.outputs.result
uses: actions/setup-node@v3
with:
node-version: 16
- name: Get Datadog CLI
if: ${{ steps.collect-report.outputs.result == 'true' }}
shell: bash
# TODO: pin version (with checksum?)
run: npm install -g @datadog/datadog-ci
- name: Upload the JUnit files
if: ${{ steps.collect-report.outputs.result == 'true' }}
- name: Upload To Datadog
shell: bash
env:
DATADOG_API_KEY: ${{ secrets.DD_API_KEY }}
DATADOG_SITE: us5.datadoghq.com
DD_ENV: ci
DD_SERVICE: ${{ github.event.repository.name }}
# TODO
# DD_METRICS:

# Git info
# Need to populate git info via env vars as we don't have the repo to look at.
DD_GIT_REPOSITORY_URL: ${{ github.event.repository.git_url }}
DD_GIT_COMMIT_SHA: ${{ github.event.workflow_run.head_sha }}
DD_GIT_BRANCH: ${{ github.event.workflow_run.head_branch }}
Expand All @@ -101,14 +90,11 @@ jobs:
DD_GIT_COMMIT_AUTHOR_DATE: ${{ github.event.workflow_run.head_commit.timestamp }}
DD_GIT_COMMIT_COMMITTER_NAME: ${{ github.event.workflow_run.head_commit.committer.name }}
DD_GIT_COMMIT_COMMITTER_EMAIL: ${{ github.event.workflow_run.head_commit.committer.email }}
# TODO: Not available?
DD_GIT_COMMIT_COMMITTER_DATE: ${{ github.event.workflow_run.head_commit.timestamp }}
run: |
# Loop over each platform, extract the tags and upload xml results.
# Unit test results are archived on the following format:
#
# unit-test-results/
# ├── android-arm
# │ ├── <shards>
# │ │ └── <test result xmls>
Expand Down

0 comments on commit 3d07d01

Please sign in to comment.