|
| 1 | +name: Build Component [Main] |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + module-name: |
| 7 | + required: true |
| 8 | + type: string |
| 9 | + module-directory: |
| 10 | + required: false |
| 11 | + default: '.' |
| 12 | + type: string |
| 13 | + run-tests: |
| 14 | + required: false |
| 15 | + default: true |
| 16 | + type: boolean |
| 17 | + code-cov-prefix: |
| 18 | + default: 'unittests' |
| 19 | + required: false |
| 20 | + type: string |
| 21 | + os-list: |
| 22 | + default: '[ "windows-latest", "ubuntu-22.04" ]' |
| 23 | + required: false |
| 24 | + type: string |
| 25 | + tfm-list: |
| 26 | + default: '[ "net462", "net8.0", "net9.0" ]' |
| 27 | + required: false |
| 28 | + type: string |
| 29 | + test-case-filter: |
| 30 | + required: false |
| 31 | + type: string |
| 32 | + test-require-elevated: |
| 33 | + default: false |
| 34 | + required: false |
| 35 | + type: boolean |
| 36 | + |
| 37 | +jobs: |
| 38 | + component-build-test: |
| 39 | + |
| 40 | + strategy: |
| 41 | + fail-fast: false # ensures the entire test matrix is run, even if one permutation fails |
| 42 | + matrix: |
| 43 | + os: ${{ fromJSON(inputs.os-list) }} |
| 44 | + version: ${{ fromJSON(inputs.tfm-list) }} |
| 45 | + exclude: |
| 46 | + - os: ubuntu-22.04 |
| 47 | + version: net462 |
| 48 | + - os: macos-latest |
| 49 | + version: net462 |
| 50 | + |
| 51 | + runs-on: ${{ matrix.os }} |
| 52 | + |
| 53 | + defaults: |
| 54 | + run: |
| 55 | + shell: bash |
| 56 | + working-directory: '${{ inputs.module-directory }}' |
| 57 | + |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 60 | + with: |
| 61 | + # Note: By default GitHub only fetches 1 commit. MinVer needs to find |
| 62 | + # the version tag which is typically NOT on the first commit so we |
| 63 | + # retrieve them all. |
| 64 | + fetch-depth: 0 |
| 65 | + |
| 66 | + - name: Setup previous .NET runtimes |
| 67 | + uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1 |
| 68 | + with: |
| 69 | + dotnet-version: | |
| 70 | + 8.0.x |
| 71 | +
|
| 72 | + - name: Setup .NET |
| 73 | + uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1 |
| 74 | + |
| 75 | + - name: dotnet restore ${{ inputs.module-name }} |
| 76 | + run: dotnet restore -p:EnablePackageValidation=true |
| 77 | + |
| 78 | + - name: dotnet build ${{ inputs.module-name }} |
| 79 | + if: ${{ matrix.os != 'windows-latest' }} |
| 80 | + run: dotnet build --configuration Release --no-restore |
| 81 | + |
| 82 | + - name: Download build artifacts |
| 83 | + if: ${{ matrix.os == 'windows-latest' }} |
| 84 | + uses: actions/download-artifact@v4 |
| 85 | + with: |
| 86 | + name: build-output |
| 87 | + |
| 88 | + - name: dotnet test ${{ inputs.module-name }} |
| 89 | + if: ${{ inputs.run-tests }} |
| 90 | + run: > |
| 91 | + dotnet test |
| 92 | + --collect:"Code Coverage;Format=cobertura" |
| 93 | + --results-directory:TestResults |
| 94 | + --framework ${{ matrix.version }} |
| 95 | + --configuration Release |
| 96 | + --no-restore |
| 97 | + --no-build |
| 98 | + --logger:"console;verbosity=detailed" |
| 99 | + --logger:"GitHubActions;report-warnings=false" |
| 100 | + --logger:"junit;LogFilePath=../../TestResults/junit.xml" |
| 101 | + --filter "${{ inputs.test-case-filter }}" |
| 102 | + -- RunConfiguration.DisableAppDomain=true |
| 103 | +
|
| 104 | + - name: Upload code coverage ${{ inputs.code-cov-prefix }}-${{ inputs.module-name }} |
| 105 | + if: ${{ inputs.run-tests }} |
| 106 | + uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3 |
| 107 | + continue-on-error: true # Note: Don't fail for upload failures |
| 108 | + env: |
| 109 | + OS: ${{ matrix.os }} |
| 110 | + TFM: ${{ matrix.version }} |
| 111 | + FILTER: ${{ inputs.test-case-filter }} |
| 112 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 113 | + with: |
| 114 | + files: TestResults/**/*Cobertura.xml |
| 115 | + env_vars: OS,TFM,FILTER |
| 116 | + flags: ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }} |
| 117 | + name: Code Coverage for ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }} on [${{ matrix.os }}.${{ matrix.version }}] |
| 118 | + codecov_yml_path: .github/codecov.yml |
| 119 | + |
| 120 | + - name: Upload test results ${{ inputs.code-cov-prefix }}-${{ inputs.module-name }} |
| 121 | + if: ${{ inputs.run-tests }} |
| 122 | + uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1.1.1 |
| 123 | + with: |
| 124 | + files: TestResults/junit.xml |
| 125 | + env_vars: OS,TFM,FILTER |
| 126 | + flags: ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }} |
| 127 | + name: Test results for ${{ inputs.code-cov-prefix }}-${{ inputs.code-cov-name }} on [${{ matrix.os }}.${{ matrix.version }}] |
| 128 | + token: ${{ secrets.CODECOV_TOKEN }} |
0 commit comments