From f7e00f85f88fa03cffcd54234c81d48e42c7d846 Mon Sep 17 00:00:00 2001 From: "michal.gubricky" Date: Mon, 22 Jul 2024 09:44:03 +0200 Subject: [PATCH 1/2] Add checkout to PR banch into e2e tests Signed-off-by: michal.gubricky --- playbooks/openstack/e2e.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/playbooks/openstack/e2e.yaml b/playbooks/openstack/e2e.yaml index ffad3881..1fc43006 100644 --- a/playbooks/openstack/e2e.yaml +++ b/playbooks/openstack/e2e.yaml @@ -23,6 +23,29 @@ tasks: - name: Determine cluster stack directory block: + - name: Get PR details + ansible.builtin.uri: + url: "https://api.github.com/repos/{{ zuul.project.name }}/pulls/{{ zuul.change }}" + body_format: json + headers: + Accept: application/vnd.github+json + X-GitHub-Api-Version: 2022-11-28 + register: pull_request + when: zuul.change is defined # execute when the e2e pipeline is initiated on a PR + - name: | + Set facts - + In cases where e2e is not executed on the PR, the main branch is used for the pipeline. + ansible.builtin.set_fact: + git_branch_name: "{{ pull_request.json.head.ref }}" + git_repository_url: "{{ pull_request.json.head.repo.clone_url }}" + when: zuul.change is defined # execute when the e2e pipeline is initiated on a PR + - name: Checkout to PR branch + ansible.builtin.git: + repo: "{{ git_repository_url }}" + clone: false + dest: "{{ project_dir }}" + version: "{{ git_branch_name }}" + when: zuul.change is defined # execute when the e2e pipeline is initiated on a PR - name: Make sure directory structure exists ansible.builtin.file: path: "{{ item }}" From 8a5cc0c75c25683cf2544fc84902e30e235e6a00 Mon Sep 17 00:00:00 2001 From: Roman Hros Date: Thu, 8 Aug 2024 14:47:12 +0200 Subject: [PATCH 2/2] Simplify 'Set facts' task name Signed-off-by: Roman Hros --- playbooks/openstack/e2e.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/playbooks/openstack/e2e.yaml b/playbooks/openstack/e2e.yaml index 4d69a5d9..f71f6088 100644 --- a/playbooks/openstack/e2e.yaml +++ b/playbooks/openstack/e2e.yaml @@ -30,9 +30,7 @@ X-GitHub-Api-Version: 2022-11-28 register: pull_request when: zuul.change is defined # execute when the e2e pipeline is initiated on a PR - - name: | - Set facts - - In cases where e2e is not executed on the PR, the main branch is used for the pipeline. + - name: Set facts when the e2e pipeline is initiated on a PR ansible.builtin.set_fact: git_branch_name: "{{ pull_request.json.head.ref }}" git_repository_url: "{{ pull_request.json.head.repo.clone_url }}"