Skip to content

Commit d6dc937

Browse files
committed
ci: split verification into separate jobs
1 parent 3a5d802 commit d6dc937

1 file changed

Lines changed: 119 additions & 29 deletions

File tree

.github/workflows/verification.yml

Lines changed: 119 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,85 @@ on:
1818
workflow_dispatch:
1919

2020
concurrency:
21-
group: verification-${{ github.ref }}-1
21+
group: verification-${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }}
2222
cancel-in-progress: true
2323

2424
env:
2525
VSTEST_CONNECTION_TIMEOUT: 180
2626
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
2727
DOTNET_NOLOGO: true
28+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
29+
NUGET_DIRECTORY: ${{ github.workspace}}/nuget
30+
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1
31+
TERM: xterm
2832

2933
jobs:
30-
verify-bunit:
31-
name: 👌 Verify bUnit
34+
create-nuget:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v3
38+
with:
39+
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
40+
41+
# Install the .NET SDK indicated in the global.json file
42+
- name: ⚙️ Setup dotnet versions
43+
uses: actions/setup-dotnet@v3
44+
with:
45+
dotnet-version: |
46+
3.1.x
47+
5.0.x
48+
6.0.x
49+
7.0.x
50+
8.0.x
51+
52+
- name: ⚙️ Setup GIT versioning
53+
uses: dotnet/nbgv@v0.4.1
54+
with:
55+
setAllVars: true
56+
57+
- name: 🍥 Replace tokens in files
58+
uses: cschleiden/replace-tokens@v1
59+
with:
60+
files: '["docs/site/*.md", "docs/**/*.md", "docs/**/*.tmpl.partial", "*.csproj", "**/*.csproj"]'
61+
62+
# Create the NuGet package in the folder from the environment variable NuGetDirectory
63+
- run: |
64+
dotnet pack -c release --output ${{ env.NUGET_DIRECTORY }} -p:ContinuousIntegrationBuild=true
65+
dotnet pack src/bunit/ -c release --output ${{ env.NUGET_DIRECTORY }} -p:ContinuousIntegrationBuild=true
66+
dotnet pack src/bunit.template/ -c release --output ${{ env.NUGET_DIRECTORY }} -p:ContinuousIntegrationBuild=true
67+
68+
# Publish the NuGet package as an artifact, so they can be used in the following jobs
69+
- uses: actions/upload-artifact@v3
70+
with:
71+
name: nuget
72+
if-no-files-found: error
73+
retention-days: 7
74+
path: ${{ env.NUGET_DIRECTORY }}/*.nupkg
75+
76+
validate-nuget:
77+
runs-on: ubuntu-latest
78+
needs: [ create-nuget ]
79+
steps:
80+
- name: Setup .NET
81+
uses: actions/setup-dotnet@v3
82+
83+
- uses: actions/download-artifact@v3
84+
with:
85+
name: nuget
86+
path: ${{ env.NUGET_DIRECTORY }}
87+
88+
- name: Install nuget validator
89+
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
90+
91+
# Validate metadata and content of the NuGet package
92+
# https://www.nuget.org/packages/Meziantou.Framework.NuGetPackageValidation.Tool#readme-body-tab
93+
# If some rules are not applicable, you can disable them
94+
# using the --excluded-rules or --excluded-rule-ids option
95+
- name: Validate package
96+
shell: pwsh
97+
run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NUGET_DIRECTORY }}/*.nupkg") --excluded-rules IconMustBeSet
98+
99+
run-test:
32100
strategy:
33101
fail-fast: false
34102
matrix:
@@ -51,28 +119,9 @@ jobs:
51119
7.0.x
52120
8.0.x
53121
54-
- name: 🎨 Setup color
55-
if: matrix.os != 'windows-latest'
56-
run: |
57-
echo "DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION=1" >> $GITHUB_ENV
58-
echo "TERM=xterm" >> $GITHUB_ENV
59-
60-
- name: ⚙️ Setup GIT versioning
61-
uses: dotnet/nbgv@v0.4.1
62-
with:
63-
setAllVars: true
64-
65-
- name: 🍥 Replace tokens in files
66-
uses: cschleiden/replace-tokens@v1
67-
with:
68-
files: '["docs/site/*.md", "docs/**/*.md", "docs/**/*.tmpl.partial", "*.csproj", "**/*.csproj"]'
69-
70122
- name: 🧪 Run unit tests
71123
run: dotnet test -c release --blame --blame-crash --blame-hang
72124

73-
- name: 🧪 Run sample unit tests
74-
run: dotnet test -c release docs/samples/samples.sln
75-
76125
- name: 📛 Upload hang- and crash-dumps on test failure
77126
if: failure()
78127
uses: actions/upload-artifact@v3
@@ -83,15 +132,21 @@ jobs:
83132
**/*hangdump.dmp
84133
**/*crashdump.dmp
85134
86-
- name: 🗳️ Pack library
87-
run: |
88-
dotnet pack -c release --property:PackageOutputPath=${{ github.workspace }}/packages -p:ContinuousIntegrationBuild=true
89-
dotnet pack src/bunit/ -c release --property:PackageOutputPath=${{ github.workspace }}/packages -p:ContinuousIntegrationBuild=true
90-
dotnet pack src/bunit.template/ -c release --property:PackageOutputPath=${{ github.workspace }}/packages -p:ContinuousIntegrationBuild=true
135+
validate_template:
136+
runs-on: ubuntu-latest
137+
needs: [ create-nuget ]
138+
steps:
139+
- name: Setup .NET
140+
uses: actions/setup-dotnet@v3
141+
142+
- uses: actions/download-artifact@v3
143+
with:
144+
name: nuget
145+
path: ${{ env.NUGET_DIRECTORY }}
91146

92147
- name: ✳ Install bUnit template
93148
run: |
94-
dotnet new --install bunit.template::${NBGV_NuGetPackageVersion} --nuget-source ${{ github.workspace }}/packages
149+
dotnet new --install bunit.template::${NBGV_NuGetPackageVersion} --nuget-source ${{ env.NUGET_DIRECTORY }}
95150
96151
- name: ✔ Verify xUnit template
97152
run: |
@@ -114,6 +169,41 @@ jobs:
114169
dotnet restore ${{ github.workspace }}/TemplateTestMstest --source https://api.nuget.org/v3/index.json --source ${{ github.workspace }}/packages
115170
dotnet test ${{ github.workspace }}/TemplateTestMstest
116171
117-
- name: 📄 Building docs
172+
validate-docs:
173+
runs-on: ubuntu-latest
174+
175+
steps:
176+
- name: 🛒 Checkout repository
177+
uses: actions/checkout@v4
178+
with:
179+
fetch-depth: 0
180+
181+
- name: ⚙️ Setup dotnet versions
182+
uses: actions/setup-dotnet@v3
183+
with:
184+
dotnet-version: |
185+
3.1.x
186+
5.0.x
187+
6.0.x
188+
7.0.x
189+
8.0.x
190+
191+
- name: ⚙️ Setup GIT versioning
192+
uses: dotnet/nbgv@v0.4.1
193+
with:
194+
setAllVars: true
195+
196+
- name: 🍥 Replace tokens in files
197+
uses: cschleiden/replace-tokens@v1
198+
with:
199+
files: '["docs/site/*.md", "docs/**/*.md", "docs/**/*.tmpl.partial", "*.csproj", "**/*.csproj"]'
200+
201+
- name: 📄 Build bUnit
202+
run: dotnet build
203+
204+
- name: 🧪 Run sample unit tests
205+
run: dotnet test -c release docs/samples/samples.sln
206+
207+
- name: 📄 Build docs
118208
working-directory: ./docs/site
119209
run: dotnet run Site.csproj

0 commit comments

Comments
 (0)