Skip to content

Commit a40defb

Browse files
authored
[ISV-5336] Automation for pipeline re-run (#742)
Signed-off-by: Maurizio Porrato <[email protected]>
1 parent 30d6b05 commit a40defb

File tree

11 files changed

+871
-59
lines changed

11 files changed

+871
-59
lines changed

.github/workflows/build-and-test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Install Python dependencies
3737
run: |
3838
pdm sync -dG tox
39-
python3 -m pip install ansible-lint
39+
pipx install ansible-lint
4040
4141
- name: Run Tests
4242
run: |
@@ -103,8 +103,8 @@ jobs:
103103
104104
- name: Install dependencies
105105
run: |
106-
# Install python dependencies
107-
pip install --user openshift pygithub
106+
# Install python packages needed from ansible
107+
pipx inject ansible-core jmespath openshift pygithub
108108
109109
# Add certificates to trusted list
110110
sudo cp operator-pipeline-images/certs/* /usr/local/share/ca-certificates
@@ -146,5 +146,6 @@ jobs:
146146
-e "integration_tests_operator_bundle_version=0.2.${{ github.run_number }}-${{ github.run_attempt }}"
147147
-e "operator_pipeline_image_tag=${{ github.sha }}"
148148
-e "suffix=${{ steps.prepare.outputs.suffix }}"
149+
-e "ansible_python_interpreter=/opt/pipx/venvs/ansible-core/bin/python3"
149150
--skip-tags=signing-pipeline
150151
-v

.github/workflows/deploy.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ jobs:
3434
- uses: actions/checkout@v4
3535
- name: Install dependencies
3636
run: |
37-
pip install --user openshift
37+
# Install python packages needed from ansible
38+
pipx inject ansible-core jmespath openshift pygithub
3839
- name: Deploy dev environment
3940
uses: dawidd6/action-ansible-playbook@v2
4041
with:
@@ -43,7 +44,10 @@ jobs:
4344
requirements: playbooks/requirements.yml
4445
vault_password: ${{secrets.VAULT_PASSWORD}}
4546
options: |
46-
--extra-vars "operator_pipeline_image_tag=${{ github.sha }} suffix=${{needs.prepare-env.outputs.short_sha}} env=dev"
47+
--extra-vars "operator_pipeline_image_tag=${{ github.sha }}"
48+
--extra-vars "suffix=${{needs.prepare-env.outputs.short_sha}}"
49+
--extra-vars "env=dev"
50+
--extra-vars "ansible_python_interpreter=/opt/pipx/venvs/ansible-core/bin/python3"
4751
--skip-tags ci,import-index-images
4852
--verbose
4953
@@ -60,7 +64,8 @@ jobs:
6064
- uses: actions/checkout@v4
6165
- name: Install dependencies
6266
run: |
63-
pip install --user openshift
67+
# Install python packages needed from ansible
68+
pipx inject ansible-core jmespath openshift pygithub
6469
- name: Deploy qa environment
6570
uses: dawidd6/action-ansible-playbook@v2
6671
with:
@@ -69,7 +74,10 @@ jobs:
6974
requirements: playbooks/requirements.yml
7075
vault_password: ${{secrets.VAULT_PASSWORD}}
7176
options: |
72-
--extra-vars "operator_pipeline_image_tag=${{ github.sha }} suffix=${{needs.prepare-env.outputs.short_sha}} env=qa"
77+
--extra-vars "operator_pipeline_image_tag=${{ github.sha }}"
78+
--extra-vars "suffix=${{needs.prepare-env.outputs.short_sha}}"
79+
--extra-vars "env=qa"
80+
--extra-vars "ansible_python_interpreter=/opt/pipx/venvs/ansible-core/bin/python3"
7381
--skip-tags ci,import-index-images
7482
--verbose
7583
@@ -87,7 +95,8 @@ jobs:
8795
- uses: actions/checkout@v4
8896
- name: Install dependencies
8997
run: |
90-
pip install --user openshift
98+
# Install python packages needed from ansible
99+
pipx inject ansible-core jmespath openshift pygithub
91100
- name: Deploy stage environment
92101
uses: dawidd6/action-ansible-playbook@v2
93102
with:
@@ -96,7 +105,10 @@ jobs:
96105
requirements: playbooks/requirements.yml
97106
vault_password: ${{secrets.VAULT_PASSWORD}}
98107
options: |
99-
--extra-vars "operator_pipeline_image_tag=${{ github.sha }} suffix=${{needs.prepare-env.outputs.short_sha}} env=stage"
108+
--extra-vars "operator_pipeline_image_tag=${{ github.sha }}"
109+
--extra-vars "suffix=${{needs.prepare-env.outputs.short_sha}}"
110+
--extra-vars "env=stage"
111+
--extra-vars "ansible_python_interpreter=/opt/pipx/venvs/ansible-core/bin/python3"
100112
--skip-tags ci,import-index-images
101113
--verbose
102114
@@ -113,7 +125,8 @@ jobs:
113125
- uses: actions/checkout@v4
114126
- name: Install dependencies
115127
run: |
116-
pip install --user openshift
128+
# Install python packages needed from ansible
129+
pipx inject ansible-core jmespath openshift pygithub
117130
- name: Deploy prod environment
118131
uses: dawidd6/action-ansible-playbook@v2
119132
with:
@@ -122,7 +135,10 @@ jobs:
122135
requirements: playbooks/requirements.yml
123136
vault_password: ${{secrets.VAULT_PASSWORD_PROD}}
124137
options: |
125-
--extra-vars "operator_pipeline_image_tag=${{ github.sha }} suffix=${{needs.prepare-env.outputs.short_sha}} env=prod"
138+
--extra-vars "operator_pipeline_image_tag=${{ github.sha }}"
139+
--extra-vars "suffix=${{needs.prepare-env.outputs.short_sha}}"
140+
--extra-vars "env=prod"
141+
--extra-vars "ansible_python_interpreter=/opt/pipx/venvs/ansible-core/bin/python3"
126142
--skip-tags ci,import-index-images
127143
--verbose
128144

.github/workflows/documentation.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ jobs:
1515
- uses: actions/checkout@v4
1616
- name: Generate docs
1717
run: |
18-
pip install mkdocs \
18+
pipx install mkdocs
19+
pipx inject mkdocs \
1920
mkdocs-material \
2021
pymdown-extensions \
2122
mkdocs-mermaid2-plugin

ansible/playbooks/requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ collections:
33
- name: kubernetes.core
44
version: 2.4.0
55
- name: community.general
6-
version: 7.5.0
6+
version: 9.5.0

ansible/roles/integration_tests/files/wait_for_pipelinerun.sh

Lines changed: 0 additions & 27 deletions
This file was deleted.

ansible/roles/integration_tests/tasks/check_pipeline_run.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@
2222
var: pipeline_run.resources[0].metadata.name
2323

2424
- name: "Wait for the run of {{ pipeline_name }}"
25-
ansible.builtin.shell: |
26-
./wait_for_pipelinerun.sh \
27-
{{ pipeline_run.resources[0].metadata.name }} \
28-
{{ oc_namespace }}
29-
args:
30-
executable: /bin/bash
31-
chdir: "{{ temp_tools_dir.path }}"
25+
kubernetes.core.k8s_info:
26+
api_version: tekton.dev/v1
27+
kind: PipelineRun
28+
namespace: "{{ oc_namespace }}"
29+
name: "{{ pipeline_run.resources[0].metadata.name }}"
3230
register: pipeline_run_wait
33-
failed_when: false
34-
timeout: 5400 # 90 minutes
35-
changed_when: false
31+
until: >
32+
pipeline_run_wait.resources[0] | community.general.json_query("contains(['False', 'True'], status.conditions[?type == 'Succeeded']|[-1].status)")
33+
retries: 90
34+
delay: 60
3635

3736
- name: "Get pipelinerun logs - {{ pipeline_name }}"
3837
ansible.builtin.shell: |

ansible/roles/integration_tests/tasks/tools.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,3 @@
2323
remote_src: true
2424
include:
2525
- opm
26-
27-
- name: Copy a local scripts to the host
28-
ansible.builtin.copy:
29-
src: "{{ item }}"
30-
dest: "{{ temp_tools_dir.path }}"
31-
mode: a+x
32-
33-
with_items:
34-
- "files/wait_for_pipelinerun.sh"

docs/pipeline-admin-guide.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ Based on which pipeline fails one of these command can be used to re-trigger it
6767

6868
After a pipeline is re-triggered using the command a few labels will be added and removed from the PR. First a new labels `pipeline/trigger-hosted` or `pipeline/trigger-release` is added. This label kick in the pipeline and pipeline itself start adding a labels based on the pipeline status.
6969

70+
A script called `bulk-retrigger` is provided in the operator-pipeline container image to help re-triggering a pipeline on multiple PRs: it takes the repository name, a CSV file containing a list of PRs to process and automates the re-triggering of the pipeline one PR at a time. See the help text for details on how to run it.
71+
7072
### Pipeline logs
7173
Pipelines interacts with user using a Github Pull request interface. There are a slight differences between ISV and community repositories, but overall concept is the same.
7274

0 commit comments

Comments
 (0)