Repository navigation
153 lines (145 loc) · 6.42 KB
/
Copy pathsamples.yml
File metadata and controls
153 lines (145 loc) · 6.42 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: samples
# Packs src/** at 0.0.0-sample into artifacts/nuget-sample, builds sample/ChirographSample against that feed, as an external
# consumer would, and runs its apps against a running Rockets.Api (mise run sample:run), on Linux, Windows and macOS.
# Chirograph.slnx doesn't list the sample: it is its own solution on local packages.
on:
push:
branches:
- main
- next
tags:
- v*
pull_request:
branches:
- main
- next
- integration/**
merge_group:
branches:
- main
- next
env:
# Adds .config/mise.ci.toml, which keeps the editor-only tools out of CI installs and out of the shared mise cache.
MISE_ENV: ci
permissions:
contents: read
# A newer run for the same branch (or pull request head) cancels this one; tags and merge-queue refs are unique.
concurrency:
group: samples-${{ github.event_name }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
# The sample only builds from src/, sample/, build/Chirograph.PackLocal.targets and the root Directory.*.props/targets, plus the toolchain (.config/mise.toml,
# global.json, NuGet.config) and this workflow. Anything else skips the legs; tags always build them.
changes:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
samples: ${{ startsWith(github.ref, 'refs/tags/') || steps.filter.outputs.samples == 'true' }}
steps:
- name: Checkout
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: actions/checkout@v7
- name: 🔎 Detect sample changes
id: filter
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: dorny/paths-filter@v4
with:
filters: |
samples:
- 'src/**'
- 'sample/**'
- 'build/Chirograph.PackLocal.targets'
- 'Directory.*.props'
- 'Directory.*.targets'
- '.config/mise.toml'
- 'global.json'
- 'NuGet.config'
- '.github/workflows/samples.yml'
sample:
name: ${{ matrix.os }}
needs: changes
if: needs.changes.outputs.samples == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: '0'
# .config/mise.toml uses {{env.HOME}}, which Windows runners don't set. Keep mise's data and NuGet's packages on D:,
# which has the room; the temp folder moves there too, since mise-action renames from it into MISE_DATA_DIR and
# Windows can't rename across drives (EXDEV).
- name: Set up Windows paths
if: runner.os == 'Windows'
run: |
mkdir -p D:/tmp
{
echo "HOME=$USERPROFILE"
echo "TEMP=D:/tmp"
echo "TMP=D:/tmp"
echo "MISE_DATA_DIR=D:/mise"
echo "NUGET_PACKAGES=D:/nuget/packages"
} >> "$GITHUB_ENV"
- name: 🛠️ Setup mise
uses: jdx/mise-action@v5
env:
# One install at a time: mise downloads dotnet-install.sh to one shared path for every dotnet version, so the
# SDK and runtime installs overwrite it under each other ("failed to execute command") when they run in parallel.
MISE_JOBS: '1'
with:
install: true
# Only dotnet (the SDK and the runtime): the sample needs nothing else.
install_args: dotnet
cache: true
# Restore only: build.yml is the single cache writer (as in lint.yml).
cache_save: false
cache_key: mise-{{platform}}-{{cache_period}}
cache_max_age_days: 7
experimental: true
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: 🔎 Locate dotnet
run: |
if [ -z "${DOTNET_ROOT:-}" ]; then
DOTNET_ROOT="$(dirname "$(command -v dotnet)")"
echo "DOTNET_ROOT=$DOTNET_ROOT" >> "$GITHUB_ENV"
fi
"$DOTNET_ROOT/dotnet" --version
# Packs src/** at 0.0.0-sample, builds the sample, starts Rockets.Api on port 5179, runs Rockets.Console and Rockets.Dovetail
# against it and fails when either exits non-zero or prints something other than sample/ChirographSample/expected/<App>.txt.
# --no-deps skips the npm deps step (it fails on Windows runners and the sample doesn't need it), and --skip-tools keeps mise
# from installing the tools the sample doesn't use. The script runs dotnet from DOTNET_ROOT, the one mise installed.
- name: ▶️ Run the sample against Rockets.Api
run: mise run --no-deps --skip-tools sample:run
- name: 🏺 Publish logs
if: always()
uses: actions/upload-artifact@v7
with:
name: samples-logs-${{ matrix.os }}
path: artifacts/logs/
# The one check the main ruleset requires: the legs report as their OS names, and are skipped when nothing the sample
# builds from changed. Passes when every leg passed or all were skipped; fails when any leg failed or was cancelled.
samples:
needs:
- changes
- sample
if: always()
runs-on: ubuntu-latest
steps:
- name: ✅ Check the sample legs
env:
CHANGES: ${{ needs.changes.result }}
SAMPLE: ${{ needs.sample.result }}
run: |
echo "changes: $CHANGES, sample: $SAMPLE"
[ "$CHANGES" = success ] && { [ "$SAMPLE" = success ] || [ "$SAMPLE" = skipped ]; }