forked from dorset-ics/healthcare-data-exchange
-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (131 loc) · 5.19 KB
/
bvt.yaml
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
name: BVT
on:
workflow_call:
inputs: # service_name and project_folder need to be passed in from the calling workflow
service_name:
required: true
type: string
project_folder:
required: true
type: string
acr_name:
required: false
type: string
default: 'acrdexoss.azurecr.io'
coverage_gate:
required: false
type: string
default: '95'
secrets: # the below need to be added as secrets to the repository
AZURE_CLIENT_ID:
required: true
AZURE_CLIENT_SECRET:
required: true
AZURE_TENANT_ID:
required: true
MESH_PASSWORD:
required: true
NVD_API_KEY:
required: true
permissions:
contents: read
jobs:
bvt:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
with:
clean: true
- name: Build documentation
run: |
set -eux # fail on error
docker compose -f ../docker/docker-compose-mkdocs.yml run mkdocs build --strict # --strict is used to fail the build if there are any warnings e.g. broken links
rm -rf site/ # remove the site folder with the build files
working-directory: src
shell: bash
- name: Build
run: |
set -eux # fail on error
cp ../docker/.env.template ../docker/.env
docker compose -f ../docker/docker-compose.yml build ${{ inputs.service_name }}
working-directory: src
shell: bash
env:
SERVICE_NAME: ${{ inputs.service_name }}
- name: Unit Tests
run: dotnet test -c Release --logger "trx;LogFileName=testresults.trx" --collect:"XPlat Code Coverage"
shell: bash
working-directory: tests/Unit.Tests
- name: Start Docker Compose
run: |
set -eux # fail on error
export TAG=${{ github.run_id }}
export DataHubFhirServer__TemplateImage=${{ inputs.acr_name }}/dev:${TAG}
export Pds__Mesh__RetrieveSchedule="*/10 * * * * ?"
bash start.sh
docker compose -f docker-compose.yml up --build data-init templates-pusher
working-directory: docker
shell: bash
env:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
MESH_PASSWORD: ${{ secrets.MESH_PASSWORD }}
- name: Templates Tests
run: |
set -eux # fail on error
dotnet test -e DataHubFhirServer:TemplateImage=${{ inputs.acr_name }}/dev:${{ github.run_id }}\
-e DataHubFhirServer:BaseUrl=http://localhost:8080 \
-e Mesh:Url=http://localhost:8700 \
-c Release --logger "trx;LogFileName=testresults.trx" --collect:"XPlat Code Coverage"
working-directory: tests/Templates.Tests
shell: bash
env:
ASPNETCORE_ENVIRONMENT: 'Integration'
- name: Integration Tests
run: |
dotnet test -e DataHubFhirServer:TemplateImage=${{ inputs.acr_name }}/dev:${{ github.run_id }} -c Release --logger "trx;LogFileName=testresults.trx" --collect:"XPlat Code Coverage"
working-directory: tests/Integration.Tests
shell: bash
env:
ASPNETCORE_ENVIRONMENT: 'Integration'
Pds__Mesh__MailboxPassword: ${{ secrets.MESH_PASSWORD }}
- name: E2E Tests
run: dotnet test --logger "trx;LogFileName=testresults.trx"
working-directory: tests/E2E.Tests
shell: bash
- name: Docker logs
run: docker compose logs
working-directory: docker
shell: bash
if: always()
- name: Publish test results
# GitHub Actions does not have built-in support for publishing test results
# like Azure Pipelines does. This step will upload the test results as a
# workflow artifact, which you can download from the GitHub web interface.
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
if: always()
with:
name: TestResults
path: tests/*/TestResults/*.trx
- name: Unify Test Coverage Reports
run: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:**/coverage.cobertura.xml -targetdir:./CodeCoverage -reporttypes:Cobertura
working-directory: ${{ github.workspace }}
- name: Publish code coverage results
# GitHub Actions does not have built-in support for publishing code coverage
# results like Azure Pipelines does. This step will upload the test results
# as a workflow artifact, which you can download from the GitHub web interface.
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: CodeCoverage
path: ./CodeCoverage/Cobertura.xml
- name: Check test line coverage gate
# needs to be tested to see if it works when workflow was triggered by PR from fork
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
with:
filename: ./CodeCoverage/Cobertura.xml
thresholds: ${{ inputs.coverage_gate }}
fail_below_min: true