Skip to content

Commit 4a7be88

Browse files
authored
fix(playbook): Retired files and local testing improvements (#455)
* chore(playbook): include more steps in the local test run * chore(playbook): auto recreate the work directory * fix(playbook): remove retired files * fix(template): Pull in a change from stackabletech/opa-operator#622 Otherwise it gets removed, like stackabletech/opa-operator#641 * refactor(template): Move local block into previous local block * chore(template): Revert nix formatting Also, see https://github.com/NixOS/nixfmt * fix(playbook): git config for dry-run Instead of using git config --global, make the git config commands local to each operator repository. This is then safe to run via test.sh (dry-run). * ci(generate_prs): Add dynamic run-name
1 parent 2a7dc83 commit 4a7be88

File tree

7 files changed

+29
-18
lines changed

7 files changed

+29
-18
lines changed

.github/workflows/generate_prs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
name: Generate Downstream PRs
33

4+
run-name: "Generate Downstream PRs (dry-run: ${{ inputs.dry-run }})"
5+
46
on:
57
workflow_dispatch:
68
inputs:

README.adoc

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

8686
=== Test changes locally
8787

88-
1. Create the directory `work` and run the `test.sh` script.
88+
1. Run the `test.sh` script.
89+
It will automatically delete and recreate a `work` directory.
8990
2. The changes can be examined with `git status`.
9091
When the pull request is later merged into the `main` branch then pull requests with these changes will be created automatically.
9192
3. Depending on the change, it makes sense to run the integration tests for all changed operators.

config/retired_files.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
retired_files:
66
- python/cargo_version.py
77
- python/requirements.txt
8-
- flake8 # replaced by ruff
8+
- .flake8 # replaced by ruff
9+
- .github/workflows/pr_reviewdog.yaml # replaced by pr_pre-commit.yaml

playbook/playbook.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@
1515
path: "{{ work_dir }}"
1616
state: directory
1717

18-
- name: Configure git author mail
19-
command:
20-
argv: [git, config, --global, user.email, "{{ author_mail }}"]
21-
22-
- name: Configure git author name
23-
command:
24-
argv: [git, config, --global, user.name, "{{ author_name }}"]
25-
2618
- name: Login to github
2719
command:
2820
argv: [gh, auth, login, --with-token]

playbook/update_repo.yaml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,15 @@
111111
register: git_change
112112
failed_when: git_change.rc == 0 # fail when there are no changes
113113

114+
- name: Configure git author mail
115+
command:
116+
argv: [git, config, user.email, "{{ author_mail }}"]
117+
chdir: "{{ work_dir }}/{{ operator.name }}"
114118

115-
# Check if anything was changed, if yes commit changes and create a pull request, otherwise skip rest of this play
116-
- name: "Operator [{{ operator.name }}] create PR if changes were performed"
117-
block:
118-
- name: "Operator [{{ operator.name }}] run 'git ls-remotes' to ensure that the branch {{ pr_branch_name }} doesn't exist"
119+
- name: Configure git author name
119120
command:
120-
argv: [git, ls-remote, --exit-code, --heads, "https://{{ gh_access_token }}@github.com/{{ operator.url }}", "{{ pr_branch_name }}"]
121+
argv: [git, config, user.name, "{{ author_name }}"]
121122
chdir: "{{ work_dir }}/{{ operator.name }}"
122-
register: branch_exists
123-
failed_when: branch_exists.rc != 2 # fail when branch exists
124123

125124
- name: "Operator [{{ operator.name }}] stage all changes"
126125
command:
@@ -129,9 +128,19 @@
129128

130129
- name: "Operator [{{ operator.name }}] commit changes"
131130
command:
132-
argv: [git, commit, -a, -m, "{{ commit_message }}"]
131+
argv: [git, commit, -m, "{{ commit_message }}"]
133132
chdir: "{{ work_dir }}/{{ operator.name }}"
134133

134+
# Fail if the remote branch exists, otherwise push changes and create a pull request
135+
- name: "Operator [{{ operator.name }}] create PR if changes were performed"
136+
block:
137+
- name: "Operator [{{ operator.name }}] run 'git ls-remotes' to ensure that the branch {{ pr_branch_name }} doesn't exist"
138+
command:
139+
argv: [git, ls-remote, --exit-code, --heads, "https://{{ gh_access_token }}@github.com/{{ operator.url }}", "{{ pr_branch_name }}"]
140+
chdir: "{{ work_dir }}/{{ operator.name }}"
141+
register: branch_exists
142+
failed_when: branch_exists.rc != 2 # fail when branch exists
143+
135144
- name: "Operator [{{ operator.name }}] push changes to branch {{ pr_branch_name }}"
136145
command:
137146
argv: [git, push, --set-upstream, origin, "{{ pr_branch_name }}"]

template/default.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
stackable-secret-operator = attrs: {
1717
buildInputs = [ pkgs.protobuf pkgs.rustfmt ];
1818
};
19+
stackable-opa-user-info-fetcher = attrs: {
20+
# TODO: why is this not pulled in via libgssapi-sys?
21+
buildInputs = [ pkgs.krb5 ];
22+
};
1923
krb5-sys = attrs: {
2024
nativeBuildInputs = [ pkgs.pkg-config ];
2125
buildInputs = [ pkgs.krb5 ];

test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/usr/bin/env bash
22

3+
rm -fr work || true
4+
mkdir -p work
35
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)