From 661eda3010f51a44b78d386b5dda22f79a65162d Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Tue, 16 Jan 2024 20:33:36 -0600 Subject: [PATCH] first pass at entire build - lots of todos left --- .../actions/setup-python-env/action.yml | 20 + .github/workflows/build.yml | 16 +- .github/workflows/build_hatch.yml | 395 ++++++++++++++++++ .github/workflows/ci_code_quality.yml | 10 +- .github/workflows/ci_tests.yml | 10 +- .github/workflows/release.yml | 189 +++++++++ .github/workflows/release_prep_hatch.yml | 37 +- 7 files changed, 626 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/actions/setup-python-env/action.yml create mode 100644 .github/workflows/build_hatch.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/actions/setup-python-env/action.yml b/.github/workflows/actions/setup-python-env/action.yml new file mode 100644 index 00000000..1ab687f6 --- /dev/null +++ b/.github/workflows/actions/setup-python-env/action.yml @@ -0,0 +1,20 @@ +name: Setup Python env +description: Install Python & Hatch +inputs: + python-version: + description: 'Version of Python to Install' + required: true + default: '3.9' +runs: + using: "composite" + steps: + - name: "Set up Python ${{ inputs.python-version }}" + uses: actions/setup-python@v4 + with: + python-version: "${{ inputs.python-version }}" + + - name: Install Hatch + shell: bash + run: | + python -m pip install --user --upgrade pip + python -m pip install hatch diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c3b8366b..485bfd62 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,20 +40,10 @@ jobs: - name: Check out the repository uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 + - name: "Set up Python & Hatch - 3.11" + uses: ./.github/actions/setup-python-env with: - python-version: '3.11' - - - name: "Install build specific python dependencies" - run: | - python -m pip install --user --upgrade pip - python -m pip install --upgrade wheel twine check-wheel-contents - python -m pip --version - - - name: "Install Hatch" - shell: bash - run: pip3 install hatch + python-version: "3.11" - name: "Build Python Package" run: | diff --git a/.github/workflows/build_hatch.yml b/.github/workflows/build_hatch.yml new file mode 100644 index 00000000..c7c898a9 --- /dev/null +++ b/.github/workflows/build_hatch.yml @@ -0,0 +1,395 @@ +# **what?** +# Build release artifacts and store them to S3 bucket if they do not already exist. +# +# Expected build artifact layout: +# +# ├── dist +# │ ├── dbt-*.tar.gz +# │ ├── dbt-*.whl +# └── .md +# +# Build artifacts get stored in S3 to a bucket with the following directory structure: +# "s3:////////" +# +# Notes: +# - resolves based on `test_run` and `nightly_release` inputs. +# nightly_release == true will use "nightly-releases" +# nightly_release == false resolves based on `test_run` input +# test_run == true will use "artifacts_testing" +# test_run == false will use "artifacts" +# +# Examples: +# nightly_release == true: "s3://core-team-artifacts/dbt-labs/dbt-core/nightly-releases/1.4.0a1.dev01112023+nightly/aaa410f17d300f1bde2cd67c03e48df135ab347b" +# test_run == true : "s3://core-team-artifacts/dbt-labs/dbt-core/artifacts_testing/1.2.3/ce98e6f067d9fa63a9b213bf99ebaf0c29d2b7eb/" +# test_run == false : "s3://core-team-artifacts/dbt-labs/dbt-core/artifacts/1.2.3/ce98e6f067d9fa63a9b213bf99ebaf0c29d2b7eb/" +# +# Inputs: +# sha: The commit to attach to this release +# version_number: The release version number (i.e. 1.0.0b1, 1.2.3rc2, 1.0.0) +# changelog_path: Path to the changelog file for release notes +# s3_bucket_name: AWS S3 bucket name +# package_test_command: Command to use to check package runs +# test_run: Test run (Bucket to upload the artifact) +# nightly_release: Identifier that this is nightly release +# +# **why?** +# Reusable and consistent build process. +# +# **when?** +# Call after a successful version bump up. +# This workflow expects that the package version is bumped and the associated changelog living in sources. +# +# Validation Checks +# +# 1. Make sure the sha has a changelog entry for this version and the version bump has been completed. +# 2. Check if build already exists in AWS s3 bucket. It will live in a bucket following the env.s3 naming convention below. +# If it does exist, upload it to the GitHub artifacts and skip the rest of the workflow. +# 3. Only upload artifacts and changelog to S3 if tests pass + +name: Build + +on: + workflow_call: + inputs: + sha: + required: true + type: string + version_number: + required: true + type: string + changelog_path: + required: true + type: string + s3_bucket_name: + required: true + default: "core-team-artifacts" + type: string + package_test_command: + required: true + default: "dbt --version" + type: string + test_run: + required: false + default: true + type: boolean + nightly_release: + required: false + default: false + type: boolean + + # pass through secrets so every repo can have their own and won't depend on a name + secrets: + AWS_ACCESS_KEY_ID: + description: AWS Access Key ID + required: true + AWS_SECRET_ACCESS_KEY: + description: AWS Access Key + required: true + +permissions: + contents: write + # this will be needed if we go with OIDC for auth instead of managing secrets in github for AWS + # id-token: write # https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-cloud-providers#adding-permissions-settings + +env: + ARTIFACT_RETENTION_DAYS: 2 + AWS_REGION: "us-east-1" + PYTHON_TARGET_VERSION: 3.8 + NOTIFICATION_PREFIX: "[Build]" + +jobs: + log-inputs: + runs-on: ubuntu-latest + steps: + - name: "[DEBUG] Print Variables" + run: | + # WORKFLOW INPUTS + echo The last commit sha in the release: ${{ inputs.sha }} + echo The release version number: ${{ inputs.version_number }} + echo The changelog path: ${{ inputs.changelog_path }} + echo The s3 bucket name: ${{ inputs.s3_bucket_name }} + echo The package test command: ${{ inputs.package_test_command }} + echo Test run: ${{ inputs.test_run }} + echo Nightly release: ${{ inputs.nightly_release }} + # ENVIRONMENT VARIABLES + echo GitHub artifact retention days: ${{ env.ARTIFACT_RETENTION_DAYS }} + echo Amazon Web Services region: ${{ env.AWS_REGION }} + echo Python target version: ${{ env.PYTHON_TARGET_VERSION }} + echo Notification prefix: ${{ env.NOTIFICATION_PREFIX }} + + resolve-aws-bucket: + runs-on: ubuntu-latest + outputs: + aws-s3-bucket: ${{ steps.bucket_path.outputs.path }} + + steps: + - name: "Resolve S3 Bucket Path" + id: bucket_path + run: | + # Resolve folder to upload/check build artifact + artifact_folder="artifacts" + if [[ ${{ inputs.nightly_release }} == true ]] + then + artifact_folder="nightly-releases" + elif [[ ${{ inputs.test_run }} == true ]] + then + artifact_folder="artifacts_testing" + fi + # Generate path for build artifact. + # Include commit in path in case release commit gets updates on subsequent runs + bucket_path="s3://${{ inputs.s3_bucket_name }}/${{ github.repository }}/$artifact_folder/${{ inputs.version_number }}/${{ inputs.sha }}" + echo "path=$bucket_path" >> $GITHUB_OUTPUT + # Send notification + title="S3 Bucket Path" + echo "$title: $bucket_path" + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$bucket_path" + + audit-version-changelog: + # Make sure the changelog has been generated and the version is up to date + runs-on: ubuntu-latest + + steps: + - name: "Checkout ${{ github.repository }} Commit ${{ inputs.sha }}" + uses: actions/checkout@v3 + with: + ref: ${{ inputs.sha }} + + - name: "Audit Version And Parse Into Parts" + id: semver + uses: dbt-labs/actions/parse-semver@v1.1.0 + with: + version: ${{ inputs.version_number }} + + - name: "Audit Changelog Exists" + run: | + title="Audit Changelog Exists" + if test -f ${{ inputs.changelog_path }} + then + message="Specified file ${{ inputs.changelog_path }} - exists." + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + else + message="Specified file ${{ inputs.changelog_path }} does not exist! The changelog for this release must exist before running this workflow." + git status + echo "::error title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + exit 1 + fi + + - name: "Check Current Version In Code" + id: set_status + run: | + title="Check Current Version In Code" + current_version=$(hatch version) + if test "$current_version" = "${{ inputs.version_number }}" + then + message="Version set to ${{ inputs.version_number }}." + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + else + message="Version not set to ${{ inputs.version_number }}. The version bump workflow must be complete before running this workflow." + git status + echo "::error title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + exit 1 + fi + + check-build-exists: + runs-on: ubuntu-latest + needs: [audit-version-changelog, resolve-aws-bucket] + + outputs: + is_exists: ${{ steps.artifact_exists.outputs.is_exists }} + + steps: + - name: "Configure AWS Credentials" + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: "Copy Artifact From S3 Via CLI" + run: | + aws s3 cp ${{ needs.resolve-aws-bucket.outputs.aws-s3-bucket }} . --recursive # since it's an entire directory + + - name: "[DEBUG] Display Structure Of All Downloaded Files" + run: ls -R + + - name: "Check Artifact Integrity" + id: artifact_integrity + uses: andstor/file-existence-action@v2 + with: + files: "${{ inputs.changelog_path }}, dist/*.tar.gz, dist/*.whl" + + # upload the files downloaded from S3 to artifacts so we don't have to keep + # downloading from S3 + - name: "Upload Artifact From S3 To GitHub" + if: ${{ steps.artifact_integrity.outputs.files_exists == 'true' }} + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.version_number }} + path: | + ${{ inputs.changelog_path }} + dist/ + if-no-files-found: error + retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} + + - name: "[Notification] Upload Artifact From S3 To GitHub" + if: ${{ steps.artifact_integrity.outputs.files_exists == 'true' }} + run: | + title="Artifact ${{ inputs.version_number }} uploaded from S3 To GitHub" + message="The build artifact is pulled from the S3 bucket and uploaded to the GitHub artifact storage." + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + - name: "Set Artifact Existence For Subsequent Jobs" + id: artifact_exists + run: echo "is_exists=${{ steps.artifact_integrity.outputs.files_exists }}" >> $GITHUB_OUTPUT + + skip-build: + runs-on: ubuntu-latest + needs: [check-build-exists] + if: ${{ needs.check-build-exists.outputs.is_exists == 'true' }} + + steps: + - name: "Build Exists, Skip To Test" + run: | + title="Build Exists in AWS S3 bucket" + message="A build already exists for version ${{ inputs.version_number }}, skipping build job." + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" + + unit: + name: Unit Test + runs-on: ubuntu-latest + needs: [audit-version-changelog, check-build-exists] + if: ${{ needs.check-build-exists.outputs.is_exists == 'false' }} + + steps: + - name: "Checkout ${{ github.repository }} Commit ${{ inputs.sha }}" + uses: actions/checkout@v3 + with: + persist-credentials: false + ref: ${{ inputs.sha }} + + - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" + uses: ./.github/actions/setup-python-env + with: + python-version: ${{ env.PYTHON_TARGET_VERSION }} + + - name: "Run Unit Tests" + run: hatch run test:unit + + build-packages: + runs-on: ubuntu-latest + needs: [unit] + + outputs: + finished: ${{ steps.set_success.outputs.finished }} + + steps: + - name: "Checkout Commit - ${{ inputs.sha }}" + uses: actions/checkout@v3 + with: + persist-credentials: false + ref: ${{ inputs.sha }} + + - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" + uses: ./.github/actions/setup-python-env + with: + python-version: ${{ env.PYTHON_TARGET_VERSION }} + + - name: "Build Python Package" + run: | + hatch build + + - name: "Upload Build Artifact - ${{ inputs.version_number }}" + uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.version_number }} + # TODO: check these paths + path: | + ${{ inputs.changelog_path }} + ./dist/ + !dist/dbt-${{ inputs.version_number }}.tar.gz + retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }} + + test-build: + runs-on: ubuntu-latest + needs: [build-packages] + + steps: + - name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}" + uses: actions/setup-python@v4 + with: + python-version: ${{ env.PYTHON_TARGET_VERSION }} + + - name: "Install Python Dependencies" + run: | + python -m pip install --user --upgrade pip + python -m pip install --upgrade wheel + python -m pip --version + + - name: "Download Build Artifact - ${{ inputs.version_number }}" + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.version_number }} + path: . + + - name: "[DEBUG] Display Structure Of All Downloaded Files" + run: ls -R + + - name: "[DEBUG] Show Distributions" + run: ls -lh dist/ + + - name: "Show distributions" + run: ls -lh dist/ + + - name: "Check distribution descriptions" + run: | + twine check dist/* + + - name: "Check wheel contents" + run: | + check-wheel-contents dist/*.whl --ignore W007,W008 + + - name: "Install wheel distributions" + run: | + find ./dist/dbt_common-*.whl -maxdepth 1 -type f | xargs python -m pip install --force-reinstall --find-links=dist/ + + # TODO: how to validate here? we did dbt --version previously. this checks it's there, but not that it can do anything. maybe it's enough? + - name: "Check wheel distributions" + run: | + pip freeze | grep dbt-common + + - name: "Install source distributions" + run: | + find ./dist/dbt_common-*.gz -maxdepth 1 -type f | xargs python -m pip install --force-reinstall --find-links=dist/ + + # TODO: how to validate here? we did dbt --version previously. this checks it's there, but not that it can do anything. maybe it's enough? + - name: "Check source distributions" + run: | + pip freeze | grep dbt-common + + upload-artifacts-aws: + runs-on: ubuntu-latest + needs: [test-build, resolve-aws-bucket] + + steps: + - name: "Download Artifact ${{ inputs.version_number }}" + uses: actions/download-artifact@v3 + with: + name: ${{ inputs.version_number }} + path: . + + - name: "Display Structure Of All Downloaded Files" + run: ls -R + + - name: "Configure Aws Credentials" + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: "Upload Artifact To S3 Via CLI" + run: | + aws s3 cp . ${{ needs.resolve-aws-bucket.outputs.aws-s3-bucket }} --recursive # since it's an entire directory + title="Artifact ${{ inputs.version_number }} uploaded to AWS S3 bucket" + message="S3 path: ${{ needs.resolve-aws-bucket.outputs.aws-s3-bucket }}" + echo "::notice title=${{ env.NOTIFICATION_PREFIX }}: $title::$message" diff --git a/.github/workflows/ci_code_quality.yml b/.github/workflows/ci_code_quality.yml index 7b12e3d5..fddd03b9 100644 --- a/.github/workflows/ci_code_quality.yml +++ b/.github/workflows/ci_code_quality.yml @@ -40,14 +40,10 @@ jobs: - name: Check out the repository uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 + - name: "Set up Python & Hatch - 3.11" + uses: ./.github/actions/setup-python-env with: - python-version: '3.11' - - - name: Install Hatch - shell: bash - run: pip3 install hatch + python-version: "3.11" - name: Run Pre-commit Hooks run: hatch run dev-env:pre-commit run --show-diff-on-failure --color=always --all-files diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 03cdffb8..b22c09b2 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -45,14 +45,10 @@ jobs: - name: "Check out the repository" uses: actions/checkout@v3 - - name: "Set up Python ${{ matrix.python-version }}" - uses: actions/setup-python@v4 + - name: "Set up Python & Hatch - ${{ matrix.python-version }}" + uses: ./.github/actions/setup-python-env with: - python-version: ${{ matrix.python-version }} - - - name: "Install Hatch" - shell: bash - run: pip3 install hatch + python-version: "${{ matrix.python-version }}" - name: "Run Tests" run: hatch run dev-env:pytest tests diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..eadb3271 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,189 @@ +# **what?** +# Release workflow provides the following steps: +# - checkout the HEAD of the target branch; +# - validate version in sources and changelog file for given version; +# - bump the version and generate a changelog if needed; +# - merge all changes to the target branch if needed; +# - run unit and integration tests against given commit; +# - build and package that SHA; +# - release it to GitHub and PyPI with that specific build; +# +# **why?** +# Ensure an automated and tested release process +# +# **when?** +# This workflow can be run manually on demand or can be called by other workflows + +name: Release to GitHub and PyPI + +on: + workflow_dispatch: + inputs: + target_branch: + description: "The branch to release from" + type: string + required: true + version_number: + description: "The release version number (i.e. 1.0.0b1)" + type: string + required: true + test_run: + description: "Test run (Publish release as draft)" + type: boolean + default: true + required: false + nightly_release: + description: "Nightly release to dev environment" + type: boolean + default: false + required: false + workflow_call: + inputs: + target_branch: + description: "The branch to release from" + type: string + required: true + version_number: + description: "The release version number (i.e. 1.0.0b1)" + type: string + required: true + test_run: + description: "Test run (Publish release as draft)" + type: boolean + default: true + required: false + nightly_release: + description: "Nightly release to dev environment" + type: boolean + default: false + required: false + +env: + ENV_SETUP_SCRIPT_PATH: "scripts/env-setup.sh" # TODO: This isn't needed for dbt-common + S3_BUCKET_NAME: "core-team-artifacts" + PACKAGE_TEST_COMMAND: "tbd..." # this should probably be the hatch command/script + +permissions: + contents: write # this is the permission that allows creating a new release + +defaults: + run: + shell: bash + +jobs: + log-inputs: + name: Log Inputs + runs-on: ubuntu-latest + steps: + - name: "[DEBUG] Print Variables" + run: | + echo "***INPUTS***" + echo The branch to release from: ${{ inputs.target_branch }} + echo The release version number: ${{ inputs.version_number }} + echo Test run: ${{ inputs.test_run }} + echo Nightly release: ${{ inputs.nightly_release }} + echo "***ENV VARS***" + echo Environment setup script path: ${{ env.ENV_SETUP_SCRIPT_PATH }} + echo AWS S3 bucket name: ${{ env.S3_BUCKET_NAME }} + echo Package test command: ${{ env.PACKAGE_TEST_COMMAND }} + + + bump-version-generate-changelog: + name: Bump package version, Generate changelog + + uses: dbt-labs/dbt-common/.github/workflows/release_prep_hatch.yml@er/release + + with: + version_number: ${{ inputs.version_number }} + target_branch: ${{ inputs.target_branch }} + env_setup_script_path: ${{ env.ENV_SETUP_SCRIPT_PATH }} + test_run: ${{ inputs.test_run }} + nightly_release: ${{ inputs.nightly_release }} + + secrets: inherit + + log-outputs-bump-version-generate-changelog: + name: "[Log output] Bump package version, Generate changelog" + if: ${{ !failure() && !cancelled() }} + + needs: [bump-version-generate-changelog] + + runs-on: ubuntu-latest + + steps: + - name: Print variables + run: | + echo Final SHA : ${{ needs.bump-version-generate-changelog.outputs.final_sha }} + echo Changelog path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }} + + build-test-package: + name: Build, Test, Package + if: ${{ !failure() && !cancelled() }} + needs: [bump-version-generate-changelog] + + uses: dbt-labs/dbt-common/.github/workflows/build_hatch.yml@er/release + + with: + sha: ${{ needs.bump-version-generate-changelog.outputs.final_sha }} + version_number: ${{ inputs.version_number }} + changelog_path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }} + s3_bucket_name: ${{ env.S3_BUCKET_NAME }} + package_test_command: ${{ env.PACKAGE_TEST_COMMAND }} + test_run: ${{ inputs.test_run }} + nightly_release: ${{ inputs.nightly_release }} + + secrets: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + github-release: + name: GitHub Release + if: ${{ !failure() && !cancelled() }} + + needs: [bump-version-generate-changelog, build-test-package] + + uses: dbt-labs/dbt-release/.github/workflows/github-release.yml@main + + with: + sha: ${{ needs.bump-version-generate-changelog.outputs.final_sha }} + version_number: ${{ inputs.version_number }} + changelog_path: ${{ needs.bump-version-generate-changelog.outputs.changelog_path }} + test_run: ${{ inputs.test_run }} + + # TODO: this should be updated to use trusted publishers for these repos. adapters could also start + # using it at that point. core/postgres are in the same repo and therefore can't use trusted publisers + # right now which is why this doesn't currently use it. It can't be updated until the project is set + # up in PyPI and we can't set it up in PyPI until we have a release. Chicken and egg. + pypi-release: + name: PyPI Release + + needs: [github-release] + + uses: dbt-labs/dbt-release/.github/workflows/pypi-release.yml@main + + with: + version_number: ${{ inputs.version_number }} + test_run: ${{ inputs.test_run }} + + secrets: + PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + TEST_PYPI_API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }} + + slack-notification: + name: Slack Notification + if: ${{ failure() && (!inputs.test_run || inputs.nightly_release) }} + + needs: + [ + bump-version-generate-changelog, + build-test-package, + github-release, + pypi-release, + ] + + uses: dbt-labs/dbt-release/.github/workflows/slack-post-notification.yml@main + with: + status: "failure" + + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEV_CORE_ALERTS }} diff --git a/.github/workflows/release_prep_hatch.yml b/.github/workflows/release_prep_hatch.yml index 1c6d6c00..af78ec5f 100644 --- a/.github/workflows/release_prep_hatch.yml +++ b/.github/workflows/release_prep_hatch.yml @@ -2,7 +2,6 @@ # Perform the version bump, generate the changelog and run tests. # # Inputs: -# sha: The commit to attach to this release # version_number: The release version number (i.e. 1.0.0b1, 1.2.3rc2, 1.0.0) # target_branch: The branch that we will release from # env_setup_script_path: Path to the environment setup script @@ -168,8 +167,10 @@ jobs: up_to_date: ${{ steps.version-check.outputs.up_to_date }} steps: - - name: "Checkout ${{ github.repository }}" - uses: actions/checkout@v3 + - name: "Checkout ${{ github.repository }} Branch ${{ inputs.target_branch }}" + uses: actions/checkout@v4 + with: + ref: ${{ inputs.target_branch }} - name: "Check Current Version In Code" id: version-check @@ -232,10 +233,10 @@ jobs: branch_name: ${{ steps.variables.outputs.branch_name }} steps: - - name: "Checkout ${{ github.repository }} Commit ${{ inputs.sha }}" - uses: actions/checkout@v3 + - name: "Checkout ${{ github.repository }} Branch ${{ inputs.target_branch }}" + uses: actions/checkout@v4 with: - ref: ${{ inputs.sha }} + ref: ${{ inputs.target_branch }} - name: "Generate Branch Name" id: variables @@ -341,9 +342,8 @@ jobs: exit 1 fi - # TODO: validate this is needed - - name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}" - uses: actions/setup-python@v4 + - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" + uses: ./.github/actions/setup-python-env with: python-version: ${{ env.PYTHON_TARGET_VERSION }} @@ -401,16 +401,11 @@ jobs: with: ref: ${{ needs.create-temp-branch.outputs.branch_name }} - - name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}" - uses: actions/setup-python@v4 + - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" + uses: ./.github/actions/setup-python-env with: python-version: ${{ env.PYTHON_TARGET_VERSION }} - - name: "Install Python Dependencies" - run: | - python -m pip install --user --upgrade pip - python -m pip install hatch - - name: "Run Unit Tests" run: hatch run test:unit @@ -458,17 +453,11 @@ jobs: env: SECRETS_CONTEXT: ${{ toJson(secrets) }} - - name: "Set up Python - ${{ env.PYTHON_TARGET_VERSION }}" - uses: actions/setup-python@v4 + - name: "Set up Python & Hatch - ${{ env.PYTHON_TARGET_VERSION }}" + uses: ./.github/actions/setup-python-env with: python-version: ${{ env.PYTHON_TARGET_VERSION }} - - name: "Install python tools" - run: | - python -m pip install --user --upgrade pip - python -m pip --version - python -m pip install hatch - - name: Run tests run: hatch run test:integration