-
Notifications
You must be signed in to change notification settings - Fork 8
224 lines (193 loc) · 8.85 KB
/
fedora-copr-build.yml
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
222
223
224
name: "Build daily LLVM snapshots on Copr"
on:
schedule:
# Everyday at 00:45am
# See https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule
- cron: "45 0 * * *"
workflow_dispatch:
inputs:
strategy:
description: 'build strategy'
required: true
type: choice
default: all
options:
- all
- big-merge
- pgo
jobs:
generate-matrix:
if: github.repository_owner == 'fedora-llvm-team'
runs-on: ubuntu-latest
outputs:
mymatrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/generate-matrix
id: set-matrix
with:
strategy: ${{ inputs.strategy }}
lookback_days: "[0]"
build-on-copr:
if: github.repository_owner == 'fedora-llvm-team'
needs: generate-matrix
strategy:
fail-fast: false
matrix: ${{fromJson(needs.generate-matrix.outputs.mymatrix)}}
runs-on: ubuntu-latest
container: fedora:41
steps:
- name: Setup Copr config file
env:
# You need to have those secrets in your repo.
# See also: https://copr.fedorainfracloud.org/api/.
COPR_CONFIG_FILE: ${{ secrets.COPR_CONFIG }}
run: |
mkdir -p ~/.config
printf "$COPR_CONFIG_FILE" > ~/.config/copr
- name: Install Copr CLI and required tools
run: |
dnf install -y copr-cli make bzip2 rpm-build pcre2-tools jq
- uses: actions/checkout@v4
- name: "Variables and functions"
shell: bash -e {0}
run: |
source scripts/functions.sh
[[ ! -z "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
today=`date +%Y%m%d`
yesterday=`date -d "${today} -1 day" +%Y%m%d`
packages="`get_packages`"
chroots="`get_chroots`"
username=@fedora-llvm-team
echo "username=$username" >> $GITHUB_ENV
echo "packages=$packages" >> $GITHUB_ENV
echo "chroots=$chroots" >> $GITHUB_ENV
echo "all_chroots=$all_chroots" >> $GITHUB_ENV
echo "project_today=${{ matrix.copr_ownername }}/${{ matrix.copr_project_tpl }}" | sed "s/YYYYMMDD/$today/" >> $GITHUB_ENV
echo "project_yesterday=${{ matrix.copr_ownername }}/${{ matrix.copr_project_tpl }}" | sed "s/YYYYMMDD/$yesterday/" >> $GITHUB_ENV
echo "project_target=${{ matrix.copr_target_project }}" >> $GITHUB_ENV
- name: "Check for Copr projects existence (yesterday, today, target)"
shell: bash -e {0}
run: |
source scripts/functions.sh
[[ ! -z "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
# Check if yesterday's project exists and all builds succeeded
yesterdays_project_exists=`project_exists ${{ env.project_yesterday }}`
if [[ "$yesterdays_project_exists" == "true" ]]; then
if ! has_all_good_builds ${{env.project_yesterday}}; then
yesterdays_project_exists=false
fi
fi
echo "todays_project_exists=`project_exists ${{ env.project_today }}`" >> $GITHUB_ENV
echo "yesterdays_project_exists=$yesterdays_project_exists" >> $GITHUB_ENV
echo "target_project_exists=`project_exists ${{ env.project_target }}`" >> $GITHUB_ENV
- name: "Canceling active builds (if any) in today's Copr project before recreating it: ${{ env.project_today }}"
if: ${{ env.todays_project_exists == 'true' }}
shell: bash -e {0}
run: |
source scripts/functions.sh
[[ ! -z "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
build_ids=""
for build_id in `get_active_build_ids ${{ env.project_today }}`; do
echo "Canceling build with ID $build_id"
copr cancel $build_id
build_ids="$build_ids $build_id"
done
if [[ "$build_ids" != "" ]]; then
echo "Waiting for build IDs to be canceled: $build_ids"
copr watch-build $build_ids || true
fi
- name: "Deleting today's Copr project before recreating it: ${{ env.project_today }}"
if: ${{ env.todays_project_exists == 'true' }}
shell: bash -e {0}
run: |
source scripts/functions.sh
[[ ! -z "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
copr delete ${{ env.project_today }}
- name: "Create today's Copr project: ${{ env.project_today }}"
shell: bash -e {0}
run: |
source scripts/functions.sh
[[ ! -z "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
chroot_opts=`for c in ${{ env.chroots }}; do echo -n " --chroot $c "; done`
copr create \
--instructions "`cat project-instructions.md`" \
--description "`cat project-description.md`" \
--unlisted-on-hp on \
--enable-net on \
--runtime-repo-dependency "https://download.copr.fedorainfracloud.org/results/%40fedora-llvm-team/llvm-compat-packages/\$distname-\$releasever-\$basearch" \
--multilib on \
--appstream off \
--delete-after-days 32 \
--module-hotfixes on \
$chroot_opts "${{ env.project_today }}"
- name: "Enable snapshot_build build condition for all and swig:4.0 module in RHEL 8 build chroots (if any)"
shell: bash -e {0}
run: |
source scripts/functions.sh
[[ ! -z "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
for chroot in ${{ env.chroots }}; do
copr edit-chroot --rpmbuild-with "snapshot_build" ${{ env.project_today }}/$chroot
if [[ "$chroot" == rhel-8-* ]]; then
copr edit-chroot --modules "swig:4.0" ${{ env.project_today }}/$chroot
fi
# Dump chroot information after all modification
copr get-chroot ${{ env.project_today }}/$chroot
done
- name: "Create today's packages: ${{ env.packages }}"
shell: bash -e {0}
run: |
source scripts/functions.sh
[[ ! -z "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
for pkg in ${{ env.packages }}; do
clone_url=`echo "${{ matrix.clone_url_tpl }}" | sed "s/PKG/$pkg/"`
copr add-package-scm \
--clone-url ${clone_url} \
--commit ${{ matrix.clone_ref }} \
--spec ${pkg}.spec \
--type git \
--method make_srpm \
--name ${pkg} \
"${{ env.project_today }}"
done
- name: "Build packages in chroot batches in this order: ${{ env.packages }}"
shell: bash -e {0}
run: |
source scripts/functions.sh
[[ ! -z "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
for chroot in ${{ env.chroots }}; do
# Start a new batch
after_build_id=""
for pkg in ${{ env.packages }}; do
if ! is_package_supported_by_chroot "${pkg}" "${chroot}"; then
echo "Package '${pkg}' is not supported by chroot: ${chroot}";
else
copr build-package \
--timeout $((30*3600)) \
--nowait \
--name $pkg ${after_build_id} \
--chroot ${chroot} \
${{ env.project_today }} \
| tee ${pkg}.log
after_build_id="--after-build-id `cat ${pkg}.log | grep -Po 'Created builds: \K(\d+)'`"
fi
done
done
- name: "Delete target Copr project at ${{ env.project_target }} before forking to it"
if: ${{ env.yesterdays_project_exists == 'true' && env.target_project_exists == 'true' }}
run: |
copr delete "${{ env.project_target }}"
# Give Copr some time to process the deletion, to avoid race conditions with forking.
# TODO: Keep and eye on https://github.com/fedora-copr/copr/issues/2698 if there's a better way to handle this.
sleep 1m
- name: "Fork Copr project from ${{ env.project_yesterday }} to ${{ env.project_target }}"
if: ${{ env.yesterdays_project_exists == 'true' }}
run: |
copr fork --confirm ${{ env.project_yesterday }} ${{ env.project_target }}
copr modify --delete-after-days -1 --unlisted-on-hp off ${{ env.project_target }}
- name: "Regenerate repos for target project ${{ env.project_target }}"
# If yesterday's project didn't exist, we haven't forked and so we don't
# need to regenerate the repos.
if: ${{ env.yesterdays_project_exists == 'true' }}
run: |
copr regenerate-repos ${{ env.project_target }}