|
| 1 | +name: CI Build |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - 'main' |
| 8 | + paths-ignore: |
| 9 | + - 'docs/**' |
| 10 | + - '.github/**' |
| 11 | + pull_request: |
| 12 | + branches: |
| 13 | + - 'main' |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + issues: read |
| 18 | + pull-requests: write |
| 19 | + checks: write |
| 20 | + |
| 21 | +env: |
| 22 | + DOTNET_NOLOGO: true |
| 23 | + DOTNET_GENERATE_ASPNET_CERTIFICATE: false |
| 24 | + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + build: |
| 28 | + name: Build and Test |
| 29 | + runs-on: ubuntu-24.04 |
| 30 | + steps: |
| 31 | + - name: 'Harden Runner' |
| 32 | + uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2 |
| 33 | + with: |
| 34 | + egress-policy: audit |
| 35 | + |
| 36 | + - name: 'Checkout' |
| 37 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 38 | + with: |
| 39 | + fetch-depth: 0 # avoid shallow clone so nbgv can do its work. |
| 40 | + |
| 41 | + - name: 'Setup .NET SDK' |
| 42 | + uses: actions/setup-dotnet@baa11fbfe1d6520db94683bd5c7a3818018e4309 # v5.1.0 |
| 43 | + with: |
| 44 | + dotnet-version: 10.0.x |
| 45 | + |
| 46 | + - name: 'Restore external dependencies' |
| 47 | + run: dotnet restore |
| 48 | + |
| 49 | + - name: 'Build' |
| 50 | + id: build |
| 51 | + run: dotnet build --configuration Debug --no-restore |
| 52 | + |
| 53 | + - name: Upload Build Artifacts |
| 54 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 55 | + with: |
| 56 | + name: build-artifacts |
| 57 | + path: | |
| 58 | + src/**/BCrypt.*.nupkg |
| 59 | + src/**/BCrypt.*.dll |
| 60 | + src/**/BCrypt.*.deps.json |
| 61 | + src/**/BCrypt.*.xml |
| 62 | + retention-days: 5 |
| 63 | + |
| 64 | + - name: 'Test' |
| 65 | + id: test |
| 66 | + run: dotnet test --restore --collect:"XPlat Code Coverage" --logger junit --configuration Debug |
| 67 | + |
| 68 | + - name: 'Create test summary' |
| 69 | + uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4 |
| 70 | + with: |
| 71 | + paths: tests/UnitTests/**/TestResults.xml |
| 72 | + show: "fail, skip" |
| 73 | + if: always() |
| 74 | + |
| 75 | + - name: 'Generate Coverage Reports' |
| 76 | + uses: danielpalme/ReportGenerator-GitHub-Action@c4c5175a441c6603ec614f5084386dabe0e2295b # v5.4.12 |
| 77 | + with: |
| 78 | + reports: "tests/**/coverage.cobertura.xml" |
| 79 | + targetdir: "${{ github.workspace }}" |
| 80 | + reporttypes: "Cobertura" |
| 81 | + verbosity: "Info" |
| 82 | + title: "Code Coverage" |
| 83 | + tag: "${{ github.run_number }}_${{ github.run_id }}" |
| 84 | + toolpath: "reportgeneratortool" |
| 85 | + license: ${{ secrets.REPORT_GENERATOR_LICENSE }} |
| 86 | + |
| 87 | + - name: Publish Code Coverage Report |
| 88 | + uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0 |
| 89 | + with: |
| 90 | + filename: "Cobertura.xml" |
| 91 | + badge: true |
| 92 | + fail_below_min: false # just informative for now |
| 93 | + format: markdown |
| 94 | + hide_branch_rate: false |
| 95 | + hide_complexity: false |
| 96 | + indicators: true |
| 97 | + output: both |
| 98 | + thresholds: "10 30" |
| 99 | + |
| 100 | + - name: Upload Code Coverage Results |
| 101 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 102 | + with: |
| 103 | + name: coverage-results |
| 104 | + path: | |
| 105 | + ${{ github.workspace }}/Cobertura.xml |
| 106 | + ${{ github.workspace }}/code-coverage-results.md |
| 107 | + retention-days: 5 |
| 108 | + |
| 109 | + - name: Publish Test Results |
| 110 | + uses: EnricoMi/publish-unit-test-result-action@afb2984f4d89672b2f9d9c13ae23d53779671984 # v2.19.0 |
| 111 | + if: always() |
| 112 | + with: |
| 113 | + files: "tests/**/TestResults.xml" |
| 114 | + |
| 115 | + - name: Upload Test Artifacts |
| 116 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 117 | + with: |
| 118 | + name: test-results |
| 119 | + path: "tests/**/TestResults.xml" |
| 120 | + retention-days: 5 |
0 commit comments