-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/workflow support #65
base: main
Are you sure you want to change the base?
Conversation
@djspiewak |
This is a really nice start! Definitely headed in the right direction, though I have some aesthetic quibbles with file organization. :-P |
Still wip ;) I realised until now, you have the data model separated from the rendering logic. Would you like to keep this? As you can see, I copied some useful methods from My gut feeling says, that |
For simplification, I plan not to implement
I'll add a part about it in the docs. |
- All TriggerEvents have now a corresponding case class/object
- Add new sbt key githubWorkflowCustomWorkflows for custom workflows - Generate custom workflows within githubWorkflowGenerate
@djspiewak I think the model should fit now, as well as the generation. Imo the current state should be fine for an initial release of the feature. |
Open questions:
|
40c53ac
to
c6f0a65
Compare
The os field in build matrices are is not mandatory. On private action runners you may just want to provide custom labels. This is now possible.
When having custom workflows, one might not want to have ci.yml or clean.yml generated. This is now configurable via githubWorkflowGenerationTargets
@djspiewak I am using this version currently in multiple projects and it works well so far. I changed to the way |
@987Nabil does this support adding the |
@catostrophe For custom workflows yes. For the default CI job aka |
@987Nabil that's exactly what I need - to tweak the default ci.yml to run on @djspiewak what's the best way to introduce this feature? As a separate small PR or as a part of this one? |
@catostrophe my suggestion would be: Merge this PR first, then do it separately afterward. I think this PR is quite big already. Even though I guess it might be a small change. |
…pport # Conflicts: # src/main/scala/sbtghactions/GenerativePlugin.scala
@djspiewak I just merged the main. And I am already heavily using it with a local build. Would be nice if you could review this and I could use an official build :) |
@987Nabil Sorry for the delay! Looking at this now |
It would be great to have this revived/merged! |
I would love to see this pull request merged in! ❤️ |
I am here as a backstop, but generally the maintainers are @sbt/sbt-github-actions team. |
@987Nabil I can have a look at it, but to get the premise of the PR by custom workflow you mean the ability to generate a completely custom github action workflow flow with the various actions. If so I can try to look at it during in a week (I have a conference to go to). In the meantime if you could rebase the PR to fix the current merge conflicts that would be great! Also agree with @eed3si9n regarding the documentation |
@eed3si9n sorry, I just saw SBT org and you changing something, so I assumed 😅 @mdedetrich basically it aims to be a scala DSL for actions/workflows. And yes, the goal is to not change any api but just extend it. |
@987Nabil Thanks for the response, as mentioned before I will realistically look at it from next week Monday but if I can find some time I might start earlier. I suspect that the reason behind the merge conflicts is the permissions feature at #105 which I wrote and was consequently merged. On the surface I think it actually makes sense to incorporate that feature into your DSL when doing the rebase. |
@mdedetrich there where also changes to the GitHub api. So I'd like to update anyway. I'll check on it today or maybe tomorrow. |
Perfect thanks! |
@mdedetrich Sorry it might take longer than I expected. Maybe I can find some time today. |
…pport # Conflicts: # src/main/scala/sbtghactions/GenerativePlugin.scala # src/test/scala/sbtghactions/GenerativePluginSpec.scala
No worries, no rush |
@mdedetrich I guess this is now in a reviewable state. The branch is up to date and I migrated the permissions. I simplified and generalized some code a bit. This comes with a little less beautiful workflows (see the missing empty lines), but is an overall benefit I guess, also in terms of maintainability. Also I did not check, if this state on the same feature level as the latest github api. |
@987Nabil Thanks, I will start looking at it in a few days. Note that some of the scripted tests are still failing |
@@ -617,16 +617,6 @@ ${indentOnce(workflow.jobs.map(compileJob(_, sbt)).mkString("\n\n"))} | |||
} else { | |||
githubWorkflowSbtCommand.value | |||
} | |||
//compileWorkflow( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@987Nabil What is the context behind this test being commented, i.e. is it temporary to pass CI or is it intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was only an example I copied for how the current call looks like. I forgot to remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realised it is already gone.
Reviewing this today |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall very nice work. I just have some minor comments (apologies for the spam regarding documentation for the DSL, its just easier to track).
I do have one question regarding how githubWorkflowJavaVersions
/githubWorkflowOSes
/ interact with this PR?
*/ | ||
|
||
package sbtghactions | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add documentation with the @see
to the equivalent github documentation (incase something changes/breaks), see https://github.com/sbt/sbt-github-actions/blob/main/src/main/scala/sbtghactions/PermissionScope.scala#L21-L23 for an example
*/ | ||
|
||
package sbtghactions | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add documentation with the @see
to the equivalent github documentation (incase something changes/breaks), see https://github.com/sbt/sbt-github-actions/blob/main/src/main/scala/sbtghactions/PermissionScope.scala#L21-L23 for an example
*/ | ||
|
||
package sbtghactions | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add documentation with the @see
to the equivalent github documentation (incase something changes/breaks), see https://github.com/sbt/sbt-github-actions/blob/main/src/main/scala/sbtghactions/PermissionScope.scala#L21-L23 for an example
*/ | ||
|
||
package sbtghactions | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add documentation with the @see
to the equivalent github documentation (incase something changes/breaks), see https://github.com/sbt/sbt-github-actions/blob/main/src/main/scala/sbtghactions/PermissionScope.scala#L21-L23 for an example
@@ -115,6 +116,7 @@ Any and all settings which affect the behavior of the generative plugin should b | |||
- `githubWorkflowJobSetup` : `Seq[WorkflowStep]` – The automatically-generated checkout, setup, and cache steps which are common to all jobs which touch the build (default: autogenerated) | |||
- `githubWorkflowEnv` : `Map[String, String]` – An environment which is global to the entire **ci.yml** workflow. Defaults to `Map("GITHUB_TOKEN" -> "${{ secrets.GITHUB_TOKEN }}")` since it's so commonly needed. | |||
- `githubWorkflowAddedJobs` : `Seq[WorkflowJob]` – A convenience mechanism for adding extra custom jobs to the **ci.yml** workflow (though you can also do this by modifying `githubWorkflowGeneratedCI`). Defaults to empty. | |||
- `githubWorkflowCustomWorkflows`: `Map[String, Workflow]` - This is the place to define your custom workflows. The key represents the filename (**.yml** is added if not provided) the value the workflow definition. The settings of the generative plugin apply, as long as they are not part of the workflow trigger events. For example, the `githubWorkflowTargetBranches` setting has no influence on custom workflows, but `githubWorkflowScalaVersions` does. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about keys like githubWorkflowJavaVersions
or githubWorkflowOSes
? Is this supported (if not I suspect that this may be a case of feature creep but having the ability to interpolate these keys into custom workflows would be useful/beneficial if practical).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what you have in mind, but this is now a very general API. It might be, that there is not even a java version needed for the workflow. Also GitHub has the feature of self hosted runners, that might not have the tags for the oses. So that might be confusing for the user. I guess using this keys should be up to the one defining the Workflows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So to put it differently, what I had is having the ability to use the githubWorkflowJavaVersions
/githubWorkflowOSes
values in a custom ReusableWorkflowJob
. While its definitely true that it doesn't make sense in some cases, at least having access to those values can be useful for certain types of custom workflows which this PR implements as a feature.
What I had in mind is adjusting ReusableWorkflowJob
so that it has the https://github.com/sbt/sbt-github-actions/pull/65/files#diff-535533c663b9848aff0c0b943149d3dd8b126b34aa463e507ada7e6011ce8288R38-R39 so that it has the scalas
and javas
variables.
See https://github.com/sbt/sbt-github-actions/pull/65/files#r1117907905.
@987Nabil Did you have time to look into the review comments? Also @armanbilge incase you have time to review the PR yourself. |
Sorry @mdedetrich for some reason I did not get notified and I just saw it. I'll check it soon. |
name: String, | ||
uses: WorkflowRef, | ||
cond: Option[String] = None, | ||
needs: List[String] = List(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also add javas
and scalas
here (like with WorkflowJob
) so that these values can be accessable if someone wants to create a custom workflow that uses those values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not so sure about that. I think you can make a very good argument, that it is after this PR more or less a smell, that WorkflowJob
does not just represent the GH api and that as a pure data structure should only do that.
And yes, I bring this argument, because I think it is the better design. What I did not think about yet is, if this would bing migration issues.
But I think, in a perfect world there would be no oses
, javas
and scalas
here, but the plugin would build the right WorkflowJob
out of the sbt keys before rendering it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After thinking about it, I think it does make sense in a future PR because as you said some things might need to be moved around and this PR has already been open for some time. The reason I brought this up is because this is actually a usecase for one of the projects I maintain, i.e. we definitely have a use for custom workflows however we are still going to be running jobs on JVM's defined by githubWorkflowJavaVersions
and OS's defined by githubWorkflowOSes
(amongst other things) and without such a change you basically have to redefine the exact same values (once in githubWorkflowJavaVersions
and another in your custom workflow) which also has the obvious risk of them accidentally going out of sync.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You actually don't need to have any risk. You will define the workflow anyway in an sbt file or your own sbt plugin. And there you can know the key. You can just use it somewhat like this.
val SetupScala: WorkflowStep.Use = WorkflowStep.Use(
name = Some("Setup Java and Scala"),
ref = UseRef.Public("coursier", "setup-action", "v1"),
params = Map("jvm" -> GenerativeKeys.githubWorkflowJavaVersions.value.head.version),
)
What I could understand is, having a method on the data types like withJavaVersions
that sets a matrix up in the right way. But I would really remove every data from the structure that is not a reflection of the github api.
If you like, we could try to have a call and try to talk about a strategy for this or pairing on a follow up issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you like, we could try to have a call and try to talk about a strategy for this or pairing on a follow up issue.
Sure! Next week I will have some time (feel free to email me to discuss, its on my profile)
For now I will merge the PR in a few days to see if we can get any more additional reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving PR
@armanbilge I will wait till mid next week if you have a few comments, at which point I will merge. |
@mdedetrich Is there something blocking this except the merge conflicts? If not I'd solve this asap to merge it. |
So I want to give some context behind whats going on, I spoke with @armanbilge and currently right now there is an issue where this project needs another active maintainer that actually uses this project (which is as of now is just me). Due to this I decided to try and make a Once In regards to merge conflicts, there will be one more additional non trivial PR merge which is #136. After that point I will upstream some of the relevant bug fixes in typelevels fork of sbt-github-actions (they ended up forking this project because it wasn't maintained) which may generate more conflicts. If you have the time to merge the conflicts than that would be great, otherwise I can also just push the merge conflicts on your branch as the mentioned changes start rolling in. |
@mdedetrich I want to check on what the status here. Do you see a chance to get this in somehow? I am willing to fix things, but want to make sure I don't work on something that can't succeed :) |
Impl. #7