Repository navigation
196 lines (181 loc) · 7.21 KB
/
Copy pathci.yml
File metadata and controls
196 lines (181 loc) · 7.21 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
name: CI
# The one entry point for the test and lint workflows on a change. The CI job at the end is the required check.
on:
pull_request:
push:
branches: [main, 'release/**']
workflow_dispatch:
# A pull request keeps only its newest run. main runs one at a time, and a newer pending run replaces the older one.
# Each release/** commit and each dispatch gets its own group, so none is replaced.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.event_name == 'workflow_dispatch' && format('dispatch-{0}', github.run_id) || github.ref == 'refs/heads/main' && github.ref || format('{0}-{1}', github.ref, github.sha) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
plan:
name: Plan
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
actions: read
outputs:
macos: ${{ steps.decide.outputs.macos }}
plugins: ${{ steps.decide.outputs.plugins }}
ios: ${{ steps.decide.outputs.ios }}
oracle: ${{ steps.decide.outputs.oracle }}
hana: ${{ steps.decide.outputs.hana }}
swiftlint: ${{ steps.decide.outputs.swiftlint }}
linux: ${{ steps.decide.outputs.linux }}
linux-docs: ${{ steps.decide.outputs.linux-docs }}
linux-deps: ${{ steps.decide.outputs.linux-deps }}
packages: ${{ steps.decide.outputs.packages }}
core: ${{ steps.decide.outputs.core }}
windows: ${{ steps.decide.outputs.windows }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
# A push compares with the last commit a CI push run on its own branch passed on, so a commit whose run was
# replaced or failed is tested again, and a release line's changelog commit runs Lint only. None, as on the first
# push of a release line, one on HEAD itself, or a dispatch runs everything.
- name: Find the base
id: base
env:
EVENT: ${{ github.event_name }}
PR_BASE: ${{ github.event.pull_request.base.sha }}
BRANCH: ${{ github.ref_name }}
GH_TOKEN: ${{ github.token }}
REPOSITORY: ${{ github.repository }}
run: |
set -euo pipefail
base=""
case "$EVENT" in
pull_request) base="$PR_BASE" ;;
push)
passed="$(gh api "repos/$REPOSITORY/actions/workflows/ci.yml/runs?branch=$BRANCH&event=push&status=success&per_page=1" \
--jq '.workflow_runs[0].head_sha // ""')"
if [ -n "$passed" ] && [ "$passed" != "$(git rev-parse HEAD)" ] && git merge-base --is-ancestor "$passed" HEAD; then
base="$passed"
fi
;;
esac
echo "Base: ${base:-none, so every suite runs}"
echo "base=$base" >> "$GITHUB_OUTPUT"
# Linux ships from main or linux-X.Y, and the core and the Windows app have no release line, so a release/** push
# or a pull request into one skips them.
- name: Decide which suites run
id: decide
env:
BASE: ${{ steps.base.outputs.base }}
REF: ${{ github.ref }}
BASE_REF: ${{ github.base_ref }}
run: |
set -euo pipefail
release_line=false
case "$REF" in refs/heads/release/*) release_line=true ;; esac
case "$BASE_REF" in release/*) release_line=true ;; esac
for suite in macos plugins ios oracle hana swiftlint linux linux-docs linux-deps packages core windows; do
verdict="$(scripts/ci/detect-changed-paths.sh --base "$BASE" "$suite")"
case "$suite" in
linux | linux-docs | linux-deps | packages | core | windows) [ "$release_line" = false ] || verdict=false ;;
esac
echo "$suite=$verdict"
echo "$suite=$verdict" >> "$GITHUB_OUTPUT"
done
lint:
needs: plan
permissions:
contents: read
pull-requests: read
uses: ./.github/workflows/ci-lint.yml
with:
swiftlint: ${{ needs.plan.outputs.swiftlint == 'true' }}
hana: ${{ needs.plan.outputs.hana == 'true' }}
macos:
needs: plan
if: needs.plan.outputs.macos == 'true'
uses: ./.github/workflows/macos-tests.yml
with:
plugins: ${{ needs.plan.outputs.plugins == 'true' }}
ios:
needs: plan
if: needs.plan.outputs.ios == 'true'
uses: ./.github/workflows/ios-tests.yml
with:
oracle: ${{ needs.plan.outputs.oracle == 'true' }}
linux:
needs: plan
if: needs.plan.outputs.linux-docs == 'true'
uses: ./.github/workflows/build-linux.yml
with:
docs-only: ${{ needs.plan.outputs.linux != 'true' }}
dependencies: ${{ needs.plan.outputs.linux-deps == 'true' }}
# The clean distribution builds, when a change touches what the packages declare or how they build. A source change
# alone leaves them to the nightly.
packages:
needs: plan
if: needs.plan.outputs.packages == 'true'
uses: ./.github/workflows/linux-packages.yml
core:
needs: plan
if: needs.plan.outputs.core == 'true'
uses: ./.github/workflows/core.yml
with:
extended: false
windows:
needs: plan
if: needs.plan.outputs.windows == 'true'
uses: ./.github/workflows/windows.yml
# Fails on a failed or cancelled job, and on a job the plan selected that did not succeed. A job the plan left out
# is skipped, which passes.
ci:
name: CI
needs: [plan, lint, macos, ios, linux, packages, core, windows]
if: always()
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Every selected job passed
env:
PLAN: ${{ needs.plan.result }}
LINT: ${{ needs.lint.result }}
MACOS: ${{ needs.macos.result }}
IOS: ${{ needs.ios.result }}
LINUX: ${{ needs.linux.result }}
PACKAGES: ${{ needs.packages.result }}
CORE: ${{ needs.core.result }}
WINDOWS: ${{ needs.windows.result }}
WANT_MACOS: ${{ needs.plan.outputs.macos }}
WANT_IOS: ${{ needs.plan.outputs.ios }}
WANT_LINUX: ${{ needs.plan.outputs.linux-docs }}
WANT_PACKAGES: ${{ needs.plan.outputs.packages }}
WANT_CORE: ${{ needs.plan.outputs.core }}
WANT_WINDOWS: ${{ needs.plan.outputs.windows }}
run: |
status=0
check() {
case "$2" in
failure | cancelled) echo "::error::$1 ended $2"; status=1 ;;
success) echo "$1: success" ;;
*)
if [ "$3" = true ]; then
echo "::error::$1 was selected and ended ${2:-without a result}"
status=1
else
echo "$1: $2, not selected"
fi
;;
esac
}
check plan "$PLAN" true
check lint "$LINT" true
check macos "$MACOS" "$WANT_MACOS"
check ios "$IOS" "$WANT_IOS"
check linux "$LINUX" "$WANT_LINUX"
check packages "$PACKAGES" "$WANT_PACKAGES"
check core "$CORE" "$WANT_CORE"
check windows "$WINDOWS" "$WANT_WINDOWS"
exit "$status"