diff --git a/.github/workflows/bump-stage-and-upload-to-jfrog.yml b/.github/workflows/bump-stage-and-upload-to-jfrog.yml new file mode 100644 index 000000000..a15a084be --- /dev/null +++ b/.github/workflows/bump-stage-and-upload-to-jfrog.yml @@ -0,0 +1,61 @@ +on: + workflow_call: + inputs: + passed-dev-tag: + type: string + description: Dev tag to fast forward the stage branch to + 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.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: + change: 'promote-dev-build-to-rc' + ref: ${{ vars.STAGE_BRANCH_NAME }} + secrets: inherit + + rebuild-artifacts-with-rc-version: + needs: promote-dev-build-to-rc + uses: ./.github/workflows/build-wheels.yml + with: + ref: ${{ needs.promote-dev-build-to-rc.outputs.bump_sha }} + + 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 + ] + 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: + 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: + ref_to_merge: origin/${{ vars.STAGE_BRANCH_NAME }} + base_branch: ${{ vars.DEV_BRANCH_NAME }} + secrets: inherit diff --git a/.github/workflows/dev-to-stage.yml b/.github/workflows/dev-to-stage.yml index c548d2022..499f573f0 100644 --- a/.github/workflows/dev-to-stage.yml +++ b/.github/workflows/dev-to-stage.yml @@ -5,90 +5,52 @@ on: workflow_dispatch: jobs: - get-latest-dev-tag: + # We want to skip the stage tests if the changes made between dev and stage wouldn't affect the results of the stage tests + compare-latest-dev-tag-and-stage: outputs: - latest-dev-version: ${{ steps.get-dev-version.outputs.latest-dev-version }} + latest-dev-tag: ${{ steps.get-dev-tag.outputs.latest-dev-tag }} + run_stage_tests: ${{ steps.run_stage_tests.outputs.run_stage_tests }} 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 + - 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: Output latest dev version (for debugging) - run: echo ${{ steps.get-dev-version.outputs.latest-dev-version }} + - 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 + shell: bash + + - name: If any files were changed besides the exceptions, run the stage tests + run: echo run_stage_tests=${{ env.NUM_FILES_CHANGED != '0' }} >> $GITHUB_OUTPUT + id: run_stage_tests run-stage-tests: + 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 - needs: get-latest-dev-tag 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 - ff-stage-to-dev-tag: + # Stage tests have passed or skipped + # 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 the subsequent jobs + bump-stage-and-upload-to-jfrog: needs: [ run-stage-tests, - get-latest-dev-tag - ] - uses: ./.github/workflows/fast-forward-merge.yml - with: - ref_to_merge: ${{ needs.get-latest-dev-tag.outputs.latest-dev-version }} - base_branch: ${{ vars.STAGE_BRANCH_NAME }} - secrets: inherit - - promote-dev-build-to-rc: - needs: ff-stage-to-dev-tag - uses: ./.github/workflows/bump-version.yml - with: - change: 'promote-dev-build-to-rc' - ref: ${{ vars.STAGE_BRANCH_NAME }} - secrets: inherit - - delete-dev-artifacts: - needs: promote-dev-build-to-rc - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - # We can't upload to the same artifact name with upload-artifact@v4 - # So we must delete the artifacts produced by stage-tests.yml - # Before rebuilding the artifacts with the new RC version - - name: Remove artifacts with dev version - uses: geekyeggo/delete-artifact@v4 - with: - name: '*.build' - - rebuild-artifacts-with-rc-version: - needs: [ - delete-dev-artifacts, - 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: - needs: [ - rebuild-artifacts-with-rc-version, - 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: - needs: [ - get-latest-dev-tag, - upload-to-jfrog + compare-latest-dev-tag-and-stage ] - uses: ./.github/workflows/fast-forward-merge.yml + 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: - ref_to_merge: origin/${{ vars.STAGE_BRANCH_NAME }} - base_branch: ${{ vars.DEV_BRANCH_NAME }} + passed-dev-tag: ${{ needs.compare-latest-dev-tag-and-stage.outputs.latest-dev-tag }} secrets: inherit diff --git a/.github/workflows/dev-workflow-p1.yml b/.github/workflows/dev-workflow-p1.yml index 6887bb785..7d2c5cda7 100644 --- a/.github/workflows/dev-workflow-p1.yml +++ b/.github/workflows/dev-workflow-p1.yml @@ -10,6 +10,10 @@ on: - review_requested branches: - 'dev*' + paths-ignore: + - 'doc/**' + - 'aerospike-stubs/**' + # So we can test changes to the test-server-rc workflow workflow_dispatch: inputs: