Skip to content

.NET

.NET #611

Workflow file for this run

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 }}