Skip to content

Commit

Permalink
Move publishing unit test results entirely into separate workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoMi committed Mar 17, 2021
1 parent 1bfbc5b commit 6951426
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 36 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/ci.yml
Expand Up @@ -142,31 +142,6 @@ jobs:
!target/surefire-reports/TEST-org.scalatest*.xml
target/site/surefire-report.html
publish-test-results:
name: Publish Unit Tests Results
needs: test

runs-on: ubuntu-latest
# the workflow is useless on pull_request events from fork repositories
# as it can not create check runs or pull request comments
if: >
( success() || failure() ) &&
( github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository )
steps:
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts

- name: Publish Unit Test Results
uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1
with:
github_token: ${{ github.token }}
files: "artifacts/Unit Test Results*/**/*.xml"
comment_on_pr: ${{ github.event_name != 'push' }}
log_level: DEBUG

integration:
name: Integration Tests (Dgraph ${{ matrix.dgraph-version }})
runs-on: ubuntu-latest
Expand Down
@@ -1,4 +1,4 @@
name: Fork
name: Unit Test Results

on:
workflow_run:
Expand All @@ -8,45 +8,49 @@ on:

jobs:
unit-test-results:
name: Unit Test Results from Fork
name: Unit Test Results
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion != 'skipped' &&
github.event.workflow_run.head_repository.full_name != github.repository
if: github.event.workflow_run.conclusion != 'skipped'

steps:
- name: Download Artifacts
uses: actions/github-script@v3.1.0
with:
script: |
var fs = require('fs');
var path = require('path');
var artifacts_path = path.join('${{github.workspace}}', 'artifacts')
fs.mkdirSync(artifacts_path, { recursive: true })
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
for (const artifact of artifacts.data.artifacts) {
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync(`${{github.workspace}}/artifact-${artifact.id}.zip`, Buffer.from(download.data));
var artifact_path = path.join(artifacts_path, `${artifact.name}.zip`)
fs.writeFileSync(artifact_path, Buffer.from(download.data));
console.log(`Downloaded ${artifact_path}`);
}
- name: Extract Artifacts
run: |
for file in artifact-*.zip
for file in artifacts/*.zip
do
dir="${file/%.zip/}"
mkdir -p "$dir"
unzip -d "$dir" "$file"
done
- name: Unit Test Results
- name: Publish Unit Test Results
uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1
with:
github_token: ${{ github.token }}
commit: ${{ github.event.workflow_run.head_sha }}
files: "**/*.xml"
files: "artifacts/Unit Test Results*/**/*.xml"

0 comments on commit 6951426

Please sign in to comment.