Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(playbook): Retired files and local testing improvements #455

Merged
merged 8 commits into from
Oct 29, 2024
Merged
2 changes: 2 additions & 0 deletions .github/workflows/generate_prs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
name: Generate Downstream PRs

run-name: "Generate Downstream PRs (dry-run: ${{ inputs.dry-run }})"

on:
workflow_dispatch:
inputs:
Expand Down
3 changes: 2 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ Consult the section above to learn more about the structure of the template.

=== Test changes locally

1. Create the directory `work` and run the `test.sh` script.
1. Run the `test.sh` script.
It will automatically delete and recreate a `work` directory.
2. The changes can be examined with `git status`.
When the pull request is later merged into the `main` branch then pull requests with these changes will be created automatically.
3. Depending on the change, it makes sense to run the integration tests for all changed operators.
Expand Down
3 changes: 2 additions & 1 deletion config/retired_files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
retired_files:
- python/cargo_version.py
- python/requirements.txt
- flake8 # replaced by ruff
- .flake8 # replaced by ruff
- .github/workflows/pr_reviewdog.yaml # replaced by pr_pre-commit.yaml
8 changes: 0 additions & 8 deletions playbook/playbook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@
path: "{{ work_dir }}"
state: directory

- name: Configure git author mail
command:
argv: [git, config, --global, user.email, "{{ author_mail }}"]

- name: Configure git author name
command:
argv: [git, config, --global, user.name, "{{ author_name }}"]

- name: Login to github
command:
argv: [gh, auth, login, --with-token]
Expand Down
25 changes: 17 additions & 8 deletions playbook/update_repo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,15 @@
register: git_change
failed_when: git_change.rc == 0 # fail when there are no changes

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

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

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

- name: "Operator [{{ operator.name }}] commit changes"
command:
argv: [git, commit, -a, -m, "{{ commit_message }}"]
argv: [git, commit, -m, "{{ commit_message }}"]
chdir: "{{ work_dir }}/{{ operator.name }}"

# Fail if the remote branch exists, otherwise push changes and create a pull request
- name: "Operator [{{ operator.name }}] create PR if changes were performed"
block:
- name: "Operator [{{ operator.name }}] run 'git ls-remotes' to ensure that the branch {{ pr_branch_name }} doesn't exist"
command:
argv: [git, ls-remote, --exit-code, --heads, "https://{{ gh_access_token }}@github.com/{{ operator.url }}", "{{ pr_branch_name }}"]
chdir: "{{ work_dir }}/{{ operator.name }}"
register: branch_exists
failed_when: branch_exists.rc != 2 # fail when branch exists

- name: "Operator [{{ operator.name }}] push changes to branch {{ pr_branch_name }}"
command:
argv: [git, push, --set-upstream, origin, "{{ pr_branch_name }}"]
Expand Down
4 changes: 4 additions & 0 deletions template/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
stackable-secret-operator = attrs: {
buildInputs = [ pkgs.protobuf pkgs.rustfmt ];
};
stackable-opa-user-info-fetcher = attrs: {
# TODO: why is this not pulled in via libgssapi-sys?
buildInputs = [ pkgs.krb5 ];
};
NickLarsenNZ marked this conversation as resolved.
Show resolved Hide resolved
krb5-sys = attrs: {
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = [ pkgs.krb5 ];
Expand Down
2 changes: 2 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

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