Skip to content

Commit 663fa8f

Browse files
committed
👷 update GitHub Actions workflows for improved structure and efficiency
1 parent 988217b commit 663fa8f

File tree

2 files changed

+15
-48
lines changed

2 files changed

+15
-48
lines changed

.github/workflows/publish.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,22 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- uses: actions/checkout@v4
24-
2524
- name: Get name, version, and group from csproj files
2625
id: get_version
2726
run: |
2827
set -e
2928
VERSION=$(awk -F'[<>]' '/^[[:space:]]*<Version>/ {print $3}' QsNet/QsNet.csproj)
3029
echo "VERSION=$VERSION" >> $GITHUB_ENV
31-
3230
- name: Setup .NET
3331
uses: actions/setup-dotnet@v4
3432
with:
3533
dotnet-version: '8.0.x'
36-
3734
- name: Restore
3835
run: dotnet restore
39-
4036
- name: Build & Pack
4137
run: dotnet pack QsNet/QsNet.csproj -c Release -o ./artifacts
42-
4338
- name: Push to NuGet
4439
run: dotnet nuget push ./artifacts/QsNet.$VERSION.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
45-
4640
- name: Upload .nupkg artefact
4741
uses: actions/upload-artifact@v4
4842
with:
@@ -91,4 +85,12 @@ jobs:
9185
if: ${{ always() }}
9286
run: |
9387
rm -rf $CHANGELOG_PATH
94-
rm -rf ./artifacts/*.nupkg
88+
rm -rf ./artifacts/*.nupkg
89+
docs:
90+
uses: ./.github/workflows/docs.yml
91+
secrets: inherit
92+
needs:
93+
- test
94+
- publish
95+
permissions:
96+
contents: write

.github/workflows/test.yml

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,39 @@ jobs:
2525

2626
steps:
2727
- uses: actions/checkout@v4
28-
2928
- name: Setup .NET 8 SDK
3029
uses: actions/setup-dotnet@v4
3130
with:
3231
dotnet-version: '8.0.x'
33-
3432
- name: Cache NuGet
3533
uses: actions/cache@v4
3634
with:
3735
path: ~/.nuget/packages
3836
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.[cC][sS]proj', '**/*.props', '**/*.targets') }}
3937
restore-keys: nuget-${{ runner.os }}-
40-
4138
- name: Restore
4239
run: dotnet restore
43-
4440
- name: dotnet format (verify)
4541
run: dotnet format --verify-no-changes --verbosity minimal
46-
4742
- name: Build (warnings -> errors)
4843
run: dotnet build --configuration Release -p:TreatWarningsAsErrors=true --no-restore
49-
5044
test:
5145
name: Test ${{ matrix.dotnet }} on ${{ matrix.os }}
5246
needs: lint
5347
runs-on: ${{ matrix.os }}
54-
5548
strategy:
5649
fail-fast: false
5750
matrix:
5851
os: [ ubuntu-latest ]
59-
dotnet: [ '8.0.x', '9.0.x' ]
60-
52+
dotnet:
53+
- '8.0.x'
54+
- '9.0.x'
6155
steps:
6256
- uses: actions/checkout@v4
63-
6457
- name: Setup .NET SDK
6558
uses: actions/setup-dotnet@v4
6659
with:
6760
dotnet-version: ${{ matrix.dotnet }}
68-
6961
- name: Cache NuGet
7062
uses: actions/cache@v4
7163
with:
@@ -74,20 +66,12 @@ jobs:
7466
restore-keys: |
7567
nuget-${{ runner.os }}-${{ matrix.dotnet }}-
7668
nuget-${{ runner.os }}-
77-
7869
- name: Restore
7970
run: dotnet restore
80-
8171
- name: Build
8272
run: dotnet build --configuration Release --no-restore
83-
8473
- name: Test + Coverage
85-
run: |
86-
dotnet test --configuration Release --no-build \
87-
--verbosity normal \
88-
--logger "trx;LogFileName=test-results.trx" \
89-
--collect "XPlat Code Coverage"
90-
74+
run: dotnet test --configuration Release --no-build --verbosity normal --logger "trx;LogFileName=test-results.trx" --collect "XPlat Code Coverage"
9175
- name: Upload TRX
9276
uses: actions/upload-artifact@v4
9377
if: always()
@@ -96,7 +80,6 @@ jobs:
9680
path: '**/*.trx'
9781
overwrite: true
9882
retention-days: 7
99-
10083
- name: Upload raw coverage
10184
uses: actions/upload-artifact@v4
10285
with:
@@ -105,43 +88,26 @@ jobs:
10588
if-no-files-found: error
10689
overwrite: true
10790
retention-days: 7
108-
10991
coverage:
11092
name: Coverage (merged)
11193
runs-on: ubuntu-latest
11294
needs: test
113-
11495
steps:
11596
- uses: actions/checkout@v4
116-
11797
- name: Setup .NET 8 SDK
11898
uses: actions/setup-dotnet@v4
11999
with:
120100
dotnet-version: '8.0.x'
121-
122101
- name: Restore
123102
run: dotnet restore
124-
125103
- name: Build
126104
run: dotnet build --configuration Release --no-restore
127-
128105
- name: Test w/ coverage (8.0—single run)
129-
run: |
130-
dotnet test --configuration Release --no-build \
131-
--collect "XPlat Code Coverage" \
132-
--results-directory coverage \
133-
--settings coverlet.runsettings
134-
106+
run: dotnet test --configuration Release --no-build --collect "XPlat Code Coverage" --results-directory coverage --settings coverlet.runsettings
135107
- name: Install ReportGenerator
136108
run: dotnet tool install -g dotnet-reportgenerator-globaltool
137-
138109
- name: Generate consolidated report
139-
run: |
140-
reportgenerator \
141-
-reports:"**/coverage.cobertura.xml" \
142-
-targetdir:"coverage/report" \
143-
-reporttypes:"Html;Cobertura;JsonSummary"
144-
110+
run: reportgenerator -reports:"**/coverage.cobertura.xml" -targetdir:"coverage/report" -reporttypes:"Html;Cobertura;JsonSummary"
145111
- name: Upload to Codecov
146112
uses: codecov/codecov-action@v5
147113
env:
@@ -151,7 +117,6 @@ jobs:
151117
flags: unittests
152118
name: codecov-umbrella
153119
fail_ci_if_error: false
154-
155120
- name: Upload coverage report artifact
156121
uses: actions/upload-artifact@v4
157122
with:

0 commit comments

Comments
 (0)