Skip to content

TST: Skip CI in Action - #11168

Merged
saimn merged 2 commits into
astropy:masterfrom
pllim:actions-ci-skip
Jan 17, 2021
Merged

saimn merged 2 commits into
astropy:masterfrom
pllim:actions-ci-skip

Conversation

@pllim

@pllim pllim commented Dec 15, 2020 •

Copy link
Copy Markdown
Member

Description

This pull request is to implement a workaround to enable skipping CI in Actions portion of #11038 .

This uses custom Action at action-skip-ci and styfle/cancel-workflow-action.

If this works correctly, only one Action job would run and it will fail set output value, preventing other jobs from running. What is not showcased here is that duplicate runs would also be cancelled if the CI is not skipped (I tested this on my own repo).

Screenshot 2021-01-07 183342

If this needs backporting, please re-milestone.

@pllim pllim added this to the v4.3 milestone Dec 15, 2020
@pllim

This comment has been minimized.

@pllim
pllim requested review from saimn and taldcroft December 15, 2020 19:38
@pllim pllim mentioned this pull request Dec 15, 2020
18 tasks done
@saimn

saimn commented Dec 16, 2020

Copy link
Copy Markdown
Contributor

I suppose the CI / ${{ matrix.name }} (pull_request) builds are because you use dependencies between builds to not run them if the ci-skip one fails.
It's also a bit annoying to have to run a docker for this, with the time it takes. But I'm not ready to learn typescript right now to avoid this ;), and couldn't find third party actions that do it better, so I guess it's fine for now.

@pllim

pllim commented Dec 16, 2020

Copy link
Copy Markdown
Member Author

I was about to add https://github.com/pllim/actions-cancel-workflows here too (tested at kali-maa#42) but now I am not sure with your comment about Docker being slow. Should I just use the third-party Action (https://github.com/styfle/cancel-workflow-action)? For that third-party one, I couldn't vet the code because its dist/index.js has over 6000 LOC, but I see other repos using it, including Apache and Google (though those repos might just be some employee pet projects or something, as they don't look high profile). 🤷

@pllim

This comment has been minimized.

@pllim
pllim marked this pull request as draft December 16, 2020 02:06
@saimn

saimn commented Dec 16, 2020

Copy link
Copy Markdown
Contributor

Well, it's just that needing a docker build which takes ~1min just to check some string in a commit message seems a bit overkill, but I don't have a better solution for now ...
For the "skip workflow" one, the source for https://github.com/pllim/actions-cancel-workflows in typescript is ~80 lines and relatively easy to understand (https://github.com/styfle/cancel-workflow-action/blob/main/src/index.ts), and I guess runs much faster than in a docker. If we can avoid multiple builds with docker taking minutes before the actual test builds, it seems better, or maybe we can combine all our custom actions in a unique docker build that would skip ci, kill running workflows, etc ?

@pllim

pllim commented Dec 16, 2020 •

Copy link
Copy Markdown
Member Author

I was talking about this file, which I think index.ts calls: https://github.com/styfle/cancel-workflow-action/blob/main/dist/index.js

Speed wise, there are two possible solutions but none of them pretty:

  • Like you said, combine everything into one giant custom action -- This will really complicate the logic, especially if you want to customize pieces of them in the future. Also might render it unusable for anything else other than core lib (e.g., smaller package might not want all the bells and whistles).
  • Move the custom actions into core lib as scripts (can exclude them from manifest and so on) and have the CI run them as steps instead of individual jobs. This way, I don't think you need Docker as theoretically it would just use the Python you installed in the previous step. This would definitely only make them usable only in core lib.

@pllim
pllim force-pushed the actions-ci-skip branch 5 times, most recently from 90e5b11 to 63e966e Compare December 16, 2020 21:20
@pllim

This comment has been minimized.

@pllim

pllim commented Dec 16, 2020 •

Copy link
Copy Markdown
Member Author

FWIW, it seems to work at https://github.com/pllim/playpen/runs/1566774010?check_suite_focus=true but I'll have to wait till Actions un-blacklist me here to find out for sure.

Also, I have it pull the Docker image now instead of creating from scratch, so the "build" part went down from over a minute to 18s. Maybe it is more bearable this way?

"[ci skip]" found in "fix yaml [ci skip]", cancelling this workflow
Cancelled WorkflowRun(url=..., id=426714081)

Let's defer the cancel duplicate runs to another PR. One thing at a time.

@pllim

pllim commented Dec 16, 2020

Copy link
Copy Markdown
Member Author

No, something is still not right. It tried to cancel but it didn't work. Maybe it is grabbing the token from my fork, which does not have the power to cancel jobs here upstream? If that is the case, we cannot know if the cancelling will work until this is merged. 🤷

https://github.com/astropy/astropy/pull/11168/checks?check_run_id=1566876617

"[skip ci]" found in "tst: skip ci in action [skip ci]", cancelling this workflow
Cancelled WorkflowRun(url=..., id=426750801)

@pllim
pllim marked this pull request as ready for review December 16, 2020 22:28
@pllim
pllim marked this pull request as draft December 16, 2020 23:45
@pllim

pllim commented Dec 16, 2020 •

Copy link
Copy Markdown
Member Author

Cancelling does not work at kali-maa#43 . I need to understand this inconsistency.

I think I have convinced myself that when a PR is opened from a fork, the canceling does not work. So, I think I have to go back to failing this outright.

@saimn

saimn commented Dec 17, 2020

Copy link
Copy Markdown
Contributor

I was talking about this file, which I think index.ts calls: https://github.com/styfle/cancel-workflow-action/blob/main/dist/index.js

The javascript file is generated from the typescript one ;)

Also, I have it pull the Docker image now instead of creating from scratch, so the "build" part went down from over a minute to 18s. Maybe it is more bearable this way?

Yes, seems much better 👍

@pllim

This comment has been minimized.

@pllim
pllim marked this pull request as ready for review December 17, 2020 01:47
@pllim

This comment has been minimized.

@pllim

pllim commented Dec 23, 2020 •

Copy link
Copy Markdown
Member Author

I rewrote it in TypeScript. Now it takes 3s to run. I still think we should implement the cancel duplicate workflows one as a separate PR. I am quite done with this one until I hear back via reviews. Thanks!

UPDATE: I was testing the Action that Simon talked about and it worked well and though might as well add it here.

UPDATE 2: I pinned the third-party action to its release hash, just in case.

TST: Add a step to also cancel prev runs and pin it to release hash.
@pllim

pllim commented Jan 7, 2021

Copy link
Copy Markdown
Member Author

Thanks to brilliant idea from @eslavich over at spacetelescope/jwst#5591 , I updated the Action to not fail, so now you get your nice green check mark and also cancelled jobs.

@mhvk

mhvk commented Jan 8, 2021

Copy link
Copy Markdown
Contributor

Yay for keeping at it! It sounds very nice now, and also extensible. Will you make the javascript part of the PR? In any case, do change the message actually shown ("Failure means CI is skipped on purpose").

@pllim

This comment has been minimized.

@mhvk

mhvk commented Jan 8, 2021

Copy link
Copy Markdown
Contributor

I meant whatever is in "pllim/action-skip-ci@main" and the other one!

@pllim

pllim commented Jan 8, 2021

Copy link
Copy Markdown
Member Author

I fixed the bug upstream in the action.

whatever is in "pllim/action-skip-ci@main" and the other one

Ah, I thought I linked them above. But here they are again. This time, I'll link to the actual TypeScript where the implementation is.

@saimn

saimn commented Jan 17, 2021

Copy link
Copy Markdown
Contributor

So this PR seems ready right ? It looks great and I think we should start to use it and see how it goes.

@pllim

pllim commented Jan 17, 2021

Copy link
Copy Markdown
Member Author

Yeah, I have been using it myself. If we move the code to some org, I'll batch PR to update all affected packages.

@saimn saimn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok, let's move forward and get this in. Thanks @pllim!

@saimn
saimn merged commit fa9007c into astropy:master Jan 17, 2021
@mhvk

mhvk commented Jan 17, 2021

Copy link
Copy Markdown
Contributor

Hurray! 🎆

I immediately used in #11222 where @saimn had asked for a small change to the changelog entry. Saved the world ~10x6minx100W ~0.1 kWhr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants