-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (137 loc) · 4.32 KB
/
ci.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
name: Continuous Integration
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
TAG: ${{ github.sha }}
jobs:
analyze:
name: analyze code
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: ["csharp"]
steps:
- name: checkout code
id: checkout-code
uses: actions/checkout@v4
- name: initialize codeql
id: initialize-codeql
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: security-and-quality
- name: setup .net
id: setup-dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: restore cached dependencies
id: restore-cached-dependencies
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget
- name: restore dependencies
id: restore-dependencies
run: dotnet restore src
- name: 🔨 build application
id: build-application
run: dotnet build src --configuration Release --no-restore
- name: 🧪 perform codeql analysis
id: perform-codeql-analysis
uses: github/codeql-action/analyze@v3
test:
name: unit test
runs-on: ubuntu-latest
steps:
- name: checkout code
id: checkout-code
uses: actions/checkout@v4
- name: setup .net
id: setup-dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: restore cached dependencies
id: restore-cached-dependencies
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget
- name: restore dependencies
id: restore-dependencies
run: dotnet restore src
- name: 🔨 build application
id: build-application
run: dotnet build src --configuration Release --no-restore
- name: 🧪 run unit tests
id: run-unit-tests
run: |
cd ./tests/Coding.Blog.Tests/
dotnet test --configuration Release --no-build --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
cp TestResults/*/coverage.opencover.xml .
- name: 💌 publish code coverage
id: publish-code-coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: /home/runner/work/coding-blog/coding-blog/tests/Coding.Blog.Tests/coverage.opencover.xml
fail_ci_if_error: true
lint:
name: lint code
runs-on: ubuntu-latest
steps:
- name: checkout code
id: checkout-code
uses: actions/checkout@v4
- name: 🧼 lint markdown files
id: lint-markdown-files
uses: avto-dev/[email protected]
- name: 🧼 lint json files
id: lint-json-files
uses: ocular-d/[email protected]
- name: 🧼 lint renovate config
id: lint-renovate-config
uses: suzuki-shunsuke/[email protected]
with:
config_file_path: "renovate.json"
verify-docker-build:
name: verify docker build
runs-on: ubuntu-latest
steps:
- name: checkout code
id: checkout-code
uses: actions/checkout@v4
- name: 🔐 authorize gcloud
id: authorize-gcloud
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ secrets.GKE_SA_KEY }}
- name: ☁ setup gcloud cli
id: setup-gcloud
uses: google-github-actions/[email protected]
with:
project_id: ${{ secrets.GKE_PROJECT }}
- name: 🔧 configure docker
id: configure-docker
run: |-
gcloud --quiet auth configure-docker
- name: 🐳 build docker image
id: build-docker-image
run: |-
docker build -f "src/Coding.Blog/Coding.Blog/Dockerfile" \
--tag "gcr.io/$PROJECT_ID/$TAG" \
"src"