Skip to content

Commit c546343

Browse files
authored
Restore repository indexing (#532)
* Slim down GH action to use the same code path for dry and wet runs * Let Ansible handle repository filtering This fixes repository indexing (fixes #411), and makes config/repositories.yaml authoritative (again) on the operator configuration. * Try to fix GH workflow syntax, maybe? * Document sharding for the local test setup * .yml is not .yaml * Satisfy pre-commit
1 parent 0fd18fc commit c546343

File tree

5 files changed

+37
-113
lines changed

5 files changed

+37
-113
lines changed

.github/workflows/generate_prs.yml

Lines changed: 32 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -27,83 +27,26 @@ jobs:
2727
runs-on: ubuntu-latest
2828
strategy:
2929
fail-fast: ${{ inputs.fail-fast }}
30-
# If you add a new repository here, also add it to config/repositories.yaml
3130
matrix:
31+
# This should be the list of repository names from config/repositories.yaml:
32+
# yq '.repositories | map(.name)' config/repositories.yaml
3233
repository:
33-
- name: airflow-operator
34-
pretty_string: Apache Airflow
35-
product_string: airflow
36-
url: stackabletech/airflow-operator.git
37-
- name: commons-operator
38-
include_productconfig: false
39-
has_product: false
40-
pretty_string: Stackable Commons
41-
product_string: commons
42-
url: stackabletech/commons-operator.git
43-
- name: druid-operator
44-
pretty_string: Apache Druid
45-
product_string: druid
46-
url: stackabletech/druid-operator.git
47-
- name: hbase-operator
48-
pretty_string: Apache HBase
49-
product_string: hbase
50-
url: stackabletech/hbase-operator.git
51-
- name: hdfs-operator
52-
pretty_string: Apache HDFS
53-
product_string: hdfs
54-
url: stackabletech/hdfs-operator.git
55-
- name: hive-operator
56-
pretty_string: Apache Hive
57-
product_string: hive
58-
url: stackabletech/hive-operator.git
59-
- name: kafka-operator
60-
pretty_string: Apache Kafka
61-
product_string: kafka
62-
url: stackabletech/kafka-operator.git
63-
- name: nifi-operator
64-
pretty_string: Apache NiFi
65-
product_string: nifi
66-
url: stackabletech/nifi-operator.git
67-
- name: listener-operator
68-
include_productconfig: false
69-
has_product: false
70-
pretty_string: Stackable Listener Operator
71-
product_string: listener-operator
72-
run_as: custom
73-
url: stackabletech/listener-operator.git
74-
- name: opa-operator
75-
extra_crates:
76-
- stackable-opa-bundle-builder
77-
pretty_string: OpenPolicyAgent
78-
product_string: opa
79-
url: stackabletech/opa-operator.git
80-
- name: opensearch-operator
81-
pretty_string: OpenSearch
82-
product_string: opensearch
83-
url: stackabletech/opensearch-operator.git
84-
- name: secret-operator
85-
include_productconfig: false
86-
has_product: false
87-
pretty_string: Stackable Secret Operator
88-
product_string: secret-operator
89-
run_as: custom
90-
url: stackabletech/secret-operator.git
91-
- name: spark-k8s-operator
92-
pretty_string: Apache Spark-on-Kubernetes
93-
product_string: spark-k8s
94-
url: stackabletech/spark-k8s-operator.git
95-
- name: superset-operator
96-
pretty_string: Apache Superset
97-
product_string: superset
98-
url: stackabletech/superset-operator.git
99-
- name: trino-operator
100-
pretty_string: Trino
101-
product_string: trino
102-
url: stackabletech/trino-operator.git
103-
- name: zookeeper-operator
104-
pretty_string: Apache ZooKeeper
105-
product_string: zookeeper
106-
url: stackabletech/zookeeper-operator.git
34+
- airflow-operator
35+
- commons-operator
36+
- druid-operator
37+
- hbase-operator
38+
- hdfs-operator
39+
- hive-operator
40+
- kafka-operator
41+
- nifi-operator
42+
- listener-operator
43+
- opa-operator
44+
- opensearch-operator
45+
- secret-operator
46+
- spark-k8s-operator
47+
- superset-operator
48+
- trino-operator
49+
- zookeeper-operator
10750
steps:
10851
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
10952
with:
@@ -113,10 +56,10 @@ jobs:
11356
env:
11457
DEBIAN_FRONTEND: noninteractive
11558
run: |
116-
sudo apt update && \
117-
sudo apt install -y software-properties-common && \
118-
sudo apt-add-repository ppa:ansible/ansible -y && \
119-
sudo apt install -y ansible
59+
sudo apt update && \
60+
sudo apt install -y software-properties-common && \
61+
sudo apt-add-repository ppa:ansible/ansible -y && \
62+
sudo apt install -y ansible
12063
12164
# NOTE (@NickLarsenNZ): This could be removed in favor of nix-shell and rrbutani/use-nix-shell-action
12265
- name: Install deps for operators
@@ -148,36 +91,18 @@ jobs:
14891
echo "AUTHOR=stackabletech/developers"
14992
echo "REASON=Daily run triggered" >> "$GITHUB_ENV"
15093
151-
- name: Overwrite repositories.yaml for ${{ matrix.repository.name }}
152-
run: |
153-
cat >config/repositories.yaml <<CONFIG
154-
---
155-
repositories:
156-
- ${{ toJSON(matrix.repository) }}
157-
CONFIG
158-
159-
# For debugging
160-
cat config/repositories.yaml
161-
162-
# Generate PRs
16394
- name: Run playbook
164-
if: ${{ !inputs.dry-run }}
16595
env:
16696
CUSTOM_PR_TITLE: ${{ inputs.custom-pr-title }}
16797
GH_ACCESS_TOKEN: ${{ secrets.gh_access_token }}
98+
REPOSITORY: ${{ matrix.repository }}
99+
# tags local excludes all actions that actually generate PRs
100+
DRY_RUN_FLAGS: ${{ inputs.dry-run && '--tags=local' || '' }}
101+
# shellsheck disable=SC2086
168102
run: |
169-
# Funnel via JSON to ensure that values are escaped properly
170-
# Check if custom PR title is set. If so, insert it into the extra vars
171-
if [ -n "$CUSTOM_PR_TITLE" ]; then
172-
echo '{}' | jq '{commit_hash: $ENV.GITHUB_SHA, author: $ENV.AUTHOR, reason: $ENV.REASON, custom_pr_title: $ENV.CUSTOM_PR_TITLE, base_dir: $pwd, gh_access_token: $ENV.GH_ACCESS_TOKEN}' --arg pwd "$(pwd)" > vars.json
173-
else
174-
echo '{}' | jq '{commit_hash: $ENV.GITHUB_SHA, author: $ENV.AUTHOR, reason: $ENV.REASON, base_dir: $pwd, gh_access_token: $ENV.GH_ACCESS_TOKEN}' --arg pwd "$(pwd)" > vars.json
175-
fi
176-
ansible-playbook playbook/playbook.yaml --extra-vars "@vars.json"
177-
178-
# Do Not Generate PRs
179-
- name: Run playbook (dry-run)
180-
if: ${{ inputs.dry-run }}
181-
run: ./test.sh
182-
env:
183-
GH_ACCESS_TOKEN: ""
103+
echo '{}' | jq '{commit_hash: $ENV.GITHUB_SHA, author: $ENV.AUTHOR, reason: $ENV.REASON, custom_pr_title: $ENV.CUSTOM_PR_TITLE, base_dir: $pwd, gh_access_token: $ENV.GH_ACCESS_TOKEN, shard_repositories: [$ENV.REPOSITORY]} | with_entries(select(.value != null and .value != ""))' --arg pwd "$(pwd)" > vars.json
104+
# $DRY_RUN_FLAGS is intentionally not quoted, since we need to avoid
105+
# passing an argument if we're not in dry mode.
106+
# This is safe, since it always has one of two hard-coded values.
107+
# shellcheck disable=SC2086
108+
ansible-playbook playbook/playbook.yaml --extra-vars "@vars.json" $DRY_RUN_FLAGS

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Consult the section above to learn more about the structure of the template.
8585

8686
=== Test changes locally
8787

88-
1. Run the `test.sh` script.
88+
1. Run the `test.sh` script. To limit the run to a single operator, add `--extra-vars "shard_repositories=['nifi-operator']"` (or your choice of operator).
8989
It will automatically delete and recreate a `work` directory.
9090
2. The changes can be examined with `git status`.
9191
When the pull request is later merged into the `main` branch then pull requests with these changes will be created automatically.

config/repositories.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# This file exists just for the purpose of running test.sh locally.
2-
# The GH workflow generate_prs.yml will overwrite it with the contents if the
3-
# matrix run.
4-
# If you add a new repository here, you also need to add it to that workflow file.
1+
# If you add a new repository here, you also need to add it to the list of
2+
# repositories in ../.github/workflows/generate_prs.yml.
53
---
64
repositories:
75
- name: airflow-operator

playbook/playbook.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
- name: Update repositories from templates
2626
include_tasks: "update_repo.yaml"
27+
when: shard_repositories is undefined or operator.name in shard_repositories
2728
with_items: "{{ repositories }}"
2829
loop_control:
2930
loop_var: operator

test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
rm -fr work || true
44
mkdir -p work
5-
ansible-playbook playbook/playbook.yaml --tags "local" --extra-vars "gh_access_token=unneeded base_dir=$(pwd) commit_hash=12345 reason='original message'"
5+
ansible-playbook playbook/playbook.yaml --tags="local" --extra-vars "gh_access_token=unneeded base_dir=$(pwd) commit_hash=12345 reason='original message'" "$@"

0 commit comments

Comments
 (0)