-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (156 loc) · 5.3 KB
/
images.yaml
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
name: Images
on:
schedule:
- cron: 0 0 * * SUN
push:
branches:
- master
- "v[0-9]+.[0-9]+"
paths:
- "Containerfile.*"
- .github/workflows/images.yaml
pull_request:
types: [opened, synchronize, reopened]
paths:
- "Containerfile.*"
- .github/workflows/images.yaml
workflow_dispatch:
inputs:
branch:
description: Branch to build (master, vX.Y)
required: true
default: master
meson-version:
description: Meson version to use
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
permissions:
packages: write
jobs:
image:
runs-on: ubuntu-latest
env:
CMAKE_VERSION: "3.23.3"
MESON_VERSION: "1.0.1"
REGISTRY: ghcr.io
strategy:
fail-fast: false
matrix:
image:
- almalinux-8
- almalinux-9
- cross-s390x
- fedora-37
- ubuntu-18.04
- ubuntu-20.04
- ubuntu-22.04
steps:
- name: Determine branch
id: determine-branch
run: |
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
echo "branch=$GITHUB_BASE_REF" >> "$GITHUB_OUTPUT"
elif [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
echo "branch=${{ github.event.inputs.branch }}" >> "$GITHUB_OUTPUT"
else
echo "branch=$GITHUB_REF_NAME" >> "$GITHUB_OUTPUT"
fi
- name: Update Meson version
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "MESON_VERSION=${{ github.event.inputs.meson-version }}" >> "$GITHUB_ENV"
- name: Export image
id: export-image
run: |
echo "image=$REGISTRY/$GITHUB_REPOSITORY/${{ matrix.image }}:${{ steps.determine-branch.outputs.branch }}" >> "$GITHUB_OUTPUT"
- name: Checkout ci-images
uses: actions/checkout@v4
- name: Checkout HSE
uses: actions/checkout@v4
with:
repository: hse-project/hse
path: hse
ref: ${{ steps.determine-branch.outputs.branch }}
- name: Checkout hse-java
uses: actions/checkout@v4
with:
repository: hse-project/hse-java
path: hse/subprojects/hse-java
ref: ${{ steps.determine-branch.outputs.branch }}
- name: Checkout hse-python
uses: actions/checkout@v4
with:
repository: hse-project/hse-python
path: hse/subprojects/hse-python
ref: ${{ steps.determine-branch.outputs.branch }}
- name: Cache Meson packagecache
uses: actions/cache@v3
with:
path: hse/subprojects/packagecache
key: meson-packagecache-${{ matrix.image }}-${{ steps.determine-branch.outputs.branch }}-${{ hashFiles('hse/subprojects/*.wrap') }}
- name: Export CROSS_ARCH
if: ${{ startsWith(matrix.image, 'cross') }}
run: |
tag=${{ matrix.image }}
echo "CROSS_ARCH=${tag##*-}" >> "$GITHUB_ENV"
- name: Export filename
id: export-filename
run: |
if [ -z "${CROSS_ARCH}" ]; then
echo "filename=Containerfile.${{ matrix.image }}" >> "$GITHUB_OUTPUT"
else
tag=${{ matrix.image }}
echo "filename=Containerfile.${tag%%-*}" >> "$GITHUB_OUTPUT"
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
uses: docker/build-push-action@v5
with:
context: ${{ github.workspace }}
file: ${{ steps.export-filename.outputs.filename }}
build-args: |
cmakeVersion=${{ env.CMAKE_VERSION }}
crossArch=${{ env.CROSS_ARCH }}
mesonVersion=${{ env.MESON_VERSION }}
load: true
tags: ${{ steps.export-image.outputs.image }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test
run: |
docker run --rm --env CI=$CI --env CROSS_ARCH=$CROSS_ARCH \
--interactive --workdir /root --volume $GITHUB_WORKSPACE:/root \
--user "$(id -u):$(id -g)" \
${{ steps.export-image.outputs.image }} \
./scripts/test.sh
- name: Login to the GitHub Container Registry
uses: docker/login-action@v3
if: ${{ github.event_name != 'pull_request' }}
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push to the GitHub Container Registry
uses: docker/build-push-action@v5
with:
context: ${{ github.workspace }}
file: ${{ steps.export-filename.outputs.filename }}
build-args: |
cmakeVersion=${{ env.CMAKE_VERSION }}
crossArch=${{ env.CROSS_ARCH }}
mesonVersion=${{ env.MESON_VERSION }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.export-image.outputs.image }}
cache-from: type=gha
cache-to: type=gha,mode=max
- uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: ${{ github.job }}-${{ matrix.image }}
path: |
hse/builddir/meson-logs/