Skip to content

Commit 0baafec

Browse files
committed
Add sync_group variable
1 parent 9728c5d commit 0baafec

File tree

5 files changed

+159
-15
lines changed

5 files changed

+159
-15
lines changed
Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,47 @@
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 YQ
19+
uses: dcarbone/[email protected]
20+
21+
- name: Create sync matrix
22+
id: matrix-build
23+
# Use YQ to make a list of all unique sync groups, and format as a GH
24+
# actions matrix
25+
run: |
26+
groups=$(yq -o=json -I=0 \
27+
'[.rpm_package_repos[] | .sync_group | select(.) ] | unique' \
28+
ansible/inventory/group_vars/all/package-repos)
29+
echo -n "matrix={\"sync_group\": " >> $GITHUB_OUTPUT
30+
echo -n $groups >> $GITHUB_OUTPUT
31+
echo "}" >> $GITHUB_OUTPUT
32+
1033
sync-matrix-run:
1134
name: Sync
35+
needs:
36+
- sync-matrix-build
1237
strategy:
1338
matrix:
14-
filter: ['rocky','(centos|rhel|epel|^docker|opensearch|grafana|rabbitmq|^treasuredata|elasticsearch)', 'jammy', 'focal', 'ubuntu_cloud_archive']
39+
matrix: ${{ fromJson(needs.sync-matrix-build.outputs.matrix) }}
1540
max-parallel: 1
1641
fail-fast: False
17-
uses: stackhpc/stackhpc-release-train/.github/workflows/package-sync.yml@main
42+
uses: stackhpc/stackhpc-release-train/.github/workflows/package-sync.yml@fix-nightly
1843
with:
1944
sync_ark: True
2045
sync_test: False
21-
filter: ${{ matrix.filter }}
46+
package_sync_group: ${{ matrix.sync_group }}
2247
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)