cake-build / cake

:cake: Cake (C# Make) is a cross platform build automation system.
https://cakebuild.net
MIT License
3.89k stars 726 forks source link

GH2863: Add GitHub Actions workflow commands #4033

Closed gitfool closed 1 year ago

gitfool commented 1 year ago

Fixes #2863.

Note: implementation guided by looking at:

@devlead I'd love to squeeze in this pull request just in time for Hacktoberfest. 😉

devlead commented 1 year ago

Could you add some integration tests here: https://github.com/cake-build/cake/blob/develop/tests/integration/Cake.Common/Build/GitHubActions/GitHubActionsProvider.cake

Wonder if group / endgroup should have an IDisposable helper so one could do a using statement like TravisCI fold https://github.com/cake-build/cake/blob/develop/src/Cake.Common/Build/TravisCI/TravisCIDisposableExtensions.cs#L20-L28

That could be in follow up PR tomorrow if your short in time.

gitfool commented 1 year ago

It might take a couple of iterations to get the integration tests working satisfactorily. Bear with me.

gitfool commented 1 year ago

@devlead I see the group but not the message inside the group for some reason. Is this something to do with how the integration tests are run? What am I missing?

2022-10-31T07:36:06.3862735Z ##[group]Cake group
2022-10-31T07:36:06.3863076Z ##[endgroup]
devlead commented 1 year ago

@devlead I see the group but not the message inside the group for some reason. Is this something to do with how the integration tests are run? What am I missing?

2022-10-31T07:36:06.3862735Z ##[group]Cake group
2022-10-31T07:36:06.3863076Z ##[endgroup]

Think it needs to be quoted, example of the command used in wild

if (BuildSystem.GitHubActions.IsRunningOnGitHubActions)
{
    TaskSetup(context=> System.Console.WriteLine($"::group::{context.Task.Name.Quote()}"));
    TaskTeardown(context=>System.Console.WriteLine("::endgroup::"));
}

https://github.com/devlead/DPI/blob/2cd985ee19359486d1911f03f6066d98e99ca2cf/build/helpers.cake#L30-L34

Result: image https://github.com/devlead/DPI/actions/runs/3348953578/jobs/5548532403#step:5:28

devlead commented 1 year ago

Hmm also looks like :: instead of ## 🤔

gitfool commented 1 year ago

No, doesn't need to be quoted, and that output is from the log which seems to be related to azure pipelines legacy. Basically the group is working fine. It's the following information output that's missing. Same problem with the secret test.

I've been using (unquoted) groups for a while: https://github.com/gitfool/Cake.Dungeon/blob/3d9f8c6fd79cb74089e7f4d6d70c68fda5c20662/scripts/bootstrap.cake#L24-L38

image

gitfool commented 1 year ago

Annotations are working as expected. It's only the Information output that's missing. I expect it will work fine outside of the integration tests. Good enough for now?

devlead commented 1 year ago

Annotations are working as expected. It's only the Information output that's missing. I expect it will work fine outside of the integration tests. Good enough for now?

Ah, the information you won't see as the integration tests run at a lower verbosity.

I switched to a Console.WriteLine if it turns up I'm happy ;)

devlead commented 1 year ago

@gitfool your changes have been merged, thanks for your contribution 👍