Skip to content

Reuse workflows - second attempt!#40

Merged
simlmx merged 2 commits intomainfrom
reusable-workflows-2
Mar 28, 2023
Merged

Reuse workflows - second attempt!#40
simlmx merged 2 commits intomainfrom
reusable-workflows-2

Conversation

@simlmx
Copy link
Contributor

@simlmx simlmx commented Mar 28, 2023

Background

This is very similar to #36 which turned out to break in some places and was reverted in #37. Here I fix the issue and extract even more steps into reusable workflows.

The issue was that we were checking out the code before the version bump commit. When one job creates a new commit, we must checkout main explicitly, otherwise it defaults to the last commit at the time the workflow was started.

Description

Instead of copy pasting a lot of code between workflows, we reuse simpler workflows. These are new:

  • bump-version
  • github-release
  • publish-to-pypi
  • push-docker

Also:

  • Relax the job dependencies in the workflows: only bump-version needs to be done before the other ones. This means more parallelism.
  • Support submodules in docker-release-only workflow
  • Rename "new_tag" -> "new_ver"
  • Bump jasonamyers/github-bumpversion-action to 1.0.5
  • Uniformize job names
  • Remove workdir option (it wasn't used anywhere)

This should in theory be fully backward compatible with 1.0.0.

Tests

@simlmx simlmx force-pushed the reusable-workflows-2 branch from 12bbec4 to cf69a52 Compare March 28, 2023 02:00
@simlmx simlmx marked this pull request as ready for review March 28, 2023 02:43
@simlmx simlmx requested review from jacobbieker and peterdudfield and removed request for jacobbieker March 28, 2023 02:44
Copy link
Contributor

@peterdudfield peterdudfield left a comment

Choose a reason for hiding this comment

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

Looks good. Last time the bump version didnt work when doing a new release. We could check this by

  • pinned a repo to this branch, maybe PVConsumer
  • do a release (check it works)
  • merge this
  • change back to main on PVConsumer

@peterdudfield
Copy link
Contributor

Looks good. Last time the bump version didnt work when doing a new release. We could check this by

  • pinned a repo to this branch, maybe PVConsumer
  • do a release (check it works)
  • merge this
  • change back to main on PVConsumer

It worked - https://github.com/openclimatefix/PVConsumer/actions/runs/4540372174/jobs/8001227925

# a commit on top of the default commit to which the action would be otherwise pointing.
ref: main
submodules: ${{ inputs.checkout_submodules }}
- name: Docker meta
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add the 'tag_value' in the name, this makes it really easy to see what docker image is being built.

This is what I often do, merge the PR to main, look at workflow new tag, and then update it on terraform cloud

Copy link
Contributor Author

@simlmx simlmx Mar 28, 2023

Choose a reason for hiding this comment

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

Do you mean adding back the run: echo ${{ needs.build.outputs.new_tag }} that I remove?

Or actually having something like name: Docker meta ${{ inputs.tag_value }}?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes please, or some easy way to see what version is being built

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is what I've got:
Cursor_and_test_·_openclimatefix__github-test_e0a850f

Copy link
Contributor

@peterdudfield peterdudfield left a comment

Choose a reason for hiding this comment

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

Looks good Simon,

One small comment

Copy link
Member

@jacobbieker jacobbieker left a comment

Choose a reason for hiding this comment

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

LGTM!

@simlmx simlmx force-pushed the reusable-workflows-2 branch 7 times, most recently from 50dbcb6 to c874905 Compare March 28, 2023 13:52
simlmx added 2 commits March 28, 2023 13:57
Instead of copy pasting a lot of code between workflows, we reuse
simpler workflows. These are new:

* bump-version
* github-release
* publish-to-pypi
* push-docker

Also:
* Support submodules in docker-release-only workflow
* Rename "new_tag" -> "new_ver"
* Bump jasonamyers/github-bumpversion-action to 1.0.5
* Uniformize job names
* Remove `workdir` option (it wasn't used anywhere)
@simlmx simlmx force-pushed the reusable-workflows-2 branch from c874905 to 68ee60a Compare March 28, 2023 13:57
@simlmx simlmx merged commit 68ee60a into main Mar 28, 2023
@simlmx simlmx deleted the reusable-workflows-2 branch March 28, 2023 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants