Repository navigation
107 lines (98 loc) · 4.12 KB
/
Copy path_unit_tests.yml
File metadata and controls
107 lines (98 loc) · 4.12 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
on:
workflow_call:
inputs:
dotnet_versions:
required: true
type: string
publish_coverage:
required: true
type: boolean
env:
DOTNET_INSTALL_DIR: "./.dotnet"
DOTNET_ROLL_FORWARD: "Major"
permissions:
contents: read
jobs:
unit_test:
name: ${{ matrix.os }} - net${{ matrix.dotnet_version }} - ${{ matrix.git_backend }}
permissions:
id-token: write
strategy:
fail-fast: false
matrix:
os: [ windows-2025-vs2026, ubuntu-26.04, macos-26 ]
dotnet_version: ${{ fromJson(inputs.dotnet_versions) }}
# Run the suite against both Git backends until libgit2 is removed,
# see https://github.com/GitTools/GitVersion/issues/5031
git_backend: [ libgit2, managed ]
runs-on: ${{ matrix.os }}
timeout-minutes: 45
env:
GITVERSION_GIT_BACKEND: ${{ matrix.git_backend }}
TEST_RESULTS: ${{ github.workspace }}/artifacts/test-results/${{ matrix.git_backend }}/attempt-${{ github.run_attempt }}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@aebdcf6156ab6691adf63218240e476564a1ed4c # v2.23.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- name: Restore State
uses: $/.github/actions/cache-restore # NOSONAR -- $/ resolves to the running commit.
# One attempt: retries leave stale failure annotations after a later pass.
- name: '[Unit Test]'
id: unit_tests
timeout-minutes: 30
shell: bash
run: |
# Explicit bash uses pipefail on every runner. Keep the log outside Cake's Clean target.
preserve_reports() {
mkdir -p "$TEST_RESULTS"
cp "$RUNNER_TEMP/unit-tests.log" "$TEST_RESULTS/test.log"
if [[ -f "$GITHUB_STEP_SUMMARY" ]]; then
cp "$GITHUB_STEP_SUMMARY" "$TEST_RESULTS/summary.md"
fi
}
trap preserve_reports EXIT
dotnet run/build.dll --target=UnitTest --dotnet_version=${{ matrix.dotnet_version }} --test_results="$TEST_RESULTS" \
2>&1 | tee "$RUNNER_TEMP/unit-tests.log"
- name: Explain failed or incomplete test run
if: always() && steps.unit_tests.outcome != 'success'
shell: bash
env:
TEST_OUTCOME: ${{ steps.unit_tests.outcome }}
run: |
{
echo '### Unit-test job did not complete successfully'
printf 'Test step outcome: **%s**.\n\n' "$TEST_OUTCOME"
echo 'Project summaries describe completed test runs only. A build or host failure may leave other projects untested.'
echo 'Missing reports do not mean tests passed. See the job log and available test-results artifact.'
} >> "$GITHUB_STEP_SUMMARY"
mkdir -p "$TEST_RESULTS"
cat "$GITHUB_STEP_SUMMARY" >> "$TEST_RESULTS/summary.md"
- name: Preserve test reports and log
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: always()
with:
name: test-results-${{ matrix.os }}-net${{ matrix.dotnet_version }}-${{ matrix.git_backend }}-${{ github.run_id }}-${{ github.run_attempt }}
path: artifacts/test-results/
if-no-files-found: warn
retention-days: 7
- name: Upload Test Results
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
if: ${{ !cancelled() && inputs.publish_coverage && matrix.dotnet_version == '10.0' }}
with:
files: artifacts/test-results/**/results.xml
report_type: 'test_results'
flags: ${{ matrix.git_backend }}
use_oidc: true
- name: Upload Coverage
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
if: success() && inputs.publish_coverage && matrix.dotnet_version == '10.0'
with:
directory: artifacts/test-results
report_type: 'coverage'
flags: ${{ matrix.git_backend }}
use_oidc: true