Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
juliannguyen4 committed Jun 5, 2024
1 parent aeca3b1 commit 17ec972
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 36 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/bump-stage-and-upload-to-jfrog.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
on:
workflow_call:
inputs:
tested-dev-tag:
passed-dev-tag:
type: string
required: true
secrets:
# Used to bump version in Github
CLIENT_BOT_PAT:
required: true
# Used to upload to JFrog
JFROG_PLATFORM_URL:
required: true
JFROG_ACCESS_TOKEN:
required: true

jobs:
ff-stage-to-dev-tag:
name: Fast forward stage branch to the dev tag that passed stage testing
uses: ./.github/workflows/fast-forward-merge.yml
with:
ref_to_merge: ${{ inputs.tested-dev-tag }}
ref_to_merge: ${{ inputs.passed-dev-tag }}
base_branch: ${{ vars.STAGE_BRANCH_NAME }}
secrets: inherit

promote-dev-build-to-rc:
name: Bump (promote) the dev version to an RC version in the stage branch
needs: ff-stage-to-dev-tag
uses: ./.github/workflows/bump-version.yml
with:
Expand All @@ -29,25 +33,25 @@ jobs:
secrets: inherit

rebuild-artifacts-with-rc-version:
# We want to make sure the "bump to RC" commit is ready to use for rebuilding on
needs: promote-dev-build-to-rc
uses: ./.github/workflows/build-wheels.yml
with:
ref: ${{ needs.promote-dev-build-to-rc.outputs.bump_sha }}

upload-to-jfrog:
upload-rc-artifacts-to-jfrog:
needs: [
rebuild-artifacts-with-rc-version,
# We need the new RC version to label the build in JFrog
promote-dev-build-to-rc,
promote-dev-build-to-rc
]
name: Upload artifacts to JFrog
uses: ./.github/workflows/upload-to-jfrog.yml
with:
version: ${{ needs.promote-dev-build-to-rc.outputs.new_version }}
secrets: inherit

ff-dev-to-stage:
ff-dev-to-stage:
name: Fast forward dev branch to stage branch to include the bump to RC commit
needs: promote-dev-build-to-rc
uses: ./.github/workflows/fast-forward-merge.yml
with:
Expand Down
45 changes: 15 additions & 30 deletions .github/workflows/dev-to-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,21 @@ on:
workflow_dispatch:

jobs:
get-latest-dev-tag:
outputs:
latest-dev-version: ${{ steps.get-dev-version.outputs.latest-dev-version }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
# Get all tags
fetch-depth: 0
ref: ${{ vars.DEV_BRANCH_NAME }}

- name: Get latest dev version
run: echo latest-dev-version=$(git describe --tags --abbrev=0) >> $GITHUB_OUTPUT
id: get-dev-version

compare-dev-tag-and-stage:
compare-latest-dev-tag-and-stage:
outputs:
latest-dev-tag: ${{ steps.get-dev-tag.outputs.latest-dev-tag }}
run_stage_tests: ${{ steps.run_stage_tests.outputs.run_stage_tests }}
needs: get-latest-dev-tag
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
# Get all tags
fetch-depth: 0

- name: Get latest dev tag
run: echo latest-dev-tag=$(git describe --tags --abbrev=0 origin/${{ vars.DEV_BRANCH_NAME }}) >> $GITHUB_OUTPUT
id: get-dev-tag

- name: Get number of files that were changed between dev and stage (with some exceptions)
run: echo NUM_FILES_CHANGED=$(git diff origin/${{ vars.STAGE_BRANCH_NAME }}..origin/${{ vars.DEV_BRANCH_NAME }} --name-only | grep --invert-match --count -e "^doc/" -e "^aerospike-stubs/" -e VERSION) >> $GITHUB_ENV
# We want this step to fail if a command failed while using pipes
Expand All @@ -41,30 +30,26 @@ jobs:
id: run_stage_tests

run-stage-tests:
needs: [
get-latest-dev-tag,
compare-dev-tag-and-stage
]
if: ${{ needs.compare-dev-tag-and-stage.outputs.run_stage_tests == 'true' }}
needs: compare-latest-dev-tag-and-stage
if: ${{ needs.compare-latest-dev-tag-and-stage.outputs.run_stage_tests == 'true' }}
uses: ./.github/workflows/stage-tests.yml
with:
ref: ${{ needs.get-latest-dev-tag.outputs.latest-dev-version }}
ref: ${{ needs.compare-latest-dev-tag-and-stage.outputs.latest-dev-tag }}
secrets: inherit

# Stage tests have passed or skipped
# so it is safe to update the stage branch with the changes in dev
# and upload RC builds with the tested changes to JFrog
# We store the subsequent jobs after the stage tests in a separate reusable workflow
# so it is safe to update the stage branch with the changes in dev, promote the version to an RC, and rebuild and upload the RC to JFrog
# We store the subsequent jobs after the stage tests in a separate reusable workflow...
# because if stage tests were skipped, all subsequent jobs will be skipped by default too (both direct and indirect descendents)
# This means we have to add a manual check for each subsequent job that checks if the stage tests were skipped in order to run them
# It's easier to just add this manual check once to a reusable workflow that wraps around all those jobs
# It's easier to just add this manual check once to a reusable workflow that wraps around all the subsequent jobs
bump-stage-and-upload-to-jfrog:
needs: [
run-stage-tests,
get-latest-dev-tag
compare-latest-dev-tag-and-stage
]
if: ${{ !cancelled() && needs.get-latest-dev-tag.result == 'success' && (needs.run-stage-tests.result == 'success' || needs.run-stage-tests.result == 'skipped') }}
if: ${{ !cancelled() && needs.compare-latest-dev-tag-and-stage.result == 'success' && (needs.run-stage-tests.result == 'success' || needs.run-stage-tests.result == 'skipped') }}
uses: ./.github/workflows/bump-stage-and-upload-to-jfrog.yml
with:
tested-dev-tag: ${{ needs.get-latest-dev-tag.outputs.latest-dev-version }}
passed-dev-tag: ${{ needs.compare-latest-dev-tag-and-stage.outputs.latest-dev-tag }}
secrets: inherit

0 comments on commit 17ec972

Please sign in to comment.