Conversation
|
After this PR is merged we need manually update |
jacekbogdanski
left a comment
There was a problem hiding this comment.
Looks good, some minor changes required.
| echo "BRANCH_NAME=${{ github.ref }}" >> $GITHUB_ENV | ||
| if [[ -f "./.github/workflows-config.json" ]]; then | ||
| pushAsPullRequest=$(jq ".setupWorkflows.pushAsPullRequest" "./.github/workflows-config.json") | ||
| if [[ "$pushAsPullRequest" == true ]]; then | ||
| echo "AS_PR=1" >> $GITHUB_ENV | ||
| echo "BRANCH_NAME=t/setup-workflows-update" >> $GITHUB_ENV | ||
| git checkout -b t/setup-workflows-update | ||
| fi | ||
| fi |
There was a problem hiding this comment.
Maybe we could load JSON file into the env variable as a separate, initial step, so the config is available everywhere? I was thinking about some separate step like:
- name: Load settings
run: |
echo "SETTINGS={}" >> $GITHUB_ENV
if [[ -f "./.github/workflows-config.json" ]]; then
echo "SETTINGS=${{ jq './.github/workflows-config.json }}" >> $GITHUB_ENV
fi
and then use it everywhere as e.g. jq -n .setupWorkflows.pushAsPullRequest (should return "null" if nothing found). WDYT?
Also, maybe there is some better way to keep settings somehow easily accessible? Overall it should work for our case now, but any other setting will require duplicated logic for loading config which may be a bit of pain.
If we go with some good approach here, we will be able to just copy it in any action using config file.
There was a problem hiding this comment.
Makes perfect sense. The best approach would be probably extracting config reading logic to separate action (so it can be called with two lines) or adding as external script to be reused.
However, as this is quite simple code I'm for adding it as initial step for now to each workflow which needs it (using copy/paste) and then we can see how problematic it is. I will also add short README section on this.
| This is the main workflow responsible for propagating all common workflows. When it is added to any other repository it checkouts this repository and copies all common workflows from `workflows/` directory to `.github/workflows/` one. It is done once a day so any changes are propagated on a daily basis. See `workflows/setup-workflows.yml` file. | ||
|
|
||
| It is a cron job task so will be triggered only on main repository branch. |
There was a problem hiding this comment.
Maybe we could add information when cron runs the action? (02:00 UTC).
We could also add this information to other actions.
|
|
||
| #### Optional secrets | ||
|
|
||
| * `BRANCH_MAIN` - Target branch name. By default, workflow runs on main repository branch. |
There was a problem hiding this comment.
I'm wondering if it shouldn't be a part of new settings json file? We could default it into github.ref if not set (depending on the action). The good part is that we will be able to configure the branch per action if needed, and setting env variables is less friendly than config.
|
I have updated https://github.com/ckeditor/workflows-test-1 and https://github.com/ckeditor/workflows-test-2 withe latest changes. |
|
I see this line pushAsPullRequest=$(echo ${{ env.SETTINGS }} | jq ".pushAsPullRequest")doesn't work as it should (see here) resulting in pushAsPullRequest=$(echo {} | jq ".pushAsPullRequest")so this still needs to be fixed. |
Align with latest ckeditor/ckeditor4-workflows-common#12.
Aligned with latest ckeditor/ckeditor4-workflows-common#12.
Align with latest ckeditor/ckeditor4-workflows-common#12
…ve redundant 'Setup node' action.
|
I had some hard time providing proper loading for config files but it seems to be working now. Also, it seems adding manual dispatch for some jobs could be useful (and also helpful for testing). And so: update-deps
All steps passes until NPM update since there is no setup-worfklows
So it seems everything works fine but testing it is kind of cumbersome. |
|
As for testing workflows locally there is already mentioned act and some other approaches like creating and testing CI-agnostic parts (e.g. https://stackoverflow.com/a/59988803/646871) |
|
Ready for another review. |
I added checking if the PR branch already exists - in such cases, workflow will be simply canceled.
We were thinking about it on a very beginning but since it is "setup and forget' and requires minimal amount of work (copy-paste |
|
@sculpt0r ready for another review. |
1 similar comment
|
@sculpt0r ready for another review. |
Also sounds like a good idea :) Now However, I can't figure out where is the misspell or syntax error... 🤔 Could you take a look there? |
@sculpt0r taken over this review.
|
@sculpt0r ready for another review. |
|
#12 (comment) Seems to work right now :) You use cancel build action. The description says Could you take another look into the 'canceling' method and try to improve it? |
Ok, it seems like that's the case. This cancel action is kind of a workaround, since it's not that straightforward to cancel action from within itself:
As for the solution to the cancel action delay, we can add wait action after - if the job needs to be cancel, the cancel step is executed and then wait step. Otherwise, those to steps will be simply skipped. |
As mentioned above, I've added wait step - c93ee5b. |
|
@sculpt0r ready for another review 🤞 |
LGTM 🎉 A few runs and it ends with proper cancelation. Of course, it elongates waiting time before any results - but since it's automatic - it's fine. |
As mentioned in #6 (comment):
So I went with configuration option which allows to alter the workflow to create PR instead of pushing directly to main branch. Since it doesn't make sense to keep configuration in GH secrets I have introduced optional JSON config file (#4).
The above needs proper explanation so I took this occasion to improve README file and describe all common workflows we have now.
The default flow and the one wit PR were tested in separate test repos:
Closes #6. Closes #4.