-
Notifications
You must be signed in to change notification settings - Fork 3
135 lines (118 loc) · 4.85 KB
/
dotnet-shared.yml
File metadata and controls
135 lines (118 loc) · 4.85 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
name: .NET Shared Library
on:
push:
paths:
- 'src/**'
- 'Directory.Build.props'
- 'Directory.Build.targets'
- '.github/workflows/dotnet-shared.yml'
pull_request:
paths:
- 'src/**'
- 'Directory.Build.props'
- 'Directory.Build.targets'
- '.github/workflows/dotnet-shared.yml'
workflow_dispatch:
inputs:
sample_id:
description: 'Sampling correlation id (prevents cancels)'
required: false
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.inputs.sample_id || github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
- shared_source: package-first
expected_resolved: package
- shared_source: package
expected_resolved: package
- shared_source: project
expected_resolved: project
steps:
- uses: actions/checkout@v5
with:
repository: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '8.0.x'
- name: Restore shared project
run: dotnet restore src/CompareVi.Shared/CompareVi.Shared.csproj
- name: Build shared project
run: dotnet build -c Release src/CompareVi.Shared/CompareVi.Shared.csproj --no-restore
- name: Pack shared project
run: dotnet pack -c Release src/CompareVi.Shared/CompareVi.Shared.csproj -o artifacts --no-build
- name: Resolve packed shared version
id: shared
shell: bash
run: |
set -euo pipefail
pkg="$(find artifacts -maxdepth 1 -name 'CompareVi.Shared.*.nupkg' | head -n 1)"
if [ -z "$pkg" ]; then
echo "No CompareVi.Shared nupkg found in artifacts/"
exit 1
fi
version="$(basename "$pkg" | sed -E 's/^CompareVi\.Shared\.([0-9A-Za-z\.-]+)\.nupkg$/\1/')"
if [ -z "$version" ]; then
echo "Failed to derive package version from $pkg"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Restore CompareVi CLI
run: >
dotnet restore src/CompareVi.Tools.Cli/CompareVi.Tools.Cli.csproj
-p:CompareViSharedSource=${{ matrix.shared_source }}
-p:CompareViSharedPackageVersion=${{ steps.shared.outputs.version }}
-p:CompareViSharedPackageFeed=${{ github.workspace }}/artifacts
--source "${{ github.workspace }}/artifacts"
--source "https://api.nuget.org/v3/index.json"
- name: Assert shared-source resolution
shell: bash
run: |
set -euo pipefail
output="$(dotnet msbuild src/CompareVi.Tools.Cli/CompareVi.Tools.Cli.csproj \
-nologo \
-t:PrintCompareViSharedSource \
-p:CompareViSharedSource=${{ matrix.shared_source }} \
-p:CompareViSharedPackageVersion=${{ steps.shared.outputs.version }} \
-p:CompareViSharedPackageFeed=${{ github.workspace }}/artifacts)"
echo "$output"
echo "$output" | grep -F "CompareViSharedResolvedSource=${{ matrix.expected_resolved }}"
- name: Build CompareVi CLI
run: >
dotnet build -c Release src/CompareVi.Tools.Cli/CompareVi.Tools.Cli.csproj
-p:CompareViSharedSource=${{ matrix.shared_source }}
-p:CompareViSharedPackageVersion=${{ steps.shared.outputs.version }}
-p:CompareViSharedPackageFeed=${{ github.workspace }}/artifacts
--no-restore
- name: CLI smoke (version/tokenize/procs)
shell: bash
run: |
set -euo pipefail
run_cli() {
dotnet run --project src/CompareVi.Tools.Cli/CompareVi.Tools.Cli.csproj -c Release --no-build \
-p:CompareViSharedSource=${{ matrix.shared_source }} \
-p:CompareViSharedPackageVersion=${{ steps.shared.outputs.version }} \
-p:CompareViSharedPackageFeed=${{ github.workspace }}/artifacts -- "$@"
}
ver_json="$(run_cli version)"
node -e "const o=JSON.parse(process.argv[1]); if(o.name!=='comparevi-cli'){throw new Error('unexpected name')}" "$ver_json"
tok_json="$(run_cli tokenize --input "foo -x=1 bar")"
node -e "const o=JSON.parse(process.argv[1]); if(!o.normalized.includes('-x')||!o.normalized.includes('1')||!o.normalized.includes('bar')){throw new Error('tokenize regression')}" "$tok_json"
run_cli procs >/dev/null
- name: Upload shared package artifacts
uses: actions/upload-artifact@v7
with:
name: comparevi-shared-nuget-${{ matrix.shared_source }}
path: |
artifacts/*.nupkg
artifacts/*.snupkg
if-no-files-found: error