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

chore: workflows call workflows #7089

Merged
merged 3 commits into from
May 24, 2024
Merged

chore: workflows call workflows #7089

merged 3 commits into from
May 24, 2024

Conversation

gastonfournier
Copy link
Contributor

Relying on tags to trigger workflows makes it hard to trace what's happening after a release, currently:

  1. We manually trigger a release workflow
  2. The release workflow executes and tags the new release in code
  3. Several other workflows trigger after matching the tag doing different things: build docker images, tarballs and other things.

This creates a loose dependency between the workflows which are actually part of the same "release workflow" which makes it difficult to spot when one or other dependent workflow fails because the dependency is indirect through the tagging mechanism.

This PR switches to a more direct approach using workflow calls. This will create a graph as shown in the following graph: making it easier to track and identify any problem.

The "drawback" of this approach is that previously we could trigger all dependent workflows at once by creating a tag matching the expected pattern without manually triggering a new release. This limitation can be overcome by adding a manual workflow_dispatch to the workflows using the tag trigger.

Copy link

vercel bot commented May 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 24, 2024 7:34am
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 24, 2024 7:34am

Comment on lines -13 to -16
ignore-push:
description: 'Ignore push to dockerhub. If not set the image will be pushed with the sha of the commit as tag'
required: false
type: boolean
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the ability of ignoring pushes. We never use it, it was mainly for testing this workflow during development

@@ -6,14 +6,8 @@ on:
- main
paths-ignore:
- website/**
tags:
- 'v*'
workflow_call:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 33 to 35
type=semver,pattern={{ version }},enable=${{ github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' }}
type=semver,pattern={{ major.minor }},enable=${{ github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' }}
type=semver,pattern={{ major }},enable=${{ github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't check that the ref starts with tags because the ref will be the one of the branch we're releasing from. Instead, whenever this workflow is called will tag the image with semver, except when called from main (cause we're not releasing from main)

push:
tags:
- 'v*'
workflow_call:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Publishing to npm based on a workflow call. If we want to still publish on tag we can add workflow_dispatch to call this manually

@@ -1,4 +1,4 @@
name: 'Releases'
name: 'Release changelog'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a rename. Keeping this workflow relying on tags because it uses a deprecated action and relies on tag refs. We should migrate this: https://github.com/Unleash/unleash/actions/runs/9125610662/job/25092161594#step:4:3

@@ -35,10 +34,10 @@ jobs:
images: |
unleashorg/unleash-server
tags: |
# only enabled for v* tags:
type=semver,pattern={{ version }},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{ major.minor }},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pattern={{ major.minor }} was wrong, it should be pattern={{ major }}.{{ minor }}

Comment on lines +37 to +40
# only enabled for workflow dispatch except main (assume its a release):
type=semver,pattern={{ version }},enable=${{ github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' }},value=${{ inputs.version }}
type=semver,pattern={{ major }}.{{ minor }},enable=${{ github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' }},value=${{ inputs.version }}
type=semver,pattern={{ major }},enable=${{ github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' }},value=${{ inputs.version }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we explicitly send the value as in https://github.com/ivarconr/unleash-enterprise/pull/1316 (because we're not using the tag to trigger)

Comment on lines -38 to -40
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't get the version from the tag, but we can receive it as an input parameter

- name: Publish static assets to S3
run: |
aws s3 cp frontend/build s3://getunleash-static/unleash/${{ steps.get_version.outputs.VERSION }} --recursive
aws s3 cp frontend/build s3://getunleash-static/unleash/v${{ inputs.version }} --recursive
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to prepend v as that's what we used to get from the tag, but the version number is just the semver without the leading v.

Compared in this test https://github.com/gastonfournier/unleash/actions/runs/9161953548/job/25187925675#step:8:8 against an actual release from unleash: https://github.com/Unleash/unleash/actions/runs/9110390951/job/25045331871#step:8:1

- name: Create release
uses: actions/create-release@v1
uses: softprops/action-gh-release@v2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrading to the same action we're using in enterprise as the one at the left is archived

with:
version: ${{ github.event.inputs.version }}

release-changelog: # TODO this changelog is different than the git-cliff one above
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: I'd like to tackle this later but I want to highlight this for the reviewer

Copy link
Contributor

@chriswk chriswk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea :)

@gastonfournier gastonfournier enabled auto-merge (squash) May 23, 2024 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants