diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14d0b24f..f186fd44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/fork.yml b/.github/workflows/unit-test-results.yml similarity index 63% rename from .github/workflows/fork.yml rename to .github/workflows/unit-test-results.yml index 3f74d4f2..2aae3b23 100644 --- a/.github/workflows/fork.yml +++ b/.github/workflows/unit-test-results.yml @@ -1,4 +1,4 @@ -name: Fork +name: Unit Test Results on: workflow_run: @@ -8,23 +8,26 @@ 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, @@ -32,21 +35,22 @@ jobs: 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"