Skip to content

Commit

Permalink
Add run-all-tests label to disable selection execution on PRs (#4130)
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi authored Dec 14, 2024
1 parent 4a1e37a commit 28b07d9
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .config/mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.3-58-4a0046
0.12.3-66-40e41b
9 changes: 7 additions & 2 deletions .github/actions/post-build-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ runs:

# Need to fix cached artifact file permissions because github actions screws it up
# https://github.com/actions/upload-artifact/issues/38
- name: chmod executable
run: "chmod -R +x ."
- run: "chmod -R +x ."
shell: bash

- uses: coursier/cache-action@v6

- run: git config --global user.email "you@example.com"
shell: bash

- run: git config --global user.name "Your Name"
shell: bash
5 changes: 0 additions & 5 deletions .github/workflows/post-build-selective.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,8 @@ jobs:
log-accepted-android-sdk-licenses: false

- run: ./mill -i -k selective.resolve ${{ inputs.millargs }}
if: github.event_name == 'pull_request'

- run: ./mill -i -k selective.run ${{ inputs.millargs }}
if: github.event_name == 'pull_request'

- run: ./mill -i -k ${{ inputs.millargs }}
if: github.event_name != 'pull_request'

- run: 'taskkill -f -im java* && rm -rf out/mill-server/*'
if: startsWith(inputs.os, 'windows')
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pre-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ jobs:

- run: chmod -R 777 . # normalize permissions before and after upload/download-artifact

- run: mkdir out && touch out/mill-selective-execution.json
shell: bash

- run: ./mill -i -k selective.prepare ${{ inputs.prepareargs }}
if: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'run-all-tests') }}

- uses: actions/upload-artifact@v4.4.3
with:
Expand Down
15 changes: 14 additions & 1 deletion main/src/mill/main/SelectiveExecutionModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,20 @@ trait SelectiveExecutionModule extends mill.define.Module {
val result = for {
resolved <- Resolve.Tasks.resolve(evaluator.rootModule, tasks, SelectMode.Multi)
diffed <- SelectiveExecution.diffMetadata(evaluator, tasks)
} yield resolved.map(_.ctx.segments.render).toSet.intersect(diffed).toArray.sorted
resolvedDiffed <- {
if (diffed.isEmpty) Right(Nil)
else Resolve.Segments.resolve(
evaluator.rootModule,
diffed.toSeq,
SelectMode.Multi,
evaluator.allowPositionalCommandArgs
)
}
} yield {
resolved.map(
_.ctx.segments.render
).toSet.intersect(resolvedDiffed.map(_.render).toSet).toArray.sorted
}

result match {
case Left(err) => Result.Failure(err)
Expand Down

0 comments on commit 28b07d9

Please sign in to comment.