Repository navigation
221 lines (220 loc) · 8.73 KB
/
Copy pathcross-repo-trigger.yml
File metadata and controls
221 lines (220 loc) · 8.73 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# SPDX-FileCopyrightText: 1996- European Centre for Medium-Range Weather Forecasts (ECMWF)
# SPDX-License-Identifier: Apache-2.0
# GENERATED FILE - DO NOT EDIT.
# Regenerate via the ci-infrastructure-generate CLI.
# Source of truth: each repo's .ci/manifest.toml.
name: Cross-repo trigger (eckit)
run-name: Cross-repo trigger (${{ inputs.from-repo }}@${{ inputs.from-sha }}) [${{ inputs.dispatch-id }}]
on:
workflow_call:
inputs:
from-repo:
description: owner/repo of the dispatcher (upstream producer or downstream consumer)
required: true
type: string
from-sha:
description: SHA of the dispatcher commit
required: true
type: string
from-jobs:
description: JSON array of package/kinds that triggered us (e.g. '["fortmath/build","fortmath/build-hpc"]') for upstream-change dispatches. '[]' when rebuild-request is true.
required: false
default: '[]'
type: string
rebuild-request:
description: True when a downstream consumer dispatches us because our artifact was missing. Mutually exclusive with from-jobs.
required: false
default: false
type: boolean
branch:
description: Dispatcher branch name; we attempt branch-matching against it
required: true
type: string
fallback-ref:
description: Ref to check out if branch does not exist in this repo
required: false
type: string
default: main
workflow_dispatch:
inputs:
dispatch-id:
description: Correlation id stamped into run-name so the dispatcher can find this run
required: false
default: ''
type: string
from-repo:
description: owner/repo of the dispatcher (upstream producer or downstream consumer)
required: true
type: string
from-sha:
description: SHA of the dispatcher commit
required: true
type: string
from-jobs:
description: JSON array of package/kinds that triggered us (e.g. '["fortmath/build","fortmath/build-hpc"]') for upstream-change dispatches. '[]' when rebuild-request is true.
required: false
default: '[]'
type: string
rebuild-request:
description: True when a downstream consumer dispatches us because our artifact was missing. Mutually exclusive with from-jobs.
required: false
default: false
type: boolean
branch:
description: Dispatcher branch name; we attempt branch-matching against it
required: true
type: string
fallback-ref:
description: Ref to check out if branch does not exist in this repo
required: false
type: string
default: main
concurrency:
group: cross-repo-trigger-runner-eckit-${{ github.ref }}
cancel-in-progress: false
env:
ARTIFACT_POLL_INTERVAL: ${{ vars.ARTIFACT_POLL_INTERVAL || '60' }}
ARTIFACT_WAIT_TIMEOUT: ${{ vars.ARTIFACT_WAIT_TIMEOUT || '1800' }}
ARTIFACT_S3_ENDPOINT: ${{ secrets.ARTIFACT_S3_ENDPOINT }}
ARTIFACT_S3_BUCKET: ${{ secrets.ARTIFACT_S3_BUCKET }}
SCCACHE_BUCKET: ${{ secrets.SCCACHE_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
jobs:
resolve:
if: contains(fromJSON(inputs.from-jobs), 'ecbuild/build') || contains(fromJSON(inputs.from-jobs), 'stack-deps/build') || inputs.rebuild-request
runs-on: arc-runner-normal
container:
image: eccr.ecmwf.int/public-ci-images/ubuntu24.04-base:latest
outputs:
ref: ${{ steps.pick.outputs.ref }}
matrix-build: ${{ toJSON(fromJSON(steps.r.outputs.json)['build']) }}
steps:
- name: Announce image
uses: ecmwf/ci-infrastructure/actions/announce-image@main
- id: mint
uses: actions/create-github-app-token@v3
with:
client-id: ${{ secrets.CI_PERMISSIONS_APP_CLIENT_ID }}
private-key: ${{ secrets.CI_PERMISSIONS_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- id: pick
uses: ecmwf/ci-infrastructure/actions/pick-ref@main
with:
repo: ecmwf/eckit
try-branch: ${{ inputs.branch }}
fallback-ref: ${{ inputs.fallback-ref }}
token: ${{ steps.mint.outputs.token }}
- uses: actions/checkout@v6
with:
repository: ecmwf/eckit
ref: ${{ steps.pick.outputs.ref }}
token: ${{ steps.mint.outputs.token }}
persist-credentials: false
- id: r
uses: ecmwf/ci-infrastructure/actions/resolve-deps@main
with:
current-branch: ${{ steps.pick.outputs.ref }}
pin: ${{ !inputs.rebuild-request && format('{0}@{1}', inputs.from-repo, inputs.from-sha) || '' }}
matrix: build
token: ${{ steps.mint.outputs.token }}
client-id: ${{ secrets.CI_PERMISSIONS_APP_CLIENT_ID }}
app-private-key: ${{ secrets.CI_PERMISSIONS_APP_PRIVATE_KEY }}
eckit__build:
needs:
- resolve
if: contains(fromJSON(inputs.from-jobs), 'ecbuild/build') || contains(fromJSON(inputs.from-jobs), 'stack-deps/build') || inputs.rebuild-request
name: eckit/build (${{ matrix._resolved['job-name'] }})
runs-on: ${{ matrix['runs-on'] }}
container:
image: ${{ matrix.container || '' }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.resolve.outputs.matrix-build) }}
steps:
- id: mint
uses: actions/create-github-app-token@v3
with:
client-id: ${{ secrets.CI_PERMISSIONS_APP_CLIENT_ID }}
private-key: ${{ secrets.CI_PERMISSIONS_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
permission-contents: read
permission-actions: read
permission-checks: write
- id: check_start
if: ${{ github.event_name == 'workflow_dispatch' && inputs.from-jobs != '[]' }}
uses: ecmwf/ci-infrastructure/actions/report-check-run@main
with:
token: ${{ steps.mint.outputs.token }}
head-repo: ${{ inputs.from-repo }}
head-sha: ${{ inputs.from-sha }}
name: eckit/build (${{ matrix._resolved['job-name'] }})
details-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
phase: start
- name: Announce image
uses: ecmwf/ci-infrastructure/actions/announce-image@main
- uses: actions/checkout@v6
with:
repository: ecmwf/eckit
ref: ${{ needs.resolve.outputs.ref }}
token: ${{ steps.mint.outputs.token }}
persist-credentials: false
- name: Decode matrix-leg
id: m
shell: bash
env:
MATRIX_LEG: ${{ toJSON(matrix) }}
run: |
set -euo pipefail
shopt -s inherit_errexit 2>/dev/null || true
command -v jq >/dev/null || {
echo "::error::jq is required but not installed in this runner/image." >&2
exit 1
}
leg="$MATRIX_LEG"
require() {
local val
val=$(jq -r "$1" <<<"$leg")
if [ -z "$val" ] || [ "$val" = "null" ]; then
echo "::error::matrix-leg field '$2' empty or null (jq -r '$1' returned '$val')." >&2
exit 1
fi
printf '%s' "$val"
}
deps_json=$(require '._resolved.deps | tojson' '_resolved.deps')
own_artifact_name=$(require '._resolved."own-artifact-name"' '_resolved.own-artifact-name')
{
echo "deps-json=${deps_json}"
echo "own-artifact-name=${own_artifact_name}"
} >> "$GITHUB_OUTPUT"
- name: Fetch resolved deps
id: deps
uses: ecmwf/ci-infrastructure/actions/fetch-deps@main
with:
deps-json: ${{ steps.m.outputs.deps-json }}
token: ${{ steps.mint.outputs.token }}
- name: Build
id: build
uses: ecmwf/ci-infrastructure/actions/run-job-script@main
with:
job-script: ${{ matrix.job-script }}
matrix-leg: ${{ toJSON(matrix) }}
package: eckit
cmake-prefix-path: ${{ steps.deps.outputs.cmake-prefix-path }}
- name: Publish
uses: ecmwf/ci-infrastructure/actions/publish-artifact@main
with:
install-path: ${{ steps.build.outputs.install-path }}
artifact-name: ${{ steps.m.outputs.own-artifact-name }}
- name: Report check-run conclusion
if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.from-jobs != '[]' }}
uses: ecmwf/ci-infrastructure/actions/report-check-run@main
with:
token: ${{ steps.mint.outputs.token }}
head-repo: ${{ inputs.from-repo }}
head-sha: ${{ inputs.from-sha }}
name: eckit/build (${{ matrix._resolved['job-name'] }})
details-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
phase: finish
conclusion: ${{ job.status }}
check-run-id: ${{ steps.check_start.outputs.check-run-id }}