|
| 1 | +name: next-gen-ci |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ out-of-process-collection ] |
| 6 | + paths: |
| 7 | + - 'next-gen/**' |
| 8 | + pull_request: |
| 9 | + branches: [ out-of-process-collection ] |
| 10 | + paths: |
| 11 | + - 'next-gen/**' |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + force_run: |
| 15 | + description: 'Force run even if no next-gen changes' |
| 16 | + required: false |
| 17 | + default: 'false' |
| 18 | + |
| 19 | +env: |
| 20 | + NUGET_PACKAGES: ${{ github.workspace }}/packages |
| 21 | + DOTNET_CLI_TELEMETRY_OPTOUT: 1 |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: read |
| 25 | + |
| 26 | +jobs: |
| 27 | + build-and-test: |
| 28 | + strategy: |
| 29 | + fail-fast: false |
| 30 | + matrix: |
| 31 | + include: |
| 32 | + - machine: windows-2022 |
| 33 | + dotnet-version: "9.0.105" |
| 34 | + - machine: ubuntu-22.04 |
| 35 | + dotnet-version: "9.0.105" |
| 36 | + - machine: macos-13 |
| 37 | + dotnet-version: "9.0.105" |
| 38 | + - machine: ubuntu-22.04-arm |
| 39 | + dotnet-version: "9.0.105" |
| 40 | + runs-on: ${{ matrix.machine }} |
| 41 | + defaults: |
| 42 | + run: |
| 43 | + working-directory: next-gen |
| 44 | + steps: |
| 45 | + |
| 46 | + - name: Checkout |
| 47 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag: v4.2.2 |
| 48 | + with: |
| 49 | + fetch-depth: 0 # fetching all, needed to correctly calculate version |
| 50 | + |
| 51 | + - name: Setup .NET |
| 52 | + uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # tag: v4.3.1 |
| 53 | + with: |
| 54 | + dotnet-version: ${{ matrix.dotnet-version }} |
| 55 | + global-json-file: next-gen/global.json |
| 56 | + |
| 57 | + - name: Check for NuGet packages cache |
| 58 | + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # tag: v4.2.3 |
| 59 | + id: nuget-cache |
| 60 | + with: |
| 61 | + key: next-gen-${{ hashFiles('next-gen/**/Directory.packages.props', 'next-gen/**/*.csproj') }} |
| 62 | + path: ${{ env.NUGET_PACKAGES }} |
| 63 | + |
| 64 | + - name: Restore NuGet packages |
| 65 | + if: ${{ steps.nuget-cache.outputs.cache-hit != 'true' }} |
| 66 | + run: dotnet restore next-gen.sln |
| 67 | + |
| 68 | + - name: Build solution |
| 69 | + run: dotnet build next-gen.sln --configuration Release --no-restore |
| 70 | + |
| 71 | + - name: Run tests |
| 72 | + run: dotnet test next-gen.sln --configuration Release --no-build --verbosity normal --logger trx --results-directory test-results |
| 73 | + |
| 74 | + - name: Upload test results |
| 75 | + if: always() |
| 76 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # tag: v4.6.2 |
| 77 | + with: |
| 78 | + name: test-results-${{ matrix.machine }} |
| 79 | + path: next-gen/test-results/ |
| 80 | + |
| 81 | + code-quality: |
| 82 | + runs-on: ubuntu-22.04 |
| 83 | + defaults: |
| 84 | + run: |
| 85 | + working-directory: next-gen |
| 86 | + steps: |
| 87 | + |
| 88 | + - name: Checkout |
| 89 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag: v4.2.2 |
| 90 | + with: |
| 91 | + fetch-depth: 0 # fetching all, needed to correctly calculate version |
| 92 | + |
| 93 | + - name: Setup .NET |
| 94 | + uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # tag: v4.3.1 |
| 95 | + with: |
| 96 | + dotnet-version: "9.0.105" |
| 97 | + global-json-file: next-gen/global.json |
| 98 | + |
| 99 | + - name: Check for NuGet packages cache |
| 100 | + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # tag: v4.2.3 |
| 101 | + id: nuget-cache |
| 102 | + with: |
| 103 | + key: next-gen-${{ hashFiles('next-gen/**/Directory.packages.props', 'next-gen/**/*.csproj') }} |
| 104 | + path: ${{ env.NUGET_PACKAGES }} |
| 105 | + |
| 106 | + - name: Restore NuGet packages |
| 107 | + if: ${{ steps.nuget-cache.outputs.cache-hit != 'true' }} |
| 108 | + run: dotnet restore next-gen.sln |
| 109 | + |
| 110 | + - name: Check formatting |
| 111 | + run: dotnet format next-gen.sln --verify-no-changes --verbosity diagnostic |
| 112 | + |
| 113 | + - name: Build solution with warnings as errors |
| 114 | + run: dotnet build next-gen.sln --configuration Release --no-restore /warnaserror |
| 115 | + |
| 116 | + security-scan: |
| 117 | + runs-on: ubuntu-22.04 |
| 118 | + defaults: |
| 119 | + run: |
| 120 | + working-directory: next-gen |
| 121 | + steps: |
| 122 | + |
| 123 | + - name: Checkout |
| 124 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag: v4.2.2 |
| 125 | + with: |
| 126 | + fetch-depth: 0 # fetching all, needed to correctly calculate version |
| 127 | + |
| 128 | + - name: Setup .NET |
| 129 | + uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # tag: v4.3.1 |
| 130 | + with: |
| 131 | + dotnet-version: "9.0.105" |
| 132 | + global-json-file: next-gen/global.json |
| 133 | + |
| 134 | + - name: Restore NuGet packages |
| 135 | + run: dotnet restore next-gen.sln |
| 136 | + |
| 137 | + - name: Run security scan |
| 138 | + run: | |
| 139 | + dotnet list next-gen.sln package --vulnerable --include-transitive --format json > vulnerability-report.json || true |
| 140 | + if [ -s vulnerability-report.json ] && [ "$(cat vulnerability-report.json)" != "{}" ]; then |
| 141 | + echo "Vulnerabilities found:" |
| 142 | + cat vulnerability-report.json |
| 143 | + exit 1 |
| 144 | + fi |
| 145 | +
|
| 146 | + - name: Upload vulnerability report |
| 147 | + if: always() |
| 148 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # tag: v4.6.2 |
| 149 | + with: |
| 150 | + name: vulnerability-report |
| 151 | + path: next-gen/vulnerability-report.json |
| 152 | + |
| 153 | + summary: |
| 154 | + runs-on: ubuntu-22.04 |
| 155 | + needs: |
| 156 | + - build-and-test |
| 157 | + - code-quality |
| 158 | + - security-scan |
| 159 | + if: always() |
| 160 | + steps: |
| 161 | + |
| 162 | + - name: Check if all jobs passed |
| 163 | + run: | |
| 164 | + echo "Build and test result: ${{ needs.build-and-test.result }}" |
| 165 | + echo "Code quality result: ${{ needs.code-quality.result }}" |
| 166 | + echo "Security scan result: ${{ needs.security-scan.result }}" |
| 167 | + |
| 168 | + if [ "${{ needs.build-and-test.result }}" != "success" ]; then |
| 169 | + echo "Build and test failed" |
| 170 | + exit 1 |
| 171 | + fi |
| 172 | + |
| 173 | + if [ "${{ needs.code-quality.result }}" != "success" ]; then |
| 174 | + echo "Code quality checks failed" |
| 175 | + exit 1 |
| 176 | + fi |
| 177 | + |
| 178 | + if [ "${{ needs.security-scan.result }}" != "success" ]; then |
| 179 | + echo "Security scan failed" |
| 180 | + exit 1 |
| 181 | + fi |
| 182 | + |
| 183 | + echo "All checks passed successfully!" |
0 commit comments