-
Notifications
You must be signed in to change notification settings - Fork 139
138 lines (132 loc) · 5.62 KB
/
Copy pathdotnet.yml
File metadata and controls
138 lines (132 loc) · 5.62 KB
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
name: .NET
on:
push:
branches: [ master ]
pull_request:
# 'labeled' lets applying the run-billable-tests label start a live run on demand.
types: [opened, synchronize, reopened, labeled]
schedule:
# Weekly live drift-check of the integration cassettes against the real Google APIs.
- cron: '0 6 * * 1'
workflow_dispatch:
inputs:
frameworks:
description: 'TFMs to run integration tests against'
type: choice
required: true
default: 'both'
options:
- 'net10.0'
- 'net8.0'
- 'both'
live:
description: 'Run integration tests LIVE against Google (needs key; counts against quota)'
type: boolean
required: false
default: false
run_billable:
description: 'When running live, also run billable API tests (Places/Aerial/Solar) — paid quota'
type: boolean
required: false
default: false
permissions:
contents: read
pull-requests: write
jobs:
# Default build for every push/PR. Unit tests and the VCR harness are always offline. Replay
# integration tests are added automatically once the repository has a committed cassette dataset.
build:
if: >
github.event_name == 'push' ||
github.event_name == 'pull_request' ||
github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Setup .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: |
6.0.x
8.0.x
10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test (net8.0, offline)
if: github.event_name == 'workflow_dispatch' && (inputs.frameworks == 'net8.0' || inputs.frameworks == 'both')
run: dotnet test --no-build --verbosity normal --framework net8.0 --filter "TestCategory!=Integration" --logger "junit;LogFilePath=test-results/{assembly}.net8.0.xml" --collect:"XPlat Code Coverage" --settings coverlet.runsettings --results-directory ./TestResults
env:
VCR_MODE: replay
- name: Test (net10.0, offline)
if: github.event_name != 'workflow_dispatch' || inputs.frameworks == 'net10.0' || inputs.frameworks == 'both'
run: dotnet test --no-build --verbosity normal --framework net10.0 --filter "TestCategory!=Integration" --logger "junit;LogFilePath=test-results/{assembly}.net10.0.xml" --collect:"XPlat Code Coverage" --settings coverlet.runsettings --results-directory ./TestResults
env:
VCR_MODE: replay
- name: Test integration cassettes (net10.0, replay)
if: github.event_name != 'workflow_dispatch' || inputs.frameworks == 'net10.0' || inputs.frameworks == 'both'
shell: bash
run: |
if find GoogleMapsApi.Test/Cassettes -name '*.json' -print -quit | grep -q .; then
dotnet test --no-build --verbosity normal --framework net10.0 \
--filter "TestCategory=Integration" \
--logger "junit;LogFilePath=test-results/{assembly}.integration.net10.0.xml"
else
echo "::warning::Replay integration tests are not enabled because no cassette JSON files are committed."
fi
env:
VCR_MODE: replay
- name: Upload coverage to Codecov
if: always()
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./TestResults
fail_ci_if_error: false
verbose: true
- name: TestGlance
if: always()
uses: testglance/action@6d35dc91921aea41ca1d62f15f3bc80bd946cf03 # v1
with:
github-token: ${{ github.token }}
# Live drift-check: hits the real Google APIs to catch responses that have diverged from the
# committed cassettes. Runs on the weekly schedule, on manual dispatch with `live=true`, or when a
# PR carries the `run-billable-tests` label. Same-repo only, so external PRs can't trigger paid runs.
live:
if: >
github.event_name == 'schedule' ||
(github.event_name == 'workflow_dispatch' && inputs.live) ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository &&
contains(github.event.pull_request.labels.*.name, 'run-billable-tests'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Setup .NET
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # v6.0.0
with:
dotnet-version: |
6.0.x
8.0.x
10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test (net10.0, live)
run: dotnet test --no-build --verbosity normal --framework net10.0 --filter "TestCategory=Integration" --logger "junit;LogFilePath=test-results/{assembly}.net10.0.xml"
env:
VCR_MODE: live
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
# Schedule and label runs include billable APIs; manual dispatch honors the checkbox.
RUN_BILLABLE_TESTS: ${{ github.event_name != 'workflow_dispatch' || inputs.run_billable }}
- name: TestGlance
if: always()
uses: testglance/action@6d35dc91921aea41ca1d62f15f3bc80bd946cf03 # v1
with:
github-token: ${{ github.token }}