-
Notifications
You must be signed in to change notification settings - Fork 21
171 lines (155 loc) · 5.37 KB
/
Copy pathci.yaml
File metadata and controls
171 lines (155 loc) · 5.37 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
# SPDX-FileCopyrightText: 2026 Institute for Automation of Complex Power Systems, RWTH Aachen University
# SPDX-License-Identifier: Apache-2.0
name: CI
on:
push:
branches: [master]
tags: ["v*"]
pull_request:
pull_request_target:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
setup:
name: Setup Variables
# Forks get a read-only GITHUB_TOKEN, so they run via pull_request_target.
if: >-
github.event_name != 'pull_request' && github.event_name != 'pull_request_target'
|| github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.full_name == github.repository
|| github.event_name == 'pull_request_target'
&& github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
environment: ${{ github.event_name == 'pull_request_target' && 'fork-pr' || 'internal' }}
outputs:
docker_image: ${{ steps.image.outputs.docker_image }}
ref: ${{ steps.ref.outputs.ref }}
ref_name: ${{ steps.ref.outputs.ref_name }}
steps:
- name: Compute image name for the current repository
id: image
env:
OWNER: ${{ github.repository_owner }}
run: echo "docker_image=ghcr.io/${OWNER,,}/villas/node" >> "$GITHUB_OUTPUT"
# Under pull_request_target GITHUB_SHA and GITHUB_REF_NAME point at the base branch.
- name: Resolve the revision under test
id: ref
env:
REF: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}
REF_NAME: ${{ github.event_name == 'pull_request_target' && format('{0}/merge', github.event.pull_request.number) || github.ref_name }}
run: |
echo "ref=$REF" >> "$GITHUB_OUTPUT"
echo "ref_name=$REF_NAME" >> "$GITHUB_OUTPUT"
checks:
name: Run Checks
needs: [setup]
secrets: inherit
uses: ./.github/workflows/checks.yaml
with:
ref: ${{ needs.setup.outputs.ref }}
paper:
name: Build Paper Draft
needs: [setup]
secrets: inherit
uses: ./.github/workflows/paper.yaml
with:
ref: ${{ needs.setup.outputs.ref }}
nix:
name: Build with Nix
needs: [setup]
secrets: inherit
uses: ./.github/workflows/nix.yaml
with:
ref: ${{ needs.setup.outputs.ref }}
prepare:
name: Prepare Docker Images
needs: [setup]
secrets: inherit
uses: ./.github/workflows/prepare.yaml
with:
docker_image: ${{ needs.setup.outputs.docker_image }}
ref: ${{ needs.setup.outputs.ref }}
ref_name: ${{ needs.setup.outputs.ref_name }}
build:
name: Build from Source
needs: [setup, prepare]
secrets: inherit
uses: ./.github/workflows/build.yaml
with:
docker_image: ${{ needs.setup.outputs.docker_image }}
ref: ${{ needs.setup.outputs.ref }}
test:
name: Run Tests
needs: [setup, build]
secrets: inherit
uses: ./.github/workflows/test.yaml
with:
docker_image: ${{ needs.setup.outputs.docker_image }}
ref: ${{ needs.setup.outputs.ref }}
packaging-docker:
name: Build Docker Images
needs: [setup, test, prepare]
secrets: inherit
uses: ./.github/workflows/packaging-docker.yaml
with:
docker_image: ${{ needs.setup.outputs.docker_image }}
ref: ${{ needs.setup.outputs.ref }}
ref_name: ${{ needs.setup.outputs.ref_name }}
packaging-nix:
name: Bundle Artifacts with Nix
needs: [setup, nix]
secrets: inherit
uses: ./.github/workflows/packaging-nix.yaml
with:
docker_image: ${{ needs.setup.outputs.docker_image }}
ref: ${{ needs.setup.outputs.ref }}
ref_name: ${{ needs.setup.outputs.ref_name }}
deploy:
name: Deploy Docker Images
needs: [setup, packaging-docker]
secrets: inherit
uses: ./.github/workflows/deploy.yaml
with:
docker_image: ${{ needs.setup.outputs.docker_image }}
ref: ${{ needs.setup.outputs.ref }}
ref_name: ${{ needs.setup.outputs.ref_name }}
is_version_tag: ${{ startsWith(github.ref, 'refs/tags/v') }}
deploy-nix:
name: Deploy Nix Artifacts
needs: [setup, packaging-nix]
secrets: inherit
uses: ./.github/workflows/deploy-nix.yaml
with:
docker_image: ${{ needs.setup.outputs.docker_image }}
ref_name: ${{ needs.setup.outputs.ref_name }}
is_version_tag: ${{ startsWith(github.ref, 'refs/tags/v') }}
all:
# Only the real run may claim the required check name. Mirrors setup.
name: >-
${{ (github.event_name != 'pull_request' && github.event_name != 'pull_request_target'
|| github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.full_name == github.repository
|| github.event_name == 'pull_request_target'
&& github.event.pull_request.head.repo.full_name != github.repository)
&& 'All prerequisites completed' || 'CI not applicable' }}
# A skipped required check counts as passing.
if: always()
needs:
- setup
- checks
- paper
- nix
- prepare
- build
- test
- packaging-docker
- packaging-nix
- deploy
- deploy-nix
runs-on: ubuntu-latest
steps:
- name: Dependency barrier
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1