@@ -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 }}
0 commit comments