|
1 | | -name: Continuous Integration |
| 1 | +name: CI |
| 2 | + |
2 | 3 | on: |
3 | | - push: |
4 | | - branches: [main] |
| 4 | + workflow_dispatch: |
5 | 5 | pull_request: |
6 | | - branches: [main] |
| 6 | + branches: [ main ] |
| 7 | + |
7 | 8 | jobs: |
8 | | - test: |
9 | | - name: Test |
| 9 | + unit-tests: |
| 10 | + name: "Unit tests" |
10 | 11 | strategy: |
11 | | - fail-fast: false |
12 | 12 | matrix: |
13 | | - os: [ubuntu-latest, windows-latest, macos-latest] |
| 13 | + os: [ ubuntu-latest, windows-latest, macos-latest ] |
14 | 14 | runs-on: ${{ matrix.os }} |
15 | 15 | steps: |
16 | | - - name: Checkout sources |
17 | | - uses: actions/checkout@v4 |
| 16 | + - uses: actions/checkout@v4 |
18 | 17 | with: |
19 | 18 | fetch-depth: 0 |
20 | | - - name: Setup .NET |
| 19 | + - name: Setup .NET SDKs |
21 | 20 | uses: actions/setup-dotnet@v4 |
22 | 21 | with: |
23 | 22 | dotnet-version: | |
24 | | - 6.0.x |
25 | | - 7.0.x |
26 | 23 | 8.0.x |
27 | | - 9.0.x |
28 | | - - name: Run tests |
29 | | - run: dotnet test --filter FullyQualifiedName\!~TestableIO.System.IO.Abstractions.Api.Tests --collect:"XPlat Code Coverage" --logger "GitHubActions" |
30 | | - - name: Upload coverage |
| 24 | + - name: Run unit tests (windows) |
| 25 | + if: matrix.os == 'windows-latest' |
| 26 | + run: ./build.ps1 CodeCoverage |
| 27 | + - name: Run unit tests (ubuntu|macos) |
| 28 | + if: matrix.os != 'windows-latest' |
| 29 | + run: ./build.sh CodeCoverage |
| 30 | + - name: Upload artifacts |
| 31 | + if: always() |
31 | 32 | uses: actions/upload-artifact@v4 |
32 | 33 | with: |
33 | | - name: Code coverage ${{ matrix.os }} |
34 | | - path: "**/coverage.cobertura.xml" |
35 | | - api-test: |
36 | | - name: API Test |
| 34 | + name: ${{ runner.os }}-artifacts |
| 35 | + path: | |
| 36 | + ./Artifacts/* |
| 37 | + ./TestResults/*.trx |
| 38 | + |
| 39 | + static-code-analysis: |
| 40 | + name: "Static code analysis" |
| 41 | + if: ${{ github.actor != 'dependabot[bot]' }} |
37 | 42 | runs-on: ubuntu-latest |
| 43 | + env: |
| 44 | + REPORTGENERATOR_LICENSE: ${{ secrets.REPORTGENERATOR_LICENSE }} |
| 45 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 46 | + DOTNET_NOLOGO: true |
38 | 47 | steps: |
39 | | - - name: Checkout sources |
40 | | - uses: actions/checkout@v4 |
| 48 | + - uses: actions/checkout@v4 |
41 | 49 | with: |
42 | 50 | fetch-depth: 0 |
43 | | - - name: Setup .NET |
| 51 | + - name: Setup .NET SDKs |
44 | 52 | uses: actions/setup-dotnet@v4 |
45 | 53 | with: |
46 | 54 | dotnet-version: | |
47 | | - 6.0.x |
48 | | - 7.0.x |
49 | 55 | 8.0.x |
50 | | - 9.0.x |
51 | | - - name: Build solution |
52 | | - run: dotnet build |
53 | | - - name: Run tests |
54 | | - run: dotnet test --filter FullyQualifiedName~TestableIO.System.IO.Abstractions.Api.Tests --logger "GitHubActions" |
55 | | - coverage: |
56 | | - name: Coverage |
57 | | - needs: [test, api-test] |
58 | | - runs-on: ubuntu-latest |
59 | | - steps: |
60 | | - - name: Checkout sources |
61 | | - uses: actions/checkout@v4 |
62 | | - - name: Setup .NET |
63 | | - uses: actions/setup-dotnet@v4 |
64 | | - - uses: actions/download-artifact@v4 |
65 | | - with: |
66 | | - name: Code coverage ubuntu-latest |
67 | | - path: coverage-ubuntu |
68 | | - - uses: actions/download-artifact@v4 |
69 | | - with: |
70 | | - name: Code coverage windows-latest |
71 | | - path: coverage-windows |
72 | | - - uses: actions/download-artifact@v4 |
73 | | - with: |
74 | | - name: Code coverage macos-latest |
75 | | - path: coverage-macos |
76 | | - - name: Generate coverage report |
77 | | - uses: danielpalme/[email protected] |
78 | | - with: |
79 | | - reports: "**/coverage.cobertura.xml" |
80 | | - targetdir: "coverage-report" |
81 | | - reporttypes: "Cobertura" |
82 | | - - name: Publish coverage report to Codacy |
83 | | - uses: codacy/codacy-coverage-reporter-action@master |
84 | | - if: github.repository == 'TestableIO/System.IO.Abstractions' && github.event_name == 'push' |
85 | | - with: |
86 | | - project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} |
87 | | - coverage-reports: coverage-report/Cobertura.xml |
88 | | - pack: |
89 | | - name: Pack |
90 | | - needs: [test, api-test] |
91 | | - runs-on: ubuntu-latest |
92 | | - steps: |
93 | | - - name: Checkout sources |
94 | | - uses: actions/checkout@v4 |
95 | | - with: |
96 | | - fetch-depth: 0 |
97 | | - - name: Setup .NET |
98 | | - uses: actions/setup-dotnet@v4 |
99 | | - - name: Create packages |
100 | | - run: dotnet pack --configuration Release --output ./packages |
101 | | - - name: Upload a Build Artifact |
102 | | - uses: actions/upload-artifact@v4 |
103 | | - with: |
104 | | - name: NuGet packages |
105 | | - path: packages/*.* |
106 | | - deploy: |
107 | | - name: Deploy |
108 | | - if: | |
109 | | - github.ref == 'refs/heads/main' && |
110 | | - github.event_name == 'push' && |
111 | | - ( |
112 | | - startsWith(github.event.head_commit.message, 'feat:') || |
113 | | - startsWith(github.event.head_commit.message, 'feat!:') || |
114 | | - startsWith(github.event.head_commit.message, 'fix:') || |
115 | | - startsWith(github.event.head_commit.message, 'fix!:') || |
116 | | - contains(github.event.head_commit.message, 'breaking change') |
117 | | - ) |
118 | | - needs: [pack] |
| 56 | + - name: Run sonarcloud analysis |
| 57 | + run: ./build.sh CodeAnalysis |
| 58 | + |
| 59 | + publish-test-results: |
| 60 | + name: "Publish Tests Results" |
| 61 | + needs: [ unit-tests ] |
119 | 62 | runs-on: ubuntu-latest |
| 63 | + permissions: |
| 64 | + checks: write |
| 65 | + pull-requests: write |
| 66 | + if: always() |
120 | 67 | steps: |
121 | | - - name: Checkout sources |
122 | | - uses: actions/checkout@v4 |
| 68 | + - name: Download Artifacts |
| 69 | + uses: actions/download-artifact@v4 |
123 | 70 | with: |
124 | | - fetch-depth: 0 |
125 | | - - name: Setup .NET |
126 | | - uses: actions/setup-dotnet@v4 |
127 | | - - uses: actions/download-artifact@v4 |
128 | | - with: |
129 | | - name: NuGet packages |
130 | | - path: packages |
131 | | - - name: Push packages |
132 | | - run: dotnet nuget push "packages/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate |
133 | | - |
134 | | - id: nbgv |
135 | | - - name: Create GitHub release |
136 | | - uses: softprops/action-gh-release@v2 |
| 71 | + path: artifacts |
| 72 | + - name: Publish Test Results |
| 73 | + uses: EnricoMi/publish-unit-test-result-action@v2 |
137 | 74 | with: |
138 | | - name: v${{ steps.nbgv.outputs.SemVer2 }} |
139 | | - tag_name: v${{ steps.nbgv.outputs.SemVer2 }} |
140 | | - token: ${{ secrets.GITHUB_TOKEN }} |
141 | | - generate_release_notes: true |
142 | | - - name: Wait for GitHub release to be available |
143 | | - run: sleep 30s |
144 | | - shell: bash |
145 | | - - name: Comment on relevant PRs and issues |
146 | | - |
147 | | - with: |
148 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
149 | | - comment-template: | |
150 | | - This is addressed in release {release_link}. |
151 | | - label-template: | |
152 | | - state: released |
153 | | -
|
| 75 | + comment_mode: always |
| 76 | + files: "artifacts/**/**/*.trx" |
0 commit comments