Skip to content

Commit

Permalink
Merge pull request #65 from kdubb/fix/workflow-test-results
Browse files Browse the repository at this point in the history
Fix test result reporting in workflows
  • Loading branch information
kdubb authored Mar 6, 2023
2 parents 7f360a5 + df91480 commit b1e1d45
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 166 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/pr-build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,11 @@ jobs:
- name: Build/Test
run: make build-test-${{ matrix.platform }}

- name: Upload Test Results
uses: actions/upload-artifact@v3
- name: Report Test Results
uses: kdubb/xcresulttool@v1
if: success() || failure()
with:
name: test-results-${{ matrix.platform }}
# "./dummy" is included to ensure "TestResults" path is archived
path: |
./dummy
TestResults/*.xcresult/
title: Test Results ${{ matrix.platform }}
path: ./TestResults/${{ matrix.platform }}.xcresult
upload-bundles: never
show-code-coverage: false
159 changes: 0 additions & 159 deletions .github/workflows/pr-report.yaml

This file was deleted.

66 changes: 66 additions & 0 deletions .github/workflows/pr-scan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: PR Scan

on:
workflow_run:
workflows: ["PR Buid/Test"]
types: [completed]

jobs:

sonar-scan:

runs-on: macos-12

if: github.event.workflow_run.conclusion == 'success'

steps:

- name: Install Tools
run: |
brew install sonar-scanner
env:
HOMEBREW_NO_INSTALL_CLEANUP: 1

- name: Get PR Info
uses: potiuk/get-workflow-origin@v1_5
id: pr_info
with:
token: ${{ secrets.GITHUB_TOKEN }}
sourceRunId: ${{ github.event.workflow_run.id }}

- name: Checkout PR
uses: actions/checkout@v3
with:
ref: ${{ steps.pr_info.outputs.mergeCommitSha }}
fetch-depth: 0

- name: Download Build
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let buildResultsArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "build-results"
})[0];
let buildResultsDownload = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: buildResultsArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/build-results.tar.gz`, Buffer.from(buildResultsDownload.data));
- name: Extract Build Results
run: tar -xzf build-results.tar.gz

- name: Sonar Scanner
run: |
sonar-scanner -Dsonar.scm.revision=${{ steps.pr_info.outputs.sourceHeadSha }} -Dsonar.pullrequest.key=${{ steps.pr_info.outputs.pullRequestNumber }} -Dsonar.pullrequest.branch=${{ steps.pr_info.outputs.sourceHeadBranch }} -Dsonar.pullrequest.base=${{ steps.pr_info.outputs.targetBranch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

0 comments on commit b1e1d45

Please sign in to comment.