-
Notifications
You must be signed in to change notification settings - Fork 63
141 lines (120 loc) · 4.68 KB
/
ci.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
name: LoRa Build & Test CI
on: # rebuild any PRs and main branch changes
pull_request:
branches:
- master
- dev
paths-ignore:
- 'Docs/**'
- 'Arduino/**'
- 'Samples/**'
push:
branches:
- master
- dev
workflow_dispatch:
permissions:
id-token: write
env:
buildConfiguration: 'Release'
AZURE_FUNCTIONAPP_NAME: loramoduleintegrationtest
TESTS_FOLDER: Tests
TESTS_RESULTS_FOLDER: Tests/TestResults
jobs:
build_and_test:
name: Build and Test Solution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Checkout current branch
- uses: actions/[email protected]
with:
global-json-file: global.json
- name: .NET SDK Information
run: dotnet --info
- name: Restore Tools
run: dotnet tool restore
- name: Refresh T4 Generated Code
# Re-run all T4 templates to refresh them.
run: git ls-files *.tt | xargs -t -n 1 dotnet t4
- name: Check for Modifications
# "git diff" with "--exit-code" makes the program exit with codes similar to diff.
# That is, it exits with 1 if there were differences and 0 means no differences.
# This is to ensure that the last step did not introduce any changes to the working
# tree, which would mean that the tracked generated code is not up to date with the
# template. The templates should be executed on a local clone (either using VS or
# via "dotnet t4") and the (refreshed) generated code committed.
run: git diff --exit-code
# build LoRa Engine
- name: Build LoRa Engine
run: dotnet build --configuration ${{ env.buildConfiguration }}
# build C# Samples/DecoderSample
- name: Build C# Samples/DecoderSample
run: dotnet build --configuration ${{ env.buildConfiguration }} Samples/DecoderSample
# Run unit tests
- name: Run unit tests
run: |
dotnet test --configuration ${{ env.buildConfiguration }} --no-build \
--logger trx -r ${{ env.TESTS_RESULTS_FOLDER }}/Unit \
/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:ExcludeByFile="**/${{ env.TESTS_FOLDER }}/" \
${{ env.TESTS_FOLDER }}/Unit/LoRaWan.Tests.Unit.csproj
# Pull Redis Cache docker image
- name: Pulling Redis Cache image
run: docker pull redis:6.0-alpine
# Run integration tests
- name: Run integration tests
run: |
dotnet test --configuration ${{ env.buildConfiguration }} --no-build \
--logger trx -r ${{ env.TESTS_RESULTS_FOLDER }}/Integration \
/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:ExcludeByFile="**/${{ env.TESTS_FOLDER }}/" \
${{ env.TESTS_FOLDER }}/Integration/LoRaWan.Tests.Integration.csproj
# Run cli tests
- name: Run cli unit tests
run: |
dotnet test --configuration ${{ env.buildConfiguration }} \
--logger trx -r ${{ env.TESTS_RESULTS_FOLDER }}/Cli.Unit \
/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:ExcludeByFile="**/${{ env.TESTS_FOLDER }}/" \
./Tools/Cli-LoRa-Device-Provisioning/Tests/LoRaWan.Tools.CLI.Tests.Unit/LoRaWan.Tools.CLI.Tests.Unit.csproj
# Upload test results as artifact
- uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: test-results
path: |
${{ env.TESTS_RESULTS_FOLDER }}/Unit
${{ env.TESTS_RESULTS_FOLDER }}/Integration
${{ env.TESTS_RESULTS_FOLDER }}/Cli.Unit
- name: Upload to Codecov test reports
uses: codecov/codecov-action@v3
with:
directory: Tests/
build_docker_images:
name: Build Docker Images
runs-on: ubuntu-latest
environment:
name: CI
steps:
- name: Az CLI login
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- uses: actions/checkout@v3
name: Checkout current branch
- name: Read Secrets from keyvault
uses: ./.github/actions/read_keyvault
with:
KEY_ARRAY: ('CI-ACR-NAME', 'CI-ACR-CREDENTIALS')
KEYVAULT_NAME: ${{ secrets.KEYVAULT_NAME }}
- uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Build docker images
run: |
echo $CI_ACR_CREDENTIALS | docker login "$CI_ACR_NAME.azurecr.io" --username "$CI_ACR_NAME" --password-stdin
CONTAINER_REGISTRY_ADDRESS=$CI_ACR_NAME.azurecr.io docker buildx bake --set *.args.CONTAINER_REGISTRY_ADDRESS=${{ env.CI_ACR_NAME }}.azurecr.io
working-directory: LoRaEngine