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

QA-2282: Add app-version output #2832

Merged
merged 4 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .github/workflows/consumer_contract_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
dry-run: true
release-branches: develop
secrets: inherit

init-github-context:
runs-on: ubuntu-latest
needs: [ bump-check ]
Expand Down Expand Up @@ -171,7 +171,7 @@ jobs:
"repo-owner": "${{ github.repository_owner }}",
"repo-name": "${{ github.event.repository.name }}",
"repo-branch": "${{ needs.init-github-context.outputs.repo-branch }}",
"release-tag": "${{ needs.regulated-tag-job.outputs.new-tag }}"
"release-tag": "${{ needs.regulated-tag-job.outputs.app-version }}"
}'
can-i-deploy:
runs-on: ubuntu-latest
Expand All @@ -189,5 +189,5 @@ jobs:
inputs: '{
"run-name": "${{ env.CAN_I_DEPLOY_RUN_NAME }}",
"pacticipant": "rawls",
"version": "${{ needs.regulated-tag-job.outputs.new-tag }}"
"version": "${{ needs.regulated-tag-job.outputs.app-version }}"
}'
22 changes: 14 additions & 8 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ on:
default: false
required: false
type: string
print-tag:
description: "Echo generated tag to console"
default: "true"
required: false
type: string
release-branches:
description: "Default branch (main, develop, etc)"
default: 'develop'
Expand All @@ -30,6 +25,9 @@ on:
new-tag:
description: "The value of the newly created tag"
value: ${{ jobs.tag-job.outputs.new-tag }}
app-version:
description: "The app version"
value: ${{ jobs.tag-job.outputs.app-version }}
secrets:
BROADBOT_TOKEN:
required: true
Expand All @@ -44,6 +42,7 @@ jobs:
outputs:
tag: ${{ steps.tag.outputs.tag }}
new-tag: ${{ steps.tag.outputs.new_tag }}
app-version: ${{ steps.output-version.outputs.app-version }}
steps:
- name: Checkout current code
uses: actions/checkout@v4
Expand All @@ -60,7 +59,14 @@ jobs:
DRY_RUN: ${{ inputs.dry-run }}
RELEASE_BRANCHES: ${{ inputs.release-branches }}
WITH_V: true
- name: Echo generated tag to console
if: ${{ inputs.print-tag == 'true' }}
- name: Output app version
id: output-version
run: |
echo "Newly created version tag: '${{ steps.tag.outputs.new_tag }}'"
# See https://broadworkbench.atlassian.net/browse/QA-2282 for context
if [[ -z "${{ steps.tag.outputs.new_tag }}" ]]; then
ichengchang marked this conversation as resolved.
Show resolved Hide resolved
echo "App version tag for this commit has already been dispatched: '${{ steps.tag.outputs.tag }}'"
echo "app-version=${{ steps.tag.outputs.tag }}" >> $GITHUB_OUTPUT
else
echo "New app version tag: '${{ steps.tag.outputs.new_tag }}'"
echo "app-version=${{ steps.tag.outputs.new_tag }}" >> $GITHUB_OUTPUT
fi
26 changes: 13 additions & 13 deletions .github/workflows/verify_consumer_pacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
branches:
- develop
paths-ignore:
- 'README.md'
- 'README.md'
workflow_dispatch:
inputs:
pb-event-type:
Expand Down Expand Up @@ -88,7 +88,7 @@ jobs:
uses: ./.github/actions/bump-skip
with:
event-name: ${{ github.event_name }}

regulated-tag-job:
needs: [ bump-check ]
if: ${{ needs.bump-check.outputs.is-bump == 'no' }}
Expand All @@ -101,7 +101,7 @@ jobs:
dry-run: true
release-branches: develop
secrets: inherit

verify-consumer-pact:
runs-on: ubuntu-latest
needs: [ regulated-tag-job ]
Expand Down Expand Up @@ -138,19 +138,19 @@ jobs:
run: |
echo "pb-event-type=${{ inputs.pb-event-type }}"
echo "consumer-name=${{ inputs.consumer-name }}"

# The consumer-version-branch and consumer-version-number identify the most recent
# consumer branch and version associated with the pact content.
echo "consumer-version-branch/consumer-version-number=${{ inputs.consumer-version-branch }}/${{ inputs.consumer-version-number }}"

# The provider-version-number represents the provider version number in the webhook event payload.
# This corresponds to the GitHub release recorded by Sherlock for the corresponding
# deployment environment (dev, sing, and prod).
# deployment environment (dev, sing, and prod).
echo "provider-version-branch/provider-version-number=${{ inputs.provider-version-branch }}/${{ inputs.provider-version-number }}"

# The pact-url is included here in case future pact4s client supports it.
echo "pact-url=${{ inputs.pact-url }}"

# Save webhook event parameters as envvars
echo "PROVIDER_BRANCH=${{ inputs.provider-version-branch }}" >> $GITHUB_ENV
echo "PROVIDER_TAG=${{ inputs.provider-version-number }}" >> $GITHUB_ENV
Expand All @@ -164,28 +164,28 @@ jobs:
# for publishing the results of provider verification.
if [[ -z "${{ inputs.pb-event-type }}" ]]; then
echo "PROVIDER_BRANCH=${{ env.CURRENT_BRANCH }}" >> $GITHUB_ENV
echo "PROVIDER_VERSION=${{ needs.regulated-tag-job.outputs.new-tag }}" >> $GITHUB_ENV
echo "PROVIDER_VERSION=${{ needs.regulated-tag-job.outputs.app-version }}" >> $GITHUB_ENV
else
echo "PROVIDER_VERSION=${{ env.PROVIDER_TAG }}" >> $GITHUB_ENV
fi

- name: Switch to appropriate provider branch
run: |
echo "This workflow has been triggered by '${{ github.event_name }}' event."

# If the PROVIDER_TAG envvar exists, switch to the corresponding tag.
# This condition is true when the workflow is triggered by a Pact Broker webhook event.
if [[ -n "${{ env.PROVIDER_TAG }}" ]]; then
echo "git checkout tags/${{ env.PROVIDER_TAG }}"
git checkout tags/${{ env.PROVIDER_TAG }}

# Otherwise, switch to CURRENT_BRANCH if the workflow has been triggered by a
# PR commit or merge onto the main branch.
elif [[ "${{ github.event_name }}" == "pull_request" ]] || [[ "${{ github.event_name }}" == "push" ]]; then
echo "git checkout ${{ env.CURRENT_BRANCH }}"
git checkout ${{ env.CURRENT_BRANCH }}
fi

# Echo the HEAD commit of the provider branch that has been switched to.
echo "git rev-parse HEAD"
git rev-parse HEAD
Expand Down Expand Up @@ -306,7 +306,7 @@ jobs:
echo "env.PROVIDER_BRANCH=${{ env.PROVIDER_BRANCH }} # This reflects the provider branch to switch to for pact verification"
echo "env.CONSUMER_VERSION=${{ env.CONSUMER_VERSION }} # This reflects the consumer version for pact verification (generated by Pact Broker)"
echo "env.PROVIDER_VERSION=${{ env.PROVIDER_VERSION }} # Deprecate env.PACT_PROVIDER_COMMIT. This new envvar is used for migrating GIT hash to app versioning"

# Refer to https://github.com/sbt/docker-sbt on this Docker image
# Recent sbt versions use Coursier instead of Ivy for dependency management.
# On Linux, the location is
Expand Down
Loading