Skip to content

Commit fcfb9ca

Browse files
author
Konrad Kleine
committed
Update (base update)
[ghstack-poisoned]
1 parent 924a65e commit fcfb9ca

9 files changed

Lines changed: 923 additions & 558 deletions

File tree

.github/workflows/check-snapshots.yml

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ on:
1414
required: true
1515
type: string
1616
lookback_days:
17-
description: "A JSON list of integers for how many days to look back. \"[0]\" means just today."
18-
default: "[0]"
17+
description: "A space separated list of integers for how many days to look back. \"0\" means just today."
18+
default: "0"
1919
type: string
2020
strategy:
2121
description: 'build strategy'
@@ -39,11 +39,25 @@ jobs:
3939
mymatrix: ${{ steps.set-matrix.outputs.matrix }}
4040
steps:
4141
- uses: actions/checkout@v4
42-
- uses: ./.github/actions/generate-matrix
42+
- uses: ./.github/actions/prepare-python
43+
- name: Setup Copr config file
44+
env:
45+
# You need to have those secrets in your repo.
46+
# See also: https://copr.fedorainfracloud.org/api/.
47+
COPR_CONFIG: ${{ secrets.COPR_CONFIG }}
48+
run: |
49+
mkdir -p ~/.config
50+
echo "$COPR_CONFIG" > ~/.config/copr
51+
- name: generate-matrix
4352
id: set-matrix
44-
with:
45-
strategy: ${{ inputs.strategy }}
46-
lookback_days: ${{ inputs.lookback_days }}
53+
run: |
54+
# shellcheck disable=SC2086
55+
echo "matrix=$(python3 \
56+
snapshot_manager/main.py github-matrix \
57+
--strategy ${{ inputs.strategy }} \
58+
--lookback-days ${{ inputs.lookback_days }} \
59+
)" >> $GITHUB_OUTPUT
60+
4761
check-snapshot:
4862
if: github.repository_owner == 'fedora-llvm-team'
4963
needs: generate-matrix
@@ -57,10 +71,10 @@ jobs:
5771
env:
5872
# You need to have those secrets in your repo.
5973
# See also: https://copr.fedorainfracloud.org/api/.
60-
COPR_CONFIG_FILE: ${{ secrets.COPR_CONFIG }}
74+
COPR_CONFIG: ${{ secrets.COPR_CONFIG }}
6175
run: |
6276
mkdir -p ~/.config
63-
echo "$COPR_CONFIG_FILE" > ~/.config/copr
77+
echo "$COPR_CONFIG" > ~/.config/copr
6478
6579
- name: Install Copr CLI
6680
if: github.event_name != 'workflow_dispatch' || (matrix.today_minus_n_days == 0 && inputs.strategy == matrix.name)
@@ -75,18 +89,11 @@ jobs:
7589

7690
- name: "Check day (today minus ${{matrix.today_minus_n_days}} days)"
7791
if: github.event_name != 'workflow_dispatch' || (matrix.today_minus_n_days == 0 && inputs.strategy == matrix.name)
78-
shell: bash -e {0}
7992
env:
8093
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8194
TESTING_FARM_API_TOKEN_PUBLIC_RANCH: ${{ secrets.TESTING_FARM_API_TOKEN_PUBLIC_RANCH }}
8295
TESTING_FARM_API_TOKEN_REDHAT_RANCH: ${{ secrets.TESTING_FARM_API_TOKEN_REDHAT_RANCH }}
8396
run: |
84-
extra_args=""
85-
86-
if [[ -n "${{ matrix.chroot_pattern }}" ]]; then
87-
extra_args="${extra_args} --chroot-pattern ${{matrix.chroot_pattern}}"
88-
fi
89-
9097
if [[ "${{github.event_name}}" == "workflow_dispatch" ]]; then
9198
yyyymmdd=${{inputs.yyyymmdd}}
9299
else
@@ -96,12 +103,6 @@ jobs:
96103
# shellcheck disable=SC2086
97104
python3 snapshot_manager/main.py \
98105
--github-repo "${GITHUB_REPOSITORY}" \
99-
--github-token-env GITHUB_TOKEN \
100-
check ${extra_args} \
101-
--maintainer-handle ${{matrix.maintainer_handle}} \
102-
--packages llvm \
103-
--build-strategy ${{matrix.name}} \
104-
--copr-ownername ${{matrix.copr_ownername}} \
105-
--copr-project-tpl ${{matrix.copr_project_tpl}} \
106-
--copr-monitor-tpl ${{matrix.copr_monitor_tpl}} \
106+
check \
107+
--strategy ${{matrix.name}} \
107108
--yyyymmdd "$yyyymmdd"

.github/workflows/fedora-copr-build.yml

Lines changed: 50 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,23 @@ jobs:
2626
mymatrix: ${{ steps.set-matrix.outputs.matrix }}
2727
steps:
2828
- uses: actions/checkout@v4
29-
- uses: ./.github/actions/generate-matrix
29+
- uses: ./.github/actions/prepare-python
30+
- name: Setup Copr config file
31+
env:
32+
# You need to have those secrets in your repo.
33+
# See also: https://copr.fedorainfracloud.org/api/.
34+
COPR_CONFIG: ${{ secrets.COPR_CONFIG }}
35+
run: |
36+
mkdir -p ~/.config
37+
echo "$COPR_CONFIG" > ~/.config/copr
38+
- name: generate-matrix
3039
id: set-matrix
31-
with:
32-
strategy: ${{ inputs.strategy }}
33-
lookback_days: "[0]"
40+
run: |
41+
# shellcheck disable=SC2086
42+
echo "matrix=$(python3 \
43+
snapshot_manager/main.py github-matrix \
44+
--strategy ${{ inputs.strategy }} \
45+
)" >> $GITHUB_OUTPUT
3446
3547
build-on-copr:
3648
if: github.repository_owner == 'fedora-llvm-team'
@@ -41,97 +53,74 @@ jobs:
4153
runs-on: ubuntu-latest
4254
container: fedora:41
4355
steps:
56+
- uses: actions/checkout@v4
57+
- uses: ./.github/actions/prepare-python
58+
4459
- name: Setup Copr config file
4560
env:
4661
# You need to have those secrets in your repo.
4762
# See also: https://copr.fedorainfracloud.org/api/.
48-
COPR_CONFIG_FILE: ${{ secrets.COPR_CONFIG }}
63+
COPR_CONFIG: ${{ secrets.COPR_CONFIG }}
4964
run: |
5065
mkdir -p ~/.config
51-
echo "$COPR_CONFIG_FILE" > ~/.config/copr
66+
echo "$COPR_CONFIG" > ~/.config/copr
5267
5368
- name: Install Copr CLI and required tools
5469
run: |
5570
dnf install -y copr-cli make bzip2 rpm-build pcre2-tools jq
5671
57-
- uses: actions/checkout@v4
58-
59-
- name: "Variables and functions"
60-
shell: bash -e {0}
72+
- name: "Variables"
6173
run: |
62-
source scripts/functions.sh
63-
[[ -n "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
64-
6574
today=$(date +%Y%m%d)
6675
yesterday=$(date -d "${today} -1 day" +%Y%m%d)
6776
68-
chroots="$(get_chroots)"
69-
7077
username=@fedora-llvm-team
7178
{
7279
echo "username=$username"
73-
echo "chroots=$chroots"
74-
echo "all_chroots=$all_chroots"
80+
echo "yesterday=$yesterday"
7581
echo "project_today=${{ matrix.copr_ownername }}/${{ matrix.copr_project_tpl }}" | sed "s/YYYYMMDD/$today/"
7682
echo "project_yesterday=${{ matrix.copr_ownername }}/${{ matrix.copr_project_tpl }}" | sed "s/YYYYMMDD/$yesterday/"
7783
echo "project_target=${{ matrix.copr_target_project }}"
7884
} >> "$GITHUB_ENV"
7985
8086
- name: "Check for Copr projects existence (yesterday, today, target)"
81-
shell: bash -e {0}
8287
run: |
83-
source scripts/functions.sh
84-
[[ -n "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
88+
# Checks if a copr project exists
89+
function copr_project_exists(){
90+
local project="$1";
91+
copr get "$project" > /dev/null 2>&1
92+
}
93+
94+
# Check general availability of projects
95+
copr_project_exists ${{ env.project_today }} && todays_project_exists=yes
96+
copr_project_exists ${{ env.project_yesterday }} && yesterdays_project_exists=yes
97+
copr_project_exists ${{ env.project_target }} && target_project_exists=yes
8598
8699
# Check if yesterday's project exists and all builds succeeded
87-
yesterdays_project_exists=$(project_exists ${{ env.project_yesterday }})
88-
if [[ "$yesterdays_project_exists" == "true" ]]; then
89-
if ! has_all_good_builds ${{env.project_yesterday}}; then
90-
yesterdays_project_exists=false
100+
if [[ "$yesterdays_project_exists" == "yes" ]]; then
101+
if ! python3 snapshot_manager/main.py has-all-good-builds --strategy ${{matrix.name}} --yyyymmdd ${{env.yesterday}}; then
102+
yesterdays_project_exists=no
91103
fi
92104
fi
93105
94106
{
95-
echo "todays_project_exists=$(project_exists ${{ env.project_today }})"
107+
echo "todays_project_exists=$todays_project_exists"
96108
echo "yesterdays_project_exists=$yesterdays_project_exists"
97-
echo "target_project_exists=$(project_exists ${{ env.project_target }})"
109+
echo "target_project_exists=$target_project_exists"
98110
} >> "$GITHUB_ENV"
99111
100-
- name: "Canceling active builds (if any) in today's Copr project before recreating it: ${{ env.project_today }}"
101-
if: ${{ env.todays_project_exists == 'true' }}
102-
shell: bash -e {0}
103-
run: |
104-
source scripts/functions.sh
105-
[[ -n "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
106-
107-
build_ids=""
108-
for build_id in $(get_active_build_ids ${{ env.project_today }}); do
109-
echo "Canceling build with ID $build_id"
110-
copr cancel "$build_id"
111-
build_ids="$build_ids $build_id"
112-
done
113-
if [[ "$build_ids" != "" ]]; then
114-
echo "Waiting for build IDs to be canceled: $build_ids"
115-
copr watch-build "$build_ids" || true
116-
fi
117-
118-
- name: "Deleting today's Copr project before recreating it: ${{ env.project_today }}"
119-
if: ${{ env.todays_project_exists == 'true' }}
120-
shell: bash -e {0}
112+
- name: "Canceling active builds (if any) in today's Copr project and deleting it: ${{ env.project_today }}"
113+
if: ${{ env.todays_project_exists == 'yes' }}
121114
run: |
122-
source scripts/functions.sh
123-
[[ -n "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
124-
125-
copr delete ${{ env.project_today }}
115+
python3 snapshot_manager/main.py \
116+
delete-project \
117+
--strategy ${{matrix.name}} \
118+
--yyyymmdd "$yyyymmdd"
126119
127120
- name: "Create today's Copr project: ${{ env.project_today }}"
128-
shell: bash -e {0}
129121
run: |
130-
source scripts/functions.sh
131-
[[ -n "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
132-
133122
# shellcheck disable=SC2207
134-
chroot_opts=($(for c in ${{ env.chroots }}; do echo -n " --chroot $c "; done))
123+
chroot_opts=($(for c in ${{ matrix.chroots }}; do echo -n " --chroot $c "; done))
135124
136125
copr create \
137126
--instructions "$(cat project-instructions.md)" \
@@ -146,12 +135,8 @@ jobs:
146135
"${chroot_opts[@]}" "${{ env.project_today }}"
147136
148137
- name: "Enable snapshot_build build condition for all and swig:4.0 module in RHEL 8 build chroots (if any)"
149-
shell: bash -e {0}
150138
run: |
151-
source scripts/functions.sh
152-
[[ -n "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
153-
154-
for chroot in ${{ env.chroots }}; do
139+
for chroot in ${{ matrix.chroots }}; do
155140
copr edit-chroot --rpmbuild-with "snapshot_build" "${{ env.project_today }}/$chroot"
156141
if [[ "$chroot" == rhel-8-* ]]; then
157142
copr edit-chroot --modules "swig:4.0" "${{ env.project_today }}/$chroot"
@@ -162,11 +147,7 @@ jobs:
162147
done
163148
164149
- name: "Create today's package"
165-
shell: bash -e {0}
166150
run: |
167-
source scripts/functions.sh
168-
[[ -n "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
169-
170151
copr add-package-scm \
171152
--clone-url ${{ matrix.clone_url }} \
172153
--commit ${{ matrix.clone_ref }} \
@@ -177,12 +158,8 @@ jobs:
177158
"${{ env.project_today }}"
178159
179160
- name: "Build llvm package"
180-
shell: bash -e {0}
181161
run: |
182-
source scripts/functions.sh
183-
[[ -n "${{ matrix.extra_script_file }}" ]] && source ${{ matrix.extra_script_file }}
184-
185-
for chroot in ${{ env.chroots }}; do
162+
for chroot in ${{ matrix.chroots }}; do
186163
copr build-package \
187164
--timeout $((30*3600)) \
188165
--nowait \
@@ -193,22 +170,22 @@ jobs:
193170
done
194171
195172
- name: "Delete target Copr project at ${{ env.project_target }} before forking to it"
196-
if: ${{ env.yesterdays_project_exists == 'true' && env.target_project_exists == 'true' }}
173+
if: ${{ env.yesterdays_project_exists == 'yes' && env.target_project_exists == 'yes' }}
197174
run: |
198175
copr delete "${{ env.project_target }}"
199176
# Give Copr some time to process the deletion, to avoid race conditions with forking.
200177
# TODO: Keep and eye on https://github.com/fedora-copr/copr/issues/2698 if there's a better way to handle this.
201178
sleep 1m
202179
203180
- name: "Fork Copr project from ${{ env.project_yesterday }} to ${{ env.project_target }}"
204-
if: ${{ env.yesterdays_project_exists == 'true' }}
181+
if: ${{ env.yesterdays_project_exists == 'yes' }}
205182
run: |
206183
copr fork --confirm ${{ env.project_yesterday }} ${{ env.project_target }}
207184
copr modify --delete-after-days -1 --unlisted-on-hp off ${{ env.project_target }}
208185
209186
- name: "Regenerate repos for target project ${{ env.project_target }}"
210187
# If yesterday's project didn't exist, we haven't forked and so we don't
211188
# need to regenerate the repos.
212-
if: ${{ env.yesterdays_project_exists == 'true' }}
189+
if: ${{ env.yesterdays_project_exists == 'yes' }}
213190
run: |
214191
copr regenerate-repos ${{ env.project_target }}

.github/workflows/retest-chroots-on-testing-farm.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ jobs:
8484
run: |
8585
python3 snapshot_manager/main.py \
8686
--github-repo "${GITHUB_REPOSITORY}" \
87-
--github-token-env GITHUB_TOKEN \
8887
retest \
8988
--trigger-comment-id ${{ github.event.comment.id }} \
9089
--issue-number ${{ github.event.issue.number }} \

0 commit comments

Comments
 (0)