From a61230ae51d636a11f90edec73cf877ac5649a3d Mon Sep 17 00:00:00 2001 From: "vimartin@redhat.com" Date: Fri, 16 Aug 2024 15:55:17 +0200 Subject: [PATCH 1/5] Fix git ls-remote command when running sg-bridge --- .github/workflows/integration.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 81ae99d8..602cf6dd 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -62,8 +62,8 @@ jobs: id: bridge_branch continue-on-error: true run: | - echo "${GITHUB_REF#refs/heads/}" - git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo ${GITHUB_REF#refs/heads/})" + echo "${refs/heads/GITHUB_REF}" + git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo ${refs/heads/GITHUB_REF})" - name: Start sg-bridge from container image if: steps.bridge_branch.outcome != 'success' run: | @@ -158,8 +158,8 @@ jobs: id: bridge_branch continue-on-error: true run: | - echo "${GITHUB_REF#refs/heads/}" - git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo ${GITHUB_REF#refs/heads/})" + echo "${refs/heads/GITHUB_REF}" + git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo ${refs/heads/GITHUB_REF})" - name: Start sg-bridge from container image if: steps.bridge_branch.outcome != 'success' run: | @@ -323,8 +323,8 @@ jobs: id: bridge_branch continue-on-error: true run: | - echo "${GITHUB_REF#refs/heads/}" - git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo ${GITHUB_REF#refs/heads/})" + echo "${refs/heads/GITHUB_REF}" + git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo ${refs/heads/GITHUB_REF})" - name: Start sg-bridge from container image if: steps.bridge_branch.outcome != 'success' run: | From b5484cd1b2cc2af56228bd21eecad44dbe998352 Mon Sep 17 00:00:00 2001 From: "vimartin@redhat.com" Date: Fri, 16 Aug 2024 17:09:39 +0200 Subject: [PATCH 2/5] Update GITHUB_REF for GITHUB_HEAD_REF GITHUB_HEAD_REF points to the head ref or source branch of the pull request in a workflow run. GITHUB_REF points to the pull request merge branch. The ref given is fully-formed, meaning that for pull requests it is refs/pull//merge We should use the former to achieve the retrieving a branch with the same name --- .github/workflows/integration.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 602cf6dd..fc28f318 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -62,8 +62,8 @@ jobs: id: bridge_branch continue-on-error: true run: | - echo "${refs/heads/GITHUB_REF}" - git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo ${refs/heads/GITHUB_REF})" + echo "refs/heads/${GITHUB_HEAD_REF}" + git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo "refs/heads/${GITHUB_HEAD_REF}")" - name: Start sg-bridge from container image if: steps.bridge_branch.outcome != 'success' run: | @@ -74,7 +74,7 @@ jobs: if: steps.bridge_branch.outcome == 'success' run: | docker run --name=sgbridge --network host $BRIDGE_VOLUME -d -uroot \ - -e GITHUB_REF -e BRIDGE_SOCKET -e QDR_CHANNEL -e OPSTOOLS_REPO \ + -e GITHUB_HEAD_REF -e BRIDGE_SOCKET -e QDR_CHANNEL -e OPSTOOLS_REPO \ --workdir=$(dirname $BRIDGE_SOCKET) --volume ${{ github.workspace }}:$PROJECT_ROOT:z \ $TEST_IMAGE bash $PROJECT_ROOT/ci/integration/metrics/run_bridge.sh - name: Install collectd @@ -158,8 +158,8 @@ jobs: id: bridge_branch continue-on-error: true run: | - echo "${refs/heads/GITHUB_REF}" - git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo ${refs/heads/GITHUB_REF})" + echo "refs/heads/${GITHUB_HEAD_REF}" + git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo "refs/heads/${GITHUB_HEAD_REF}")" - name: Start sg-bridge from container image if: steps.bridge_branch.outcome != 'success' run: | @@ -170,7 +170,7 @@ jobs: if: steps.bridge_branch.outcome == 'success' run: | docker run --name=sgbridge --network host $BRIDGE_VOLUME -d -uroot \ - -e GITHUB_REF -e BRIDGE_SOCKET -e QDR_CHANNEL -e OPSTOOLS_REPO \ + -e GITHUB_HEAD_REF -e BRIDGE_SOCKET -e QDR_CHANNEL -e OPSTOOLS_REPO \ --workdir=$(dirname $BRIDGE_SOCKET) --volume ${{ github.workspace }}:$PROJECT_ROOT:z \ $TEST_IMAGE bash $PROJECT_ROOT/ci/integration/metrics/run_bridge.sh - name: Set Ceilometer pipelines to QDR output and restart notification agent @@ -323,8 +323,8 @@ jobs: id: bridge_branch continue-on-error: true run: | - echo "${refs/heads/GITHUB_REF}" - git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo ${refs/heads/GITHUB_REF})" + echo "refs/heads/${GITHUB_HEAD_REF}" + git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo "refs/heads/${GITHUB_HEAD_REF}")" - name: Start sg-bridge from container image if: steps.bridge_branch.outcome != 'success' run: | @@ -334,7 +334,7 @@ jobs: if: steps.bridge_branch.outcome == 'success' run: | docker run --name=sgbridge $BRIDGE_VOLUME -d -uroot --network host -e OPSTOOLS_REPO \ - -e GITHUB_REF -e BRIDGE_SOCKET --workdir=$(dirname $BRIDGE_SOCKET) --volume ${{ github.workspace }}:$PROJECT_ROOT:z \ + -e GITHUB_HEAD_REF -e BRIDGE_SOCKET --workdir=$(dirname $BRIDGE_SOCKET) --volume ${{ github.workspace }}:$PROJECT_ROOT:z \ $TEST_IMAGE bash $PROJECT_ROOT/ci/integration/logging/run_bridge.sh - name: Run rsyslog to produce log messages run: | From 6a2a6df77de9ab31064637b280fa0ca4001a4e16 Mon Sep 17 00:00:00 2001 From: "vimartin@redhat.com" Date: Mon, 19 Aug 2024 10:12:36 +0200 Subject: [PATCH 3/5] Update CI scripts to include correct branch ref --- ci/integration/logging/run_bridge.sh | 2 +- ci/integration/metrics/run_bridge.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/integration/logging/run_bridge.sh b/ci/integration/logging/run_bridge.sh index 59edfa7a..30b94fc8 100644 --- a/ci/integration/logging/run_bridge.sh +++ b/ci/integration/logging/run_bridge.sh @@ -11,7 +11,7 @@ sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/CentOS-OpsTools.repo dnf install -y git gcc make qpid-proton-c-devel redhat-rpm-config # install and start sg-bridge -BRANCH="$(echo ${GITHUB_REF#refs/heads/})" +BRANCH="$(echo "refs/heads/${GITHUB_HEAD_REF}")" git clone https://github.com/infrawatch/sg-bridge.git pushd sg-bridge git checkout $BRANCH || true diff --git a/ci/integration/metrics/run_bridge.sh b/ci/integration/metrics/run_bridge.sh index 0c73d1da..f28c2dea 100644 --- a/ci/integration/metrics/run_bridge.sh +++ b/ci/integration/metrics/run_bridge.sh @@ -13,7 +13,7 @@ sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/CentOS-OpsTools.repo dnf install -y git gcc make qpid-proton-c-devel redhat-rpm-config # install and start sg-bridge -BRANCH="$(echo ${GITHUB_REF#refs/heads/})" +BRANCH="$(echo "refs/heads/${GITHUB_HEAD_REF}")" git clone https://github.com/infrawatch/sg-bridge.git pushd sg-bridge git checkout $BRANCH || true From 04fe580eb1405ab31c5c77d925261a7580f590eb Mon Sep 17 00:00:00 2001 From: Victoria Martinez de la Cruz Date: Fri, 13 Sep 2024 19:08:15 +0200 Subject: [PATCH 4/5] Use ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} Default to using the bare branch name in GITHUB_HEAD_REF when it's available in a PR, and will fall back to parsing it out of the GITHUB_REF when operating on a branch in a push workflow, where "refs/heads" will be correct. --- .github/workflows/integration.yml | 12 ++++++------ ci/integration/logging/run_bridge.sh | 2 +- ci/integration/metrics/run_bridge.sh | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index fc28f318..ad090ae3 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -62,8 +62,8 @@ jobs: id: bridge_branch continue-on-error: true run: | - echo "refs/heads/${GITHUB_HEAD_REF}" - git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo "refs/heads/${GITHUB_HEAD_REF}")" + echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" + git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}")" - name: Start sg-bridge from container image if: steps.bridge_branch.outcome != 'success' run: | @@ -158,8 +158,8 @@ jobs: id: bridge_branch continue-on-error: true run: | - echo "refs/heads/${GITHUB_HEAD_REF}" - git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo "refs/heads/${GITHUB_HEAD_REF}")" + echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" + git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}")" - name: Start sg-bridge from container image if: steps.bridge_branch.outcome != 'success' run: | @@ -323,8 +323,8 @@ jobs: id: bridge_branch continue-on-error: true run: | - echo "refs/heads/${GITHUB_HEAD_REF}" - git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo "refs/heads/${GITHUB_HEAD_REF}")" + echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" + git ls-remote --exit-code --heads https://github.com/infrawatch/sg-bridge.git "$(echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}")" - name: Start sg-bridge from container image if: steps.bridge_branch.outcome != 'success' run: | diff --git a/ci/integration/logging/run_bridge.sh b/ci/integration/logging/run_bridge.sh index 30b94fc8..e66b7a0d 100644 --- a/ci/integration/logging/run_bridge.sh +++ b/ci/integration/logging/run_bridge.sh @@ -11,7 +11,7 @@ sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/CentOS-OpsTools.repo dnf install -y git gcc make qpid-proton-c-devel redhat-rpm-config # install and start sg-bridge -BRANCH="$(echo "refs/heads/${GITHUB_HEAD_REF}")" +BRANCH="$(echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}")" git clone https://github.com/infrawatch/sg-bridge.git pushd sg-bridge git checkout $BRANCH || true diff --git a/ci/integration/metrics/run_bridge.sh b/ci/integration/metrics/run_bridge.sh index f28c2dea..4cf1f0f1 100644 --- a/ci/integration/metrics/run_bridge.sh +++ b/ci/integration/metrics/run_bridge.sh @@ -13,7 +13,7 @@ sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/CentOS-OpsTools.repo dnf install -y git gcc make qpid-proton-c-devel redhat-rpm-config # install and start sg-bridge -BRANCH="$(echo "refs/heads/${GITHUB_HEAD_REF}")" +BRANCH="$(echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}")" git clone https://github.com/infrawatch/sg-bridge.git pushd sg-bridge git checkout $BRANCH || true From a8f6ed4fbbe43fa30d518f0e5fc6f1df9b300cad Mon Sep 17 00:00:00 2001 From: Victoria Martinez de la Cruz Date: Fri, 13 Sep 2024 19:13:13 +0200 Subject: [PATCH 5/5] Remove unnecesary quotes from ci/integration scripts --- ci/integration/logging/run_bridge.sh | 2 +- ci/integration/metrics/run_bridge.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/integration/logging/run_bridge.sh b/ci/integration/logging/run_bridge.sh index e66b7a0d..fcd734f3 100644 --- a/ci/integration/logging/run_bridge.sh +++ b/ci/integration/logging/run_bridge.sh @@ -11,7 +11,7 @@ sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/CentOS-OpsTools.repo dnf install -y git gcc make qpid-proton-c-devel redhat-rpm-config # install and start sg-bridge -BRANCH="$(echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}")" +BRANCH="$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}})" git clone https://github.com/infrawatch/sg-bridge.git pushd sg-bridge git checkout $BRANCH || true diff --git a/ci/integration/metrics/run_bridge.sh b/ci/integration/metrics/run_bridge.sh index 4cf1f0f1..e8c94efc 100644 --- a/ci/integration/metrics/run_bridge.sh +++ b/ci/integration/metrics/run_bridge.sh @@ -13,7 +13,7 @@ sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/CentOS-OpsTools.repo dnf install -y git gcc make qpid-proton-c-devel redhat-rpm-config # install and start sg-bridge -BRANCH="$(echo "${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}")" +BRANCH="$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}})" git clone https://github.com/infrawatch/sg-bridge.git pushd sg-bridge git checkout $BRANCH || true