diff --git a/.github/actions/test-module/action.yml b/.github/actions/test-module/action.yml index 80080ae0..438a3983 100644 --- a/.github/actions/test-module/action.yml +++ b/.github/actions/test-module/action.yml @@ -1,12 +1,6 @@ name: Test module description: Run tests against specified module inputs: - module-name: - description: Name of the module - required: true - module-namespace: - description: Name of the module namespace - required: true codecov-token: description: Value of Codecov token used to upload code coverage results required: true @@ -14,6 +8,15 @@ inputs: description: Path to code coverage directory where results are being stored required: false default: ${{ github.workspace }}\src\opencover + module-name: + description: Name of the module + required: true + module-namespace: + description: Name of the module namespace + required: true + target-framework: + description: Framework version to run tests against + required: true outputs: file-path: description: Signing key file path @@ -21,27 +24,19 @@ outputs: runs: using: composite steps: - - name: ๐Ÿงช test ${{ matrix.package_module }} in net7.0 & collect coverage - id: module-code-coverage + - name: ๐Ÿงช test ${{ inputs.module-name }} in ${{ inputs.target-framework }} & collect coverage + id: test-and-collect-code-coverage run: | - $path = [IO.Path]::Combine("$env:CoverageDirectory","$env:ModuleFullName.xml") - dotnet test ./src/$env:ModuleFullName.Tests/ --no-build -f $env:TargetFramework -e:CollectCoverage=true -e:CoverletOutputFormat=opencover -e:Exclude="[xunit*]*" -e:CoverletOutput=$path - "FILE=$env:ModuleFullName.$env:TargetFramework.xml" >> $env:GITHUB_OUTPUT + $path = [IO.Path]::Combine("${{ inputs.coverage-directory }}","$env:ModuleFullName.xml") + dotnet test ./src/$env:ModuleFullName.Tests/ --no-build -f ${{ inputs.target-framework }} -e:CollectCoverage=true -e:CoverletOutputFormat=opencover -e:Exclude="[xunit*]*" -e:CoverletOutput=$path + "FILE=$env:ModuleFullName.${{ inputs.target-framework }}.xml" >> $env:GITHUB_OUTPUT shell: pwsh env: - CoverageDirectory: ${{ inputs.coverage-directory }} ModuleFullName: ${{ inputs.module-namespace }}.${{ inputs.module-name }} - TargetFramework: net7.0 - - name: ๐Ÿงช test ${{ matrix.package_module }} in net472 - run: dotnet test ./src/${{ inputs.module-namespace }}.${{ inputs.module-name }}.Tests/ --no-build -f net472 - shell: pwsh - - name: ๐Ÿงช test ${{ matrix.package_module }} in net48 - run: dotnet test ./src/${{ inputs.module-namespace }}.${{ inputs.module-name }}.Tests/ --no-build -f net48 - shell: pwsh - name: ๐Ÿ“ค upload coverage reports to Codecov uses: codecov/codecov-action@v3 with: token: ${{ inputs.codecov-token }} - files: ${{ steps.module-code-coverage.outputs.FILE }} + files: ${{ steps.test-and-collect-code-coverage.outputs.FILE }} directory: ${{ inputs.coverage-directory }} flags: unittests diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index b81177d9..7b08feee 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -80,7 +80,7 @@ jobs: uses: gittools/actions/gitversion/execute@v0 with: useConfigFile: true - build: + build-and-test: needs: init runs-on: windows-latest # We are using windows instead of ubuntu becaus it provides support for net472 & net48. timeout-minutes: 15 @@ -88,7 +88,11 @@ jobs: Version: ${{ needs.init.outputs.Version }} strategy: matrix: - package_module: ${{ fromJSON(needs.init.outputs.matrix) }} + package-module: ${{ fromJSON(needs.init.outputs.matrix) }} + target-framework: [net7.0, net472, net48] + include: + - target-framework: net7.0 + collect-code-coverage: true if: ${{ needs.init.outputs.matrix != '' }} steps: - name: ๐Ÿ“ฅ checkout @@ -101,26 +105,51 @@ jobs: with: signing-key-value: ${{ secrets.SIGNING_KEY }} - name: ๐Ÿ—๏ธ build - run: dotnet build ./src/${{ env.Namespace }}.${{ matrix.package_module }}.sln + run: dotnet build ./src/${{ env.Namespace }}.${{ matrix.package-module }}.sln -f ${{ matrix.target-framework }} env: CI: true StrongNameKey: ${{ secrets.SIGNING_KEY }} StrongNameKeyPath: ${{ steps.signing-key.outputs.file-path }} + - name: ๐Ÿงช test ${{ matrix.package-module }} in net472 + if: ${{ matrix.collect-code-coverage != true }} + run: dotnet test ./src/${{ env.Namespace }}.${{ matrix.package-module }}.Tests/ --no-build -f ${{ matrix.target-framework }} - name: ๐Ÿงช test + if: ${{ matrix.collect-code-coverage == true }} uses: ./.github/actions/test-module with: - module-name: ${{ matrix.package_module }} - module-namespace: ${{ env.Namespace }} codecov-token: ${{ secrets.CODECOV_TOKEN }} + module-name: ${{ matrix.package-module }} + module-namespace: ${{ env.Namespace }} + target-framework: ${{ matrix.target-framework }} + pack: + needs: [init, build-and-test] + runs-on: windows-latest # We are using windows instead of ubuntu becaus it provides support for net472 & net48. + timeout-minutes: 15 + env: + Version: ${{ needs.init.outputs.Version }} + strategy: + matrix: + package-module: ${{ fromJSON(needs.init.outputs.matrix) }} + if: ${{ needs.init.outputs.matrix != '' }} + steps: + - name: ๐Ÿ“ฅ checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: ๐Ÿ–Š๏ธ materialize signing key + id: signing-key + uses: ./.github/actions/materialize-signing-key + with: + signing-key-value: ${{ secrets.SIGNING_KEY }} - name: ๐Ÿ“ฆ pack - if: ${{ startsWith(matrix.package_module, 'Auto' ) }} - run: dotnet pack ./src/${{ env.Namespace }}.${{ matrix.package_module }} --no-restore + if: ${{ startsWith(matrix.package-module, 'Auto' ) }} + run: dotnet pack ./src/${{ env.Namespace }}.${{ matrix.package-module }} --no-restore env: CI: true StrongNameKey: ${{ secrets.SIGNING_KEY }} StrongNameKeyPath: ${{ steps.signing-key.outputs.file-path }} - name: ๐Ÿ”ผ upload packages - if: ${{ startsWith(matrix.package_module, 'Auto' ) }} + if: ${{ startsWith(matrix.package-module, 'Auto' ) }} uses: actions/upload-artifact@v3 with: name: packages @@ -130,7 +159,7 @@ jobs: publish: runs-on: ubuntu-latest timeout-minutes: 15 - needs: [build] + needs: [pack] environment: ${{ inputs.environment }} if: ${{ inputs.environment != null }} steps: