-
-
Notifications
You must be signed in to change notification settings - Fork 2
214 lines (180 loc) · 7.82 KB
/
dotnet.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
name: CI
permissions:
contents: read
pull-requests: write # required if create-pr-comment: true
checks: write # required if create-status-check: true
packages: write
on:
push:
branches: [ "master", "development" ]
pull_request:
branches: [ "master", "development" ]
release:
types:
- published
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NuGetDirectory: ${{github.workspace}}/nupkgs
jobs:
integration-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Compose
run: |
docker compose -f docker-compose.yml -f docker-compose.override.yml config
docker compose pull
docker compose build
- name: Install ReportGenerator
run: dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Run tests
run: docker compose up --exit-code-from tests tests localstack
- name: Run tests
run: docker compose up --exit-code-from unittests unittests
- name: Upload TRX test results
uses: actions/upload-artifact@v4
if: always() # This ensures it runs even if the previous steps fail
with:
name: trx-test-results
path: ./test-results/*.trx
- name: Merge Coverage Reports
run: reportgenerator "-reports:${{ github.workspace }}/test-results/coverage_*.cobertura.xml" "-targetdir:${{ github.workspace }}/coverage-results/" "-reporttypes:Cobertura"
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
if: always() # This ensures it runs even if the previous steps fail
with:
name: coverage-results
path: ./coverage-results/*.xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
directory: ./coverage-results
files: '*.xml'
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}
- name: Clean up
run: docker compose down
- name: Parse Trx files
uses: NasAmin/trx-parser@v0.5.0
id: trx-parser
with:
TRX_PATH: ${{ github.workspace }}/test-results #This should be the path to your TRX files
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Process trx reports
id: process-trx
# You may also reference just the major or major.minor version
uses: im-open/process-dotnet-test-results@v3.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
base-directory: './test-results'
create-status-check: true
create-pr-comment: true
update-comment-if-one-exists: true
ignore-test-failures: true
timezone: 'america/denver'
comment-identifier: 'bff-tests'
# Optional
- name: Annotate Test Outcome
if: steps.process-trx.outputs.test-results-truncated == 'true'
run: cat ${{ steps.process-trx.outputs.test-results-file-path }} > $GITHUB_STEP_SUMMARY
# Optional
- name: Upload Outcome as artifact if character limit reached
if: steps.process-trx.outputs.test-results-truncated == 'true'
uses: actions/upload-artifact@v4
with:
name: Cypress-Results
path: |
${{ steps.process-trx.outputs.test-results-file-path }}
retention-days: 90
create_nuget:
needs: integration-tests
runs-on: ubuntu-latest
if: (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/development') && success() || github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'prereleased')
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Build and Pack
run: |
# Extracting version number from .csproj file
AWS_SDK_VERSION=$(grep -oP '(?<=<PackageReference Include="AWSSDK.DynamoDBv2" Version=")[^"]*' src/DynamoDBv2.Transactions.csproj)
echo "Extracted AWSSDK.DynamoDBv2 version: $AWS_SDK_VERSION"
# Splitting the version number into components
IFS='.' read -r -a VERSION_PARTS <<< "$AWS_SDK_VERSION"
# Combine the third and fourth parts if the fourth part exists
if [ ${#VERSION_PARTS[@]} -ge 4 ]; then
THIRD_FOURTH="${VERSION_PARTS[2]}${VERSION_PARTS[3]}"
else
THIRD_FOURTH="${VERSION_PARTS[2]}"
fi
# Construct the final version
FINAL_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$THIRD_FOURTH.$GITHUB_RUN_NUMBER"
# Append suffix if on development branch
#if [ "${{ github.ref }}" == "refs/heads/master" ]; then
if [ "${{ github.event_name }}" == "release" ]; then
SUFFIX=""
else
SUFFIX="-beta"
fi
FINAL_VERSION="$FINAL_VERSION$SUFFIX"
echo "Final package version: $FINAL_VERSION"
# Build and pack with the calculated version
dotnet build src/DynamoDBv2.Transactions.csproj --configuration Release
dotnet pack src/DynamoDBv2.Transactions.csproj --configuration Release --output ${{ env.NuGetDirectory }} /p:Version=$FINAL_VERSION
- name: Create NuGet Artifact
uses: actions/upload-artifact@v3
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDirectory }}/*.nupkg
validate_nuget:
runs-on: ubuntu-latest
needs: [ create_nuget, integration-tests ]
steps:
# Install the .NET SDK indicated in the global.json file
- name: Setup .NET
uses: actions/setup-dotnet@v4
- uses: actions/download-artifact@v4.1.7
with:
name: nuget
path: ${{ env.NuGetDirectory }}
- name: Install nuget validator
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
- name: Validate package
run: meziantou.validate-nuget-package $(ls "${{ env.NuGetDirectory }}"/*.nupkg) --excluded-rules Symbols
deploy:
# Publish only when creating a GitHub Release
# https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository
# You can update this logic if you want to manage releases differently
if: github.event_name == 'release'
runs-on: ubuntu-latest
needs: [ validate_nuget, integration-tests ]
steps:
# Download the NuGet package created in the previous job
- uses: actions/download-artifact@v4.1.7
with:
name: nuget
path: ${{ env.NuGetDirectory }}
# Install the .NET SDK indicated in the global.json file
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
- name: Publish NuGet package
run: |
for file in $(find ${NuGetDirectory} -name "*.nupkg" -or -name "*.snupkg")
do
dotnet nuget push "$file" --api-key "${{secrets.NUGET_PUSH_KEY}}" --source https://api.nuget.org/v3/index.json --skip-duplicate
done
- name: Github Prep NuGet.config
run: dotnet nuget add source --username ${{ github.repository_owner }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
- name: Publish to GitHub Packages
run: |
for file in $(find ${{ env.NuGetDirectory }} -name "*.nupkg" -or -name "*.snupkg")
do
dotnet nuget push "$file" --api-key ${{ secrets.GITHUB_TOKEN }} --source "https://nuget.pkg.github.com/${{ github.repository_owner }}/" --skip-duplicate
done