Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLIENT-1837] CI/CD: Skip dev and stage tests if only documentation or type stub changes were made #599

Merged
merged 21 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/bump-stage-and-upload-to-jfrog.yml
Original file line number Diff line number Diff line change
@@ -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
96 changes: 29 additions & 67 deletions .github/workflows/dev-to-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions .github/workflows/dev-workflow-p1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading