-
Notifications
You must be signed in to change notification settings - Fork 3
176 lines (146 loc) · 5.62 KB
/
build.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
name: Build authorization server
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
CONTAINER_REGISTRY: ghcr.io
defaults:
run:
working-directory: dotnet-authserver
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
authserver: ${{ steps.image_tags.outputs.authserver }}
testclient: ${{ steps.image_tags.outputs.testclient }}
services:
postgres:
image: postgres
env:
POSTGRES_DB: teacher_identity
POSTGRES_PASSWORD: teacher_identity
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v2
with:
dotnet-version: '6.0.x'
- name: Lint
run: |
#https://github.com/dotnet/format/issues/1433
dotnet tool install -g dotnet-format --version "6.*" --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json
dotnet-format --verify-no-changes
- name: Build
run: dotnet build --configuration Release
- name: Install Playwright
run: pwsh ./test/TeacherIdentity.AuthServer.EndToEndTests/bin/Release/net6.0/playwright.ps1 install
- name: Unit tests
id: unit-tests
run: dotnet test ./test/TeacherIdentity.AuthServer.Tests/ --configuration Release --no-build --logger trx
env:
ConnectionStrings__DefaultConnection: "Host=localhost;Username=postgres;Password=teacher_identity;Database=teacher_identity"
- name: Unit tests report
uses: dorny/test-reporter@v1
if: always() && (steps.unit-tests.outcome == 'success' || steps.unit-tests.outcome == 'failure')
with:
name: Unit test results
path: 'dotnet-authserver/test/TeacherIdentity.AuthServer.Tests/**/*.trx'
reporter: dotnet-trx
- name: End-to-end tests
id: e2e-tests
run: dotnet test ./test/TeacherIdentity.AuthServer.EndToEndTests/ --configuration Release --no-build --logger trx
env:
AuthorizationServer__ConnectionStrings__DefaultConnection: "Host=localhost;Username=postgres;Password=teacher_identity;Database=teacher_identity"
- name: End-to-end tests report
uses: dorny/test-reporter@v1
if: always() && (steps.e2e-tests.outcome == 'success' || steps.e2e-tests.outcome == 'failure')
with:
name: End-to-end test results
path: 'dotnet-authserver/test/TeacherIdentity.AuthServer.EndToEndTests/**/*.trx'
reporter: dotnet-trx
- name: Publish
run: |
dotnet publish --configuration Release --no-build src/TeacherIdentity.AuthServer/TeacherIdentity.AuthServer.csproj
dotnet publish --configuration Release --no-build src/TeacherIdentity.TestClient/TeacherIdentity.TestClient.csproj
- name: Get Docker image tags
id: image-tags
run: |
echo ::set-output name=authserver::$CONTAINER_REGISTRY/$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]'):authserver-$GITHUB_SHA
echo ::set-output name=testclient::$CONTAINER_REGISTRY/$(echo $GITHUB_REPOSITORY | tr '[:upper:]' '[:lower:]'):testclient-$GITHUB_SHA
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: AuthServer Docker build & push
uses: docker/build-push-action@v2
with:
context: dotnet-authserver/src/TeacherIdentity.AuthServer
push: true
tags: ${{ steps.image-tags.outputs.authserver }}
build-args: |
GIT_SHA=${{ github.sha }}
- name: TestClient Docker build & push
uses: docker/build-push-action@v2
with:
context: dotnet-authserver/src/TeacherIdentity.TestClient
push: true
tags: ${{ steps.image-tags.outputs.testclient }}
validate_terraform:
name: Validate Terraform
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.0.10
- name: Check formatting
run: terraform fmt -check
working-directory: terraform
- name: Validate
run: |
terraform init -backend=false
terraform validate -no-color
working-directory: terraform
- name: Lint
uses: reviewdog/action-tflint@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tflint_rulesets: azurerm
working_directory: terraform
continue-on-error: true # temporary- we're getting sporadic 503 errors here in action setup
deploy_dev:
name: Deploy to dev environment
needs: [build, validate_terraform]
runs-on: ubuntu-latest
if: (github.event_name == 'pull_request' && github.event.pull_request.draft == false) || github.event_name == 'workflow_dispatch'
environment:
name: dev
url: ${{ steps.deploy.outputs.environment_url }}
concurrency: deploy_dev
outputs:
environment_url: ${{ steps.deploy.outputs.environment_url }}
steps:
- uses: actions/checkout@v3
- uses: ./.github/workflows/actions/deploy-environment
id: deploy
with:
environment_name: dev
docker_image: ghcr.io/dfe-digital/get-an-identity
authserver_tag: authserver-${{ github.sha }}
testclient_tag: testclient-${{ github.sha }}
azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}
terraform_vars: workspace_variables/dev.tfvars.json
terraform_backend_vars: workspace_variables/dev.backend.tfvars