-
Notifications
You must be signed in to change notification settings - Fork 30
189 lines (160 loc) · 5.77 KB
/
application.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
name: Application - Build and Deploy
on:
push:
branches:
- main
paths:
- "application/**"
- ".github/workflows/application.yml"
- "!**.md"
pull_request:
paths:
- "application/**"
- ".github/workflows/application.yml"
- "!**.md"
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
version: ${{ steps.generate_version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Generate version
id: generate_version
run: |
VERSION=$(date +"%Y.%m.%d").$GITHUB_RUN_NUMBER
echo "Generated version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Install Bun
uses: oven-sh/setup-bun@v1
- name: Install Node modules
working-directory: application/account-management/WebApp
run: bun install --frozen-lockfile
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore .NET tools
working-directory: application
run: |
dotnet tool restore &&
dotnet workload install aspire
- name: Restore .NET dependencies
working-directory: application
run: dotnet restore
- name: Build
run: dotnet build application/PlatformPlatform.sln --no-restore --configuration Release /p:Version=${{ steps.generate_version.outputs.version }}
- name: Publish Account Management build
working-directory: application/account-management
run: |
dotnet publish ./Api/Api.csproj --no-restore --configuration Release --output ./Api/publish --version-suffix ${{ steps.generate_version.outputs.version }}
- name: Save Account Management artifacts
uses: actions/upload-artifact@v3
with:
name: account-management
path: application/account-management/Api/publish/**/*
test-with-code-coverage:
name: Test and Code Coverage
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Bun
uses: oven-sh/setup-bun@v1
- name: Restore Node modules
working-directory: application/account-management/WebApp
run: bun install --frozen-lockfile
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore .NET tools
working-directory: application
run: |
dotnet tool restore &&
dotnet workload install aspire
- name: Setup-java
uses: actions/setup-java@v3
with:
distribution: "microsoft"
java-version: "17"
- name: Run Test with dotCover and SonarScanner reporting
working-directory: application
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet sonarscanner begin /k:"${{ vars.SONAR_PROJECT_KEY }}" /o:"${{ vars.SONAR_ORGANIZATION }}" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.dotcover.reportsPaths="coverage/dotCover.html" &&
dotnet dotcover test PlatformPlatform.sln --dcOutput="coverage/dotCover.html" --dcReportType=HTML &&
dotnet sonarscanner end /d:sonar.login="${SONAR_TOKEN}"
jetbrains-code-inspection:
name: JetBrains Code Inspections
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Bun
uses: oven-sh/setup-bun@v1
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore .NET tools
working-directory: application
run: |
dotnet tool restore &&
dotnet workload install aspire
- name: Run code inspections
working-directory: application
run: |
dotnet jb inspectcode PlatformPlatform.sln --build --output=result.xml --severity=SUGGESTION --exclude="**/*.csproj" # Exclude .csproj. See https://youtrack.jetbrains.com/issue/RSRP-490866
# Check if there are any issues. <Issues /> indicates no issues found.
if ! grep -q '<Issues />' result.xml; then
cat result.xml
echo "Code inspection issues found."
exit 1
fi
- name: Check for code formatting issues
working-directory: application
run: |
dotnet jb cleanupcode PlatformPlatform.sln --profile=".NET only"
# Check for any changes made by the code formatter
git diff --exit-code || {
echo "Formatting issues detected. Please run 'dotnet jb cleanupcode PlatformPlatform.sln --profile=\".NET only\"' locally and commit the formatted code."
exit 1
}
account-management-publish:
name: Account Management Publish
needs: [build]
uses: ./.github/workflows/_publish-container.yml
secrets: inherit
with:
artifacts_name: account-management
artifacts_path: application/account-management/Api/publish
image_name: account-management
version: ${{ needs.build.outputs.version }}
docker_context: ./application/account-management
docker_file: ./Api/Dockerfile
account-management-deploy:
name: Account Management Deploy
if: github.ref == 'refs/heads/main'
needs:
[
build,
test-with-code-coverage,
jetbrains-code-inspection,
account-management-publish,
]
uses: ./.github/workflows/_deploy-container.yml
secrets: inherit
with:
image_name: account-management
version: ${{ needs.build.outputs.version }}