Skip to content

Commit af49e2d

Browse files
committed
Add sync_group variable
1 parent 9728c5d commit af49e2d

File tree

5 files changed

+164
-16
lines changed

5 files changed

+164
-16
lines changed
Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,51 @@
11
---
22
name: Nightly package repository sync
3-
on:
4-
schedule:
5-
# Daily at 23:17
6-
- cron: '17 23 * * *'
3+
on: push
74
env:
85
ANSIBLE_FORCE_COLOR: True
6+
ANSIBLE_VAULT_PASSWORD_FILE: ${{ github.workspace }}/vault-pass
97
jobs:
8+
sync-matrix-build:
9+
name: Build package matrix of package repo sync jobs
10+
runs-on: arc-release-train-runner
11+
outputs:
12+
matrix: ${{ steps.matrix-build.outputs.matrix }}
13+
steps:
14+
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Install dependencies
19+
run: |
20+
sudo apt update
21+
sudo apt install wget
22+
23+
- name: Install YQ
24+
uses: dcarbone/[email protected]
25+
26+
- name: Create sync matrix
27+
id: matrix-build
28+
# Use YQ to make a list of all unique sync groups, and format as a GH
29+
# actions matrix
30+
run: |
31+
groups=$(yq -o=json -I=0 \
32+
'[.rpm_package_repos[] | .sync_group | select(.) ] | unique' \
33+
ansible/inventory/group_vars/all/package-repos)
34+
echo -n "matrix={\"sync_group\": " >> $GITHUB_OUTPUT
35+
echo -n $groups >> $GITHUB_OUTPUT
36+
echo "}" >> $GITHUB_OUTPUT
37+
1038
sync-matrix-run:
1139
name: Sync
40+
needs:
41+
- sync-matrix-build
1242
strategy:
13-
matrix:
14-
filter: ['rocky','(centos|rhel|epel|^docker|opensearch|grafana|rabbitmq|^treasuredata|elasticsearch)', 'jammy', 'focal', 'ubuntu_cloud_archive']
43+
matrix: ${{ fromJson(needs.sync-matrix-build.outputs.matrix) }}
1544
max-parallel: 1
1645
fail-fast: False
17-
uses: stackhpc/stackhpc-release-train/.github/workflows/package-sync.yml@main
46+
uses: stackhpc/stackhpc-release-train/.github/workflows/package-sync.yml@fix-nightly
1847
with:
1948
sync_ark: True
2049
sync_test: False
21-
filter: ${{ matrix.filter }}
50+
package_sync_group: ${{ matrix.sync_group }}
2251
secrets: inherit

.github/workflows/package-sync.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ on:
1111
description: Sync package repositories in Test Pulp
1212
type: boolean
1313
required: true
14-
filter:
15-
description: Space-separated list of regular expressions matching short_name of repositories to sync
14+
package_sync_group:
15+
description: String matching sync_group of repositories to sync
1616
type: string
17-
required: true
17+
required: false
1818
workflow_dispatch:
1919
inputs:
2020
sync_ark:
@@ -62,11 +62,13 @@ jobs:
6262
ansible/dev-pulp-repo-sync.yml \
6363
ansible/dev-pulp-repo-publication-cleanup.yml \
6464
ansible/dev-pulp-repo-publish.yml \
65+
-e package_sync_group="'$PACKAGE_SYNC_GROUP'" \
6566
-e deb_package_repo_filter="'$FILTER'" \
6667
-e rpm_package_repo_filter="'$FILTER'"
6768
retry_wait_seconds: 3600
6869
env:
6970
FILTER: ${{ inputs.filter }}
71+
PACKAGE_SYNC_GROUP: ${{ inputs.package_sync_group }}
7072

7173
package-sync-test:
7274
name: Sync package repositories in test
@@ -96,6 +98,7 @@ jobs:
9698
ansible/test-pulp-repo-publication-cleanup.yml \
9799
ansible/test-pulp-repo-publish.yml \
98100
-e deb_package_repo_filter="'$FILTER'" \
101+
-e deb_package_repo_filter="'$FILTER'" \
99102
-e rpm_package_repo_filter="'$FILTER'"
100103
retry_wait_seconds: 3600
101104
env:

ansible/filter_plugins/filters.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,25 @@
1515
import re
1616

1717

18-
def select_repos(repos, filter_string):
19-
"""Select repositories that match a filter string.
18+
def select_repos(repos, filter_string, package_sync_group):
19+
"""Select repositories that match a filter string and package sync group.
2020
2121
The filter string is a whitespace-separated list of regular expressions
2222
matching repository short names.
23+
24+
The package sync group is a string matching a repository sync group.
2325
"""
2426
if not filter_string:
2527
return repos
2628
regexes = filter_string.split()
2729
patterns = re.compile(r"|".join(regexes).join('()'))
28-
return [repo for repo in repos
30+
filtered_repos = [repo for repo in repos
2931
if "short_name" in repo and re.search(patterns, repo["short_name"])]
32+
if package_sync_group:
33+
return [repo for repo in filtered_repos
34+
if "sync_group" in repo and repo["sync_group"] == package_sync_group]
35+
else:
36+
return filtered_repos
3037

3138

3239
def select_images(images, filter_string):

0 commit comments

Comments
 (0)