Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Conversation

@galargh
Copy link
Contributor

@galargh galargh commented Dec 8, 2021

Description

Both dispath.yml and copy-workflow.yml have accumulated a fair share of go specific setup. In this PR I'm trying to generalise both of these workflows to enable setting up unified CI for JS repos.

Moving config JSONs to configs directory

With JS adoption we're expecting more JSON config files to be needed. I propose to store all the config JSON files in a designated configs directory so that they're easy to find. This also allows us to use matching patterns like configs/*.json in various places.

Specifying what files should be copied for particular configuration

I have decided to create defaults object with files array field inside each config JSON file. The files array defines what files should be copied for that particular workflow by default.

In dispatch workflow, each object from repositories array is mapped to the output of merging the defaults object with the repository object. Thanks to this, it is also possible to override the list of files to be copied on a per repository basis (or other fields that defaults might define):

{
  "defaults": { "files": ["a", "b", "c"] },
  "repositories": [
    { "target": "1", "description": "copy files a, b and c to repository 1" },
    { "target": "2", "files": ["a", "b"], "description": "copy only files a and b to repository 2" }
  ]
}

Having the list of files to be copied in the same file as the list of repositories makes it easier for repo owners to reason about the outcome of adding a repository to the repositories list.

Handling language specific setup in copy-workflow

I have moved go specific setup to copy-workflow-go action. The action is performed iff the target object passed to the copy-workflow has deploy_go field set to true. I have used this pattern to provide specific setup for targets that request deploy_versioning too.

It will also be applicable when we want to introduce more languages, like JS for example. We could just introduce new flags like deploy_monorepo_js, deploy_isomorphic_js, etc.

Testing

@galargh galargh marked this pull request as ready for review December 8, 2021 13:25
@galargh galargh force-pushed the testing-js branch 2 times, most recently from c03b9de to c41af02 Compare December 15, 2021 12:14
@galargh
Copy link
Contributor Author

galargh commented Dec 15, 2021

Since this PR doesn't modify any workflows in the target repositories I propose merging it into the master branch.

Testing after the rebase

@galargh galargh changed the base branch from next to master December 15, 2021 12:28
- name: Check if we need to create a PR
working-directory: ${{ env.TARGET_REPO_DIR }}
run: echo "NEEDS_UPDATE=$(git rev-list HEAD...origin/$(git rev-parse --abbrev-ref HEAD) --ignore-submodules --count)" >> $GITHUB_ENV
run: echo "NEEDS_UPDATE=$(git rev-list HEAD...origin/$(git rev-parse --abbrev-ref HEAD) --ignore-submodules --count 2> /dev/null || echo 1)" >> $GITHUB_ENV
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice one. This is a lot better than working with fake bools (strings).

Copy link
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

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

LGTM!

@galargh galargh merged commit 0ca4a50 into master Jan 7, 2022
@galargh galargh deleted the testing-js branch January 7, 2022 10:06
galargh added a commit that referenced this pull request Jan 7, 2022
* move config*.json files to configs directory

* rename configs/*.json

* make checks aware of all the configs/*.json

* turn configs into objects with repositories key

* make files part of the config

* move language specific copy-workflow setup to actions

* make dispatch workflow support more than one config json

* create fewer batches if possible

* set up copy-workflow actions properly

* extract defaults from config separately

* bring back double toJson

* use copy-workflow actions from same branch

* use compact json representation for storing FILES

* fix files and local actions

* run actions from template repo

* add missing shell property to actions

* add configs README

* set deploy_versioning=true for go repositories

* address review comments

* restore hardcoded template-repo reference

* add section on config testing

* fix batches creation

* fix command that produces batches

* fix needs update logic
@galargh galargh mentioned this pull request Jan 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants