Skip to content

Commit

Permalink
ci: Fix bug with deleting xts-candidate tag prior to creation or use (#…
Browse files Browse the repository at this point in the history
…16159)

Signed-off-by: Roger Barker <roger.barker@swirldslabs.com>
  • Loading branch information
rbarkerSL authored Oct 25, 2024
1 parent 8c4f948 commit 6620006
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
30 changes: 22 additions & 8 deletions .github/workflows/zxcron-extended-test-suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,31 @@ jobs:
- name: Check for tags
id: check-tags-exist
run: |
XTS_COMMIT=$(git rev-list -n 1 "${XTS_CANDIDATE_TAG}")
# Check if the tag exists and if so grab its commit id
set +e
XTS_COMMIT=$(git rev-list -n 1 "${XTS_CANDIDATE_TAG}") >/dev/null 2>&1
XTS_COMMIT_FOUND="${?}"
set -e
# Cancel out if the tag does not exist
if [[ "${XTS_COMMIT_FOUND}" -ne 0 ]]; then
gh run cancel ${{ github.run_id }}
fi
# Check if the tag exists on the develop branch
set +e
git branch --contains "${XTS_COMMIT}" | grep --quiet develop >/dev/null 2>&1
BRANCH_ON_DEVELOP="${?}"
set -e
if [[ -n "${XTS_COMMIT}" && "${BRANCH_ON_DEVELOP}" -eq 0 ]]; then
# If the tag exists on the Develop Branch set the output variables as appropriate
# Otherwise cancel out
if [[ "${BRANCH_ON_DEVELOP}" -eq 0 ]]; then
echo "xts-tag-exists=true" >> $GITHUB_OUTPUT
echo "xts-tag-commit=${XTS_COMMIT}" >> $GITHUB_OUTPUT
echo "### Commit has been tagged as an XTS-Candidate" >> $GITHUB_STEP_SUMMARY
echo "xts-tag-commit=${XTS_COMMIT}" >> $GITHUB_STEP_SUMMARY
git push --delete origin "${XTS_CANDIDATE_TAG}"
git tag -d "${XTS_CANDIDATE_TAG}"
else
Expand Down Expand Up @@ -152,14 +167,13 @@ jobs:
name: Tag as XTS-Passing
runs-on: network-node-linux-medium
needs:
# - abbreviated-panel
- abbreviated-panel
- extended-test-suite
- fetch-xts-candidate
# - hedera-node-jrs-panel
# if: ${{ needs.abbreviated-panel.result == 'success' ||
# needs.extended-test-suite.result == 'success' ||
# needs.hedera-node-jrs-panel.result == 'success' }}
if: ${{ needs.extended-test-suite.result == 'success' }}
- hedera-node-jrs-panel
if: ${{ needs.abbreviated-panel.result == 'success' ||
needs.extended-test-suite.result == 'success' ||
needs.hedera-node-jrs-panel.result == 'success' }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/zxf-prepare-extended-test-suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,19 @@ jobs:
# move the tag if successful
- name: Tag Code and push
run: |
XTS_COMMIT=$(git rev-list -n 1 "${XTS_CANDIDATE_TAG}")
# Check if the tag exists
set +e
git branch --contains "${XTS_COMMIT}" | grep --quiet develop >/dev/null 2>&1
BRANCH_ON_DEVELOP="${?}"
git rev-list -n 1 "${XTS_CANDIDATE_TAG}" >/dev/null 2>&1
XTS_COMMIT_FOUND="${?}"
set -e
if [[ -n "${XTS_COMMIT}" && "${BRANCH_ON_DEVELOP}" -eq 0 ]]; then
# Delete the tag if it does exist
if [[ "${XTS_COMMIT_FOUND}" -eq 0 ]]; then
git push --delete origin "${XTS_CANDIDATE_TAG}"
git tag -d "${XTS_CANDIDATE_TAG}"
fi
# Create the new tag
git tag --annotate "${XTS_CANDIDATE_TAG}" --message "chore: tagging commit for XTS promotion"
git push --set-upstream origin --tags
Expand Down

0 comments on commit 6620006

Please sign in to comment.