From fce715523246d30003f173e501c2b2f8c17c11e4 Mon Sep 17 00:00:00 2001 From: krymtkts Date: Thu, 4 Jan 2024 15:41:53 +0900 Subject: [PATCH 1/5] Change the path for the coverage report XML. --- psakefile.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/psakefile.ps1 b/psakefile.ps1 index b24d2557..4a96b9a8 100644 --- a/psakefile.ps1 +++ b/psakefile.ps1 @@ -46,11 +46,12 @@ Task UnitTest { if (-not $?) { throw 'dotnet test failed.' } + Move-Item ./src/pocof.Test/TestResults/*/coverage.cobertura.xml ./src/pocof.Test/TestResults/coverage.cobertura.xml -Force } Task Coverage -depends UnitTest { Remove-Item ./coverage/* - reportgenerator -reports:'./src/pocof.Test/TestResults/*/coverage.cobertura.xml' -targetdir:'coverage' -reporttypes:Html + reportgenerator -reports:'./src/pocof.Test/TestResults/coverage.cobertura.xml' -targetdir:'coverage' -reporttypes:Html } Task WorkflowTest { From 3c51dff88282d3ddd297232f9adfb2c40cd949be Mon Sep 17 00:00:00 2001 From: krymtkts Date: Thu, 4 Jan 2024 15:42:40 +0900 Subject: [PATCH 2/5] Add a step for Codecov to the test composite action. --- .github/actions/test/action.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml index 01c3b6d1..376b0084 100644 --- a/.github/actions/test/action.yml +++ b/.github/actions/test/action.yml @@ -16,3 +16,9 @@ runs: - name: Execute All Tests shell: pwsh run: Invoke-Psake -taskList TestAll + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + with: + file: ./src/pocof.Test/TestResults/coverage.cobertura.xml + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From 5d1542f5c42015687e24328924ef2b551185788d Mon Sep 17 00:00:00 2001 From: krymtkts Date: Thu, 4 Jan 2024 15:42:55 +0900 Subject: [PATCH 3/5] Fix a type in README.md. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f4bfc0b9..34e6f558 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Pocof [![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/pocof)](https://www.powershellgallery.com/packages/pocof) -![pull request workflow](https://github.com/krymtkts/pocof/actions/workflows/main.yml/badge.svg) +![Test main status](https://github.com/krymtkts/pocof/actions/workflows/main.yml/badge.svg) An interactive pipeline filtering Cmdlet for PowerShell written in F#. From 09aa5be2301b0b0e747f71422904a2b551f48739 Mon Sep 17 00:00:00 2001 From: krymtkts Date: Thu, 4 Jan 2024 16:08:05 +0900 Subject: [PATCH 4/5] Pass secrets to the composite action using inputs. --- .github/actions/test/action.yml | 7 ++++++- .github/workflows/main.yml | 2 ++ .github/workflows/pr.yml | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml index 376b0084..e75a80e3 100644 --- a/.github/actions/test/action.yml +++ b/.github/actions/test/action.yml @@ -1,6 +1,11 @@ name: Test description: Setup .NET, install PowerShell modules and run all tests. +inputs: + codecov_token: + description: "Codecov token" + required: true + runs: using: composite steps: @@ -21,4 +26,4 @@ runs: with: file: ./src/pocof.Test/TestResults/coverage.cobertura.xml env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + CODECOV_TOKEN: ${{ inputs.codecov_token }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index be56145f..06f2b91e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,3 +22,5 @@ jobs: uses: actions/checkout@v4 - name: Test uses: ./.github/actions/test + with: + codecov_token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d32c12f6..8fe46f9f 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -21,3 +21,5 @@ jobs: uses: actions/checkout@v4 - name: Test uses: ./.github/actions/test + with: + codecov_token: ${{ secrets.CODECOV_TOKEN }} From e0bcdfa369a0f8249f87755183e8fc54995e88eb Mon Sep 17 00:00:00 2001 From: krymtkts Date: Thu, 4 Jan 2024 16:14:06 +0900 Subject: [PATCH 5/5] Add a badge for Codecov. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 34e6f558..5548ac62 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/pocof)](https://www.powershellgallery.com/packages/pocof) ![Test main status](https://github.com/krymtkts/pocof/actions/workflows/main.yml/badge.svg) +[![codecov](https://codecov.io/gh/krymtkts/pocof/graph/badge.svg?token=7HA9NC8PHT)](https://codecov.io/gh/krymtkts/pocof) An interactive pipeline filtering Cmdlet for PowerShell written in F#.