From 4d9f73c8bf21dff16fcee08dccb1bdbdf5c72545 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 18 Sep 2024 11:45:45 +1000 Subject: [PATCH 1/3] Moving the test reporter to its own workflow, so it should run on forks --- .github/workflows/dotnet-ci.yml | 21 --------------------- .github/workflows/test-reporting.yml | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/test-reporting.yml diff --git a/.github/workflows/dotnet-ci.yml b/.github/workflows/dotnet-ci.yml index 973498a3..254296d6 100644 --- a/.github/workflows/dotnet-ci.yml +++ b/.github/workflows/dotnet-ci.yml @@ -108,24 +108,3 @@ jobs: working-directory: samples env: PYTHON_VERSION: ${{ steps.installpython.outputs.python-version }} - - test-reporting: - permissions: - contents: read - actions: read - checks: write - runs-on: ubuntu-latest - needs: build - steps: - - uses: actions/checkout@v4 - - uses: actions/download-artifact@v4 - with: - merge-multiple: true - - - name: Test Report - uses: dorny/test-reporter@v1 - if: success() || failure() - with: - name: ".NET Tests" - path: "*.trx" - reporter: dotnet-trx diff --git a/.github/workflows/test-reporting.yml b/.github/workflows/test-reporting.yml new file mode 100644 index 00000000..3506ab2d --- /dev/null +++ b/.github/workflows/test-reporting.yml @@ -0,0 +1,16 @@ +name: "Test Report" +on: + workflow_run: + workflows: [".NET CI"] + types: + - completed +jobs: + report: + runs-on: ubuntu-latest + steps: + - uses: phoenix-actions/test-reporting@v15 + id: test-report + with: + name: ".NET Tests" + path: "*.trx" + reporter: dotnet-trx From fbf9370e1dac500653b5fea7a85e5caec062500d Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 18 Sep 2024 11:49:52 +1000 Subject: [PATCH 2/3] Supporting multiple test bundles --- .github/workflows/test-reporting.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-reporting.yml b/.github/workflows/test-reporting.yml index 3506ab2d..5026c9f2 100644 --- a/.github/workflows/test-reporting.yml +++ b/.github/workflows/test-reporting.yml @@ -11,6 +11,7 @@ jobs: - uses: phoenix-actions/test-reporting@v15 id: test-report with: - name: ".NET Tests" path: "*.trx" reporter: dotnet-trx + artifact: /test-results-(.*)/ + name: ".NET Test report $1" From 5ecd069b844c5a0c58701584fab7bc5b1c021847 Mon Sep 17 00:00:00 2001 From: Aaron Powell Date: Wed, 18 Sep 2024 12:15:06 +1000 Subject: [PATCH 3/3] publishing to GitHub packages only after packaging job completes. Done as a workflow_run trigger so that we can run in the right GITHUB_TOKEN context --- .github/workflows/dotnet-publish-ci.yml | 10 +--------- .../workflows/dotnet-publish-gh-packages.yml | 19 +++++++++++++++++++ .github/workflows/dotnet-publish-main.yml | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/dotnet-publish-gh-packages.yml diff --git a/.github/workflows/dotnet-publish-ci.yml b/.github/workflows/dotnet-publish-ci.yml index 6ccf9c81..3b98650f 100644 --- a/.github/workflows/dotnet-publish-ci.yml +++ b/.github/workflows/dotnet-publish-ci.yml @@ -1,7 +1,7 @@ # This workflow will build a .NET project # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net -name: .NET Publish (GitHub Packages) +name: .NET Publish (CI) on: pull_request: @@ -16,11 +16,6 @@ env: jobs: publish-github-packages: runs-on: ubuntu-latest - permissions: - contents: read - packages: write - attestations: write - id-token: write steps: - uses: actions/checkout@v4 - name: Setup .NET @@ -46,6 +41,3 @@ jobs: with: name: nuget-packages path: ./nuget - - - name: Publish to GitHub packages - run: dotnet nuget push ./nuget/*.nupkg --source "https://nuget.pkg.github.com/tonybaloney/index.json" --api-key ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/dotnet-publish-gh-packages.yml b/.github/workflows/dotnet-publish-gh-packages.yml new file mode 100644 index 00000000..a4e4af3a --- /dev/null +++ b/.github/workflows/dotnet-publish-gh-packages.yml @@ -0,0 +1,19 @@ +name: "Publish NuGet packages to GitHub Packages" +on: + workflow_run: + workflows: [".NET Publish (CI)"] + types: + - completed +jobs: + report: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + name: nuget-packages + run-id: ${{ github.event.workflow_run.id }} diff --git a/.github/workflows/dotnet-publish-main.yml b/.github/workflows/dotnet-publish-main.yml index 364b21e4..4142a6cf 100644 --- a/.github/workflows/dotnet-publish-main.yml +++ b/.github/workflows/dotnet-publish-main.yml @@ -1,7 +1,7 @@ # This workflow will build a .NET project # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net -name: .NET Publish (NuGet) +name: .NET Publish (main) on: push: