Skip to content

Use Scala script for targeted releases#102

Merged
rtyley merged 1 commit intomainfrom
targeted-releases-with-scala-script
Nov 26, 2025
Merged

Use Scala script for targeted releases#102
rtyley merged 1 commit intomainfrom
targeted-releases-with-scala-script

Conversation

@rtyley
Copy link
Member

@rtyley rtyley commented Oct 1, 2025

Here we're continuing work on:

...but switching from using bash to Scala instead.

Testing

I've made several runs using this updated script, and it's now working well.

Preventing 'unconfigured' runs of Scala Steward

Workflow Run 13 did not go as expected - when given a PR that had not generated a preview release, the script silently failed to generate a targeted-scala-steward.conf - but nothing prevented the next step from occurring, which was running Scala Steward. Consequently Scala Steward ran without any global config (including our normal config, that limits the number of PRs Scala Steward raises & groups the PRs), and raised about 20 individual PRs that it normally would not have.

In order to prevent this happening again, I've ensured that the script will return a non-zero exit code if no-config is generated, which then correctly terminates the workflow without running Scala Steward.

Blockers

@rtyley rtyley force-pushed the targeted-releases-with-scala-script branch 2 times, most recently from 8eb02be to 982bf8f Compare October 1, 2025 13:57
@rtyley
Copy link
Member Author

rtyley commented Oct 1, 2025

Weirdly, although the test run was mostly successful, it did do one weird thing - open 1 of the 8 PRs it raised as non-draft:

image

https://github.com/guardian/scala-steward-public-repos/actions/runs/18164577794/job/51703329773#step:8:1831

I can not see why this would have happened...!

cc @jonathonherbert

@rtyley
Copy link
Member Author

rtyley commented Oct 2, 2025

Weirdly, although the test run was mostly successful, it did do one weird thing - open 1 of the 8 PRs it raised as non-draft

I've figured out why that 1 repository got a non-draft PR - it exposed a Scala Steward bug which I'm now fixing with this PR:

...basically that repo had a .scala-steward.conf with some pullRequests.xxx entries in it - but no pullRequests.draft:

https://github.com/guardian/typerighter/blob/d6461c6782a9734707166f3eb825ede28c29c20d/.scala-steward.conf#L5

...due to the bug, for pullRequests.draft being not-set took precedence over being set!

rtyley added a commit to scala-steward-org/scala-steward that referenced this pull request Oct 2, 2025
…mbined with _unset_ config

This fixes a bug that came in with the initial introduction of the `pullRequests.draft` config setting with this PR:

* #3628

The bug was that when combining global & local repo config, the result of combining `pullRequests.draft = true` with a config with _no_ setting for `pullRequests.draft` would be that `pullRequests.draft` was _unset_ (ie given the value `None`, rather than `Some(true)`.

This is because of the behaviour of `.mapN()`, which I hadn't really thought through:

https://github.com/scala-steward-org/scala-steward/blob/373d5a70533a024389bb93f5028d0fee81a6cbd6/modules/core/src/main/scala/org/scalasteward/core/repoconfig/PullRequestsConfig.scala#L66

...in retrospect, it's not too surprising that `.mapN()` on two `Option`s only produces a populated `Some` if _both_ the inputs are `Some` - which is not the behaviour we want here. For us, if only _one_ of the configs has a value set, we definitely want to use that value.

In the end, the neatest way I could find to get the desired behaviour was to remove the thing stopping us from having a `Monoid[Option[Boolean]]` - ie that there is no _general_ `Monoid[Boolean]` (there is no _one_ correct way to combine two `Boolean`s). We can create a specific one for this case, that says `Boolean`s should be combined with logical-`OR` (rather than `AND`, for instance) - and only expose it in the very narrow scope of where we want to use it.

* guardian/scala-steward-public-repos#102 (comment)
@rtyley
Copy link
Member Author

rtyley commented Oct 2, 2025

The config generated here (for an sbt plugin...) looks incorrect - why is there still a Scala version in the artifact name (sbt-scrooge-typescript_2.12)?:

Wrote config to /home/runner/work/scala-steward-public-repos/scala-steward-public-repos/targeted-scala-steward.conf

updates.allow = [{"groupId":"com.gu","artifactId":"sbt-scrooge-typescript_2.12","version":"4.0.0-PREVIEW.fpdowngrade-scrooge.2025-10-02T0939.1433794d"},{"groupId":"com.gu","artifactId":"scrooge-generator-typescript","version":"4.0.0-PREVIEW.fpdowngrade-scrooge.2025-10-02T0939.1433794d"}]

updates.allowPreReleases = [{"groupId":"com.gu","artifactId":"sbt-scrooge-typescript_2.12","version":"4.0.0-PREVIEW.fpdowngrade-scrooge.2025-10-02T0939.1433794d"},{"groupId":"com.gu","artifactId":"scrooge-generator-typescript","version":"4.0.0-PREVIEW.fpdowngrade-scrooge.2025-10-02T0939.1433794d"}]

pullRequests.draft = true
commits.message = "Update ${artifactName} from ${currentVersion} to ${nextVersion}"
pullRequests.grouping = [{
  name = "guardian/scrooge-extras/pull/39",
  title = "Update `scrooge-extras` to 4.0.0-PREVIEW.fpdowngrade-scrooge.2025-10-02T0939.1433794d",
  filter = [{"group" = "*"}]
}]

rtyley added a commit to scala-steward-org/scala-steward that referenced this pull request Oct 2, 2025
…mbined with _unset_ config

This fixes a bug that came in with the initial introduction of the `pullRequests.draft` config setting with this PR:

* #3628

The bug was that when combining global & local repo config, the result of combining `pullRequests.draft = true` with a config with _no_ setting for `pullRequests.draft` would be that `pullRequests.draft` was _unset_ (ie given the value `None`, rather than `Some(true)`.

This is because of the behaviour of `.mapN()`, which I hadn't really thought through:

https://github.com/scala-steward-org/scala-steward/blob/373d5a70533a024389bb93f5028d0fee81a6cbd6/modules/core/src/main/scala/org/scalasteward/core/repoconfig/PullRequestsConfig.scala#L66

...in retrospect, it's not too surprising that `.mapN()` on two `Option`s only produces a populated `Some` if _both_ the inputs are `Some` - which is not the behaviour we want here. For us, if only _one_ of the configs has a value set, we definitely want to use that value.

In the end, the neatest way I could find to get the desired behaviour was to remove the thing stopping us from having a `Monoid[Option[Boolean]]` - ie that there is no _general_ `Monoid[Boolean]` (there is no _one_ correct way to combine two `Boolean`s). We can create a specific one for this case, that says `Boolean`s should be combined with logical-`OR` (rather than `AND`, for instance) - and only expose it in the very narrow scope of where we want to use it.

* guardian/scala-steward-public-repos#102 (comment)
@rtyley rtyley force-pushed the targeted-releases-with-scala-script branch 11 times, most recently from c42c15c to ce48ba0 Compare October 8, 2025 09:47
Give a warning when we can't generate config - probably because no preview is available
@rtyley rtyley force-pushed the targeted-releases-with-scala-script branch from 8c6dfc2 to b656f1b Compare November 11, 2025 18:19
@rtyley rtyley marked this pull request as ready for review November 11, 2025 18:26
@rtyley rtyley requested a review from a team as a code owner November 11, 2025 18:26
@rtyley rtyley merged commit fb14fa6 into main Nov 26, 2025
2 checks passed
@rtyley rtyley deleted the targeted-releases-with-scala-script branch November 26, 2025 16:07
@rtyley rtyley restored the targeted-releases-with-scala-script branch November 26, 2025 16:07
@rtyley rtyley deleted the targeted-releases-with-scala-script branch November 26, 2025 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants