-
Notifications
You must be signed in to change notification settings - Fork 12
163 lines (134 loc) · 5.62 KB
/
ci-tests.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: Tests
# Controls when the workflow will run
on:
pull_request:
branches: [ main, main-vnext ]
push:
branches: [ main, main-vnext ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
unit-test:
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Restore Dotnet tools
run: dotnet tool restore
working-directory: src/
- name: Restore dependencies
run: dotnet restore IoTHub.Portal.sln
working-directory: src/
- name: Build
run: dotnet build IoTHub.Portal.sln --no-restore -p:ClientAssetsRestoreCommand="npm ci"
working-directory: src/
- name: Run unit tests
run: dotnet test --no-build --verbosity normal --logger trx --collect:"XPlat Code Coverage" IoTHub.Portal.Tests.Unit.csproj
working-directory: src/IoTHub.Portal.Tests.Unit/
# Upload test results as artifact
- uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: test-results
path: |
src/IoTHub.Portal.Tests.Unit/TestResults
codecov:
name: Codecov
runs-on: ubuntu-latest
needs: unit-test
steps:
- uses: actions/[email protected]
- uses: actions/download-artifact@v4
with:
name: test-results
path: |
src/IoTHub.Portal.Tests.Unit/TestResults
- name: Upload to Codecov test reports
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: src/IoTHub.Portal.Tests.Unit/TestResults
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
#e2e-tests:
# name: E2E tests
# runs-on: ubuntu-latest
# environment: E2E
# steps:
# - uses: actions/[email protected]
# - name: Setup .NET
# uses: actions/setup-dotnet@v4
# with:
# dotnet-version: 7.0.x
# - name: Launch the portal locally
# uses: isbang/[email protected]
# with:
# compose-file: "./src/e2e-docker-compose.yml"
# down-flags: "--volumes"
# up-flags: "--build"
# env:
# GITHUB_RUN_NUMBER: ${{ github.run_number }}
# CLOUDPROVIDER: ${{ Azure }}
# PORTALNAME: ${{ vars.PORTALNAME }}
# OIDC__VALIDATEAUDIENCE: ${{ vars.OIDC__VALIDATEAUDIENCE }}
# OIDC__SCOPE: ${{ vars.OIDC__SCOPE }}
# OIDC__METADATAURL: ${{ vars.OIDC__METADATAURL }}
# OIDC__CLIENTID: ${{ vars.OIDC__CLIENTID }}
# OIDC__AUTHORITY: ${{ vars.OIDC__AUTHORITY }}
# OIDC__APICLIENTID: ${{ vars.OIDC__APICLIENTID }}
# LORAFEATURE_ENABLED: ${{ vars.LORAFEATURE_ENABLED }}
# AZURE_STORAGEACCOUNT__BLOBCONTAINERNAME: ${{ vars.STORAGEACCOUNT__BLOBCONTAINERNAME }}
# AZURE_LORAKEYMANAGEMENT__URL: ${{ vars.LORAKEYMANAGEMENT__URL }}
# AZURE_IOTHUB__EVENTHUB__CONSUMERGROUP: ${{ vars.IOTHUB__EVENTHUB__CONSUMERGROUP }}
# AZURE_IOTDPS__SERVICEENDPOINT: ${{ vars.IOTDPS__SERVICEENDPOINT }}
# AZURE_IOTDPS__IDSCOPE: ${{ vars.IOTDPS__IDSCOPE }}
# AZURE_IDEAS__URL: ${{ vars.IDEAS__URL }}
# AZURE_IDEAS__ENABLED: ${{ vars.IDEAS__ENABLED }}
# AZURE_IDEAS__AUTHENTICATION__HEADER: ${{ vars.IDEAS__AUTHENTICATION__HEADER }}
# POSTGRESQL__CONNECTIONSTRING: ${{ secrets.POSTGRESQL__CONNECTIONSTRING }}
# JOBSTORE__CONNECTIONSTRING: ${{ secrets.JOBSTORE__CONNECTIONSTRING }}
# AZURE_IOTHUB__EVENTHUB__ENDPOINT: ${{ secrets.IOTHUB__EVENTHUB__ENDPOINT }}
# AZURE_LORAKEYMANAGEMENT__CODE: ${{ secrets.LORAKEYMANAGEMENT__CODE }}
# AZURE_IOTHUB__CONNECTIONSTRING: ${{ secrets.IOTHUB__CONNECTIONSTRING }}
# AZURE_IOTDPS__CONNECTIONSTRING: ${{ secrets.IOTDPS__CONNECTIONSTRING }}
# AZURE_STORAGEACCOUNT__CONNECTIONSTRING: ${{ secrets.STORAGEACCOUNT__CONNECTIONSTRING }}
# IDEAS__AUTHENTICATION__TOKEN: ${{ secrets.IDEAS__AUTHENTICATION__TOKEN }}
# - name: Wait until portal is up
# run: |
# while ! nc -z localhost 80 </dev/null; do sleep 10; done
# shell: bash
# - name: Install Chrome Driver
# run: |
# wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
# echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | sudo tee /etc/apt/sources.list.d/google-chrome.list
# sudo apt-get update
# sudo apt-get install google-chrome-stable
# LATEST_CHROMEDRIVER=$(curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE)
# wget -q -O /tmp/chromedriver.zip "https://chromedriver.storage.googleapis.com/${LATEST_CHROMEDRIVER}/chromedriver_linux64.zip"
# sudo unzip -q /tmp/chromedriver.zip -d /usr/local/bin/
# sudo chmod +x /usr/local/bin/chromedriver
# - name: Install Chrome
# run: sudo apt-get install google-chrome-stable
# - name: Run E2E tests
# run: dotnet test IoTHub.Portal.Tests.E2E.csproj
# working-directory: src/IoTHub.Portal.Tests.E2E/
# env:
# E2E_USERNAME: ${{ vars.E2E_USERNAME }}
# E2E_PASSWORD: ${{ secrets.E2E_PASSWORD }}
# E2E_URL: http://localhost:80/
# - name: Get docker logs
# run: |
# docker logs src_portal_1
# shell: bash
# if: always()