Skip to content

Commit dd48bfb

Browse files
committed
wip
1 parent 76ea3dc commit dd48bfb

File tree

2 files changed

+50
-30
lines changed

2 files changed

+50
-30
lines changed

.github/workflows/buildBisect.yaml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: "Open CB: bisect"
2-
run-name: ${{ inputs.build-name != '' && inputs.build-name || format('{0} - Scala {1} @ {2} / {3} {4}{5}', inputs.project-name, inputs.published-scala-version != '' && inputs.published-scala-version || 'snapshot', inputs.repository-url, inputs.repository-branch, inputs.extra-scalac-options != '' && format('extraScalacOptions={0} ', inputs.extra-scalac-options) || '', inputs.disabled-scalac-options != '' && format('disabledScalacOptions={0}', inputs.disabled-scalac-options) || '' ) }}
2+
run-name: ${{ inputs.build-name != '' && inputs.build-name || format('Bisect {1}', inputs.project-name) }}
33

44
on:
55
workflow_dispatch:
@@ -11,9 +11,13 @@ on:
1111
project-name:
1212
type: string
1313
description: "Name of a project to build using GitHub coordinates <org>/<repo> eg. VirtusLab/scala-cli"
14+
project-targets:
15+
type: string
16+
description: "List of project targets to builds (comma deliomited)"
17+
default: "*"
1418
repository-url:
1519
type: string
16-
description: "GitHub repository URL for compiler to build, ignored when published-scala-version is defined"
20+
description: "GitHub repository URL for compiler to build"
1721
default: "lampepfl/dotty"
1822
scala-version-start:
1923
type: string
@@ -31,13 +35,19 @@ on:
3135
type: string
3236
description: "List of scalacOptions which should be filtered out when building projects."
3337
default: ""
38+
3439
jobs:
3540
run-bisect:
3641
runs-on: ubuntu-22.04
3742
continue-on-error: false
3843
timeout-minutes: 60
3944
steps:
4045
- name: "Git Checkout"
46+
uses: actions/checkout@v3
47+
with:
48+
path: opencb
49+
50+
- name: "Git Checkout compiler"
4151
uses: actions/checkout@v3
4252
with:
4353
repository: ${{ inputs.repository-url }}
@@ -54,15 +64,13 @@ jobs:
5464
echo "java-version=$javaVersion" >> $GITHUB_ENV
5565
echo "JavaVersion set to $javaVersion"
5666
57-
58-
- name: "Build project"
59-
uses: ./.github/actions/build-project
60-
with:
61-
project-name: ${{ inputs.project-name }}
62-
extra-scalac-options: ${{ inputs.extra-scalac-options }}
63-
disabled-scalac-options: ${{ inputs.disabled-scalac-options }}
64-
scala-version: ${{ needs.setup-build.outputs.scala-version }}
65-
maven-repo-url: https://scala3.westeurope.cloudapp.azure.com/maven2/bisect/
66-
elastic-user: ${{ secrets.OPENCB_ELASTIC_USER }}
67-
elastic-password: ${{ secrets.OPENCB_ELASTIC_PSWD }}
68-
github-key: ${{ secrets.OPENCB_GITHUB_KEY }}
67+
- name: "Bisect project"
68+
shell: bash
69+
run: |
70+
${{ github.workspace }}/opencb/scripts/bisect.scala -- \
71+
--releases ${{ inputs.scala-version-start}}..${{ inputs.scala-version-end}} \
72+
--extra-scalac-options ${{ inputs.extra-scalac-options }} \
73+
--disabled-scalac-options ${{ inputs.disabled-scalac-options }} \
74+
--community-build-dir ${{ github.workspace }}/opencb \
75+
--compiler-dir ${{ github.workspace }}/compiler \
76+
${{ inputs.project-name }} ${{ inputs.project-targets }}

scripts/bisect.scala

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ Look at the `usageMessage` below for more details.
88
*/
99

1010

11+
12+
1113
import sys.process._
1214
import scala.io.Source
1315
import java.io.File
1416
import java.nio.file.attribute.PosixFilePermissions
1517
import java.nio.charset.StandardCharsets
1618
import java.nio.file.Files
1719

20+
// --extra-scalac-options ${{ inputs.extra-scalac-options }} \
21+
// --disabled-scalac-options ${{ inputs.disabled-scalac-options }} \
22+
// --community-build-dir ${{ github.workspace }}/opencb
23+
1824
val usageMessage = """
1925
|Usage:
2026
| > scala-cli project/scripts/bisect.scala -- [<bisect-options>] <projectName> <targets>*
@@ -23,17 +29,26 @@ val usageMessage = """
2329
|* --dry-run
2430
| Don't try to bisect - just make sure the validation command works correctly
2531
|
32+
|* --extra-scalac-options <options>
33+
| Comma delimited of additional scalacOptions passed to project build
34+
|
35+
|* --disabled-scalac-options <options>
36+
| Comma delimited of disabled scalacOptions passed to project build
37+
|
38+
|* --community-build-dir <path>
39+
| Directory with community build project from which the project config would be resolved
40+
|
41+
|* --compiler-dir <path>
42+
| Directory containing Scala compiler repository, required for commit-based bissect
43+
|
2644
|* --releases <releases-range>
2745
| Bisect only releases from the given range (defaults to all releases).
28-
| The range format is <first>...<last>, where both <first> and <last> are optional, e.g.
46+
| The range format is <first>..<last>, where both <first> and <last> are optional, e.g.
2947
| * 3.1.0-RC1-bin-20210827-427d313-NIGHTLY..3.2.1-RC1-bin-20220716-bb9c8ff-NIGHTLY
3048
| * 3.2.1-RC1-bin-20220620-de3a82c-NIGHTLY..
3149
| * ..3.3.0-RC1-bin-20221124-e25362d-NIGHTLY
3250
| The ranges are treated as inclusive.
3351
|
34-
|* --bootstrapped
35-
| Publish locally and test a bootstrapped compiler rather than a nonboostrapped one.
36-
|
3752
|* --should-fail
3853
| Expect the validation command to fail rather that succeed. This can be used e.g. to find out when some illegal code started to compile.
3954
|
@@ -60,17 +75,16 @@ val usageMessage = """
6075
println(s"First bad release: ${firstBadRelease.version}")
6176
println("\nFinished bisecting releases\n")
6277

63-
val commitBisect = CommitBisect(validationScript, shouldFail = scriptOptions.shouldFail, bootstrapped = scriptOptions.bootstrapped, lastGoodRelease.hash, firstBadRelease.hash)
78+
val commitBisect = CommitBisect(validationScript, shouldFail = scriptOptions.shouldFail, lastGoodRelease.hash, firstBadRelease.hash)
6479
commitBisect.bisect()
6580

6681

67-
case class ScriptOptions(validationCommand: ValidationCommand, dryRun: Boolean, bootstrapped: Boolean, releasesRange: ReleasesRange, shouldFail: Boolean)
82+
case class ScriptOptions(validationCommand: ValidationCommand, dryRun: Boolean, releasesRange: ReleasesRange, shouldFail: Boolean)
6883
object ScriptOptions:
6984
def fromArgs(args: Seq[String]) =
7085
val defaultOptions = ScriptOptions(
7186
validationCommand = null,
7287
dryRun = false,
73-
bootstrapped = false,
7488
ReleasesRange(first = None, last = None),
7589
shouldFail = false
7690
)
@@ -80,17 +94,15 @@ object ScriptOptions:
8094
println(s"parse: $args")
8195
args match
8296
case "--dry-run" :: argsRest => parseArgs(argsRest, options.copy(dryRun = true))
83-
case "--bootstrapped" :: argsRest => parseArgs(argsRest, options.copy(bootstrapped = true))
8497
case "--releases" :: argsRest =>
8598
val range = ReleasesRange.tryParse(argsRest.head).get
8699
parseArgs(argsRest.tail, options.copy(releasesRange = range))
87100
case "--should-fail" :: argsRest => parseArgs(argsRest, options.copy(shouldFail = true))
88101
case args =>
89-
println(s"command: $args")
90102
val command = ValidationCommand.fromArgs(args)
91103
options.copy(validationCommand = command)
92104

93-
case class ValidationCommand(projectName: String, openCommunityBuildDir: File, targets: Seq[String]):
105+
case class ValidationCommand(projectName: String, openCommunityBuildDir: File, targets: Seq[String]):
94106
val remoteValidationScript: File = ValidationScript.buildProject(
95107
projectName = projectName,
96108
targets = Option.when(targets.nonEmpty)(targets.mkString(" ")),
@@ -104,7 +116,6 @@ case class ValidationCommand(projectName: String, openCommunityBuildDir: File, t
104116

105117
object ValidationCommand:
106118
def fromArgs(args: Seq[String]) =
107-
println(args)
108119
args match
109120
case Seq(projectName, openCBDir, targets*) => ValidationCommand(projectName, new File(openCBDir), targets)
110121

@@ -119,7 +130,7 @@ object ValidationScript:
119130
|#!/usr/bin/env bash
120131
|set -e
121132
|
122-
|scalaVersion="$$1" # e.g. 3.0.0-RC3
133+
|scalaVersion="$$1" # e.g. 3.3.3
123134
|
124135
|DefaultConfig='{"memoryRequestMb":4096}'
125136
|ConfigFile="/opencb/.github/workflows/buildConfig.json"
@@ -217,7 +228,7 @@ case class ReleasesRange(first: Option[String], last: Option[String]):
217228
object ReleasesRange:
218229
def all = ReleasesRange(None, None)
219230
def tryParse(range: String): Option[ReleasesRange] = range match
220-
case s"${first}...${last}" => Some(ReleasesRange(
231+
case s"${first}..${last}" => Some(ReleasesRange(
221232
Some(first).filter(_.nonEmpty),
222233
Some(last).filter(_.nonEmpty)
223234
))
@@ -287,11 +298,12 @@ class ReleaseBisect(validationScript: File, shouldFail: Boolean, allReleases: Ve
287298
isGood
288299
})
289300

290-
class CommitBisect(validationScript: File, shouldFail: Boolean, bootstrapped: Boolean, lastGoodHash: String, fistBadHash: String):
301+
class CommitBisect(validationScript: File, shouldFail: Boolean, lastGoodHash: String, fistBadHash: String):
291302
def bisect(): Unit =
292303
println(s"Starting bisecting commits $lastGoodHash..$fistBadHash\n")
293-
val scala3CompilerProject = if bootstrapped then "scala3-compiler-bootstrapped" else "scala3-compiler"
294-
val scala3Project = if bootstrapped then "scala3-bootstrapped" else "scala3"
304+
// Always bootstrapped
305+
val scala3CompilerProject = "scala3-compiler-bootstrapped"
306+
val scala3Project = "scala3-bootstrapped"
295307
val mavenRepo = "https://scala3.westeurope.cloudapp.azure.com/maven2/bisect/"
296308
val validationCommandStatusModifier = if shouldFail then "! " else "" // invert the process status if failure was expected
297309
val bisectRunScript = raw"""

0 commit comments

Comments
 (0)