Skip to content

Commit a35267c

Browse files
Merge pull request #142 from alexarchambault/tweak-ci
Tweak CI
2 parents 23571f7 + d46768a commit a35267c

File tree

4 files changed

+105
-49
lines changed

4 files changed

+105
-49
lines changed

.github/scripts/update-website.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
git config --global user.name "gh-actions"
5+
git config --global user.email "[email protected]"
6+
7+
cd website
8+
yarn install
9+
yarn build
10+
yarn deploy

.github/workflows/ci.yml

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010

1111
jobs:
1212
jvm-tests:
13+
timeout-minutes: 80
1314
runs-on: ${{ matrix.OS }}
1415
strategy:
1516
fail-fast: false
@@ -41,6 +42,7 @@ jobs:
4142
run: ./mill -i integration.jvm.test
4243

4344
native-tests:
45+
timeout-minutes: 80
4446
runs-on: ${{ matrix.OS }}
4547
strategy:
4648
fail-fast: false
@@ -74,6 +76,7 @@ jobs:
7476
COURSIER_JNI: force
7577

7678
native-mostly-static-tests:
79+
timeout-minutes: 80
7780
runs-on: ubuntu-latest
7881
steps:
7982
- uses: actions/checkout@v2
@@ -114,6 +117,7 @@ jobs:
114117
docker push ghcr.io/virtuslabrnd/scala-cli:latest
115118
116119
native-static-tests:
120+
timeout-minutes: 80
117121
runs-on: ubuntu-latest
118122
steps:
119123
- uses: actions/checkout@v2
@@ -138,6 +142,7 @@ jobs:
138142
run: ./mill -i integration.native-static.test
139143

140144
checks:
145+
timeout-minutes: 15
141146
runs-on: ubuntu-latest
142147
steps:
143148
- uses: actions/checkout@v2
@@ -154,6 +159,7 @@ jobs:
154159
run: ./mill -i 'dummy.amm[_].resolvedRunIvyDeps.'
155160

156161
format:
162+
timeout-minutes: 15
157163
runs-on: ubuntu-latest
158164
steps:
159165
- uses: actions/checkout@v2
@@ -168,6 +174,7 @@ jobs:
168174
- run: scalafmt --check
169175

170176
reference-doc:
177+
timeout-minutes: 15
171178
runs-on: ubuntu-latest
172179
steps:
173180
- uses: actions/checkout@v2
@@ -188,6 +195,7 @@ jobs:
188195
)
189196
190197
vc-redist:
198+
timeout-minutes: 15
191199
runs-on: windows-2016
192200
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == 'VirtuslabRnD/scala-cli'
193201
steps:
@@ -231,6 +239,7 @@ jobs:
231239
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
232240

233241
launchers:
242+
timeout-minutes: 20
234243
needs: [jvm-tests, native-tests, native-mostly-static-tests, native-static-tests, vc-redist, format, checks, reference-doc]
235244
if: github.event_name == 'push'
236245
runs-on: ubuntu-latest
@@ -289,9 +298,28 @@ jobs:
289298
PGP_SECRET: ${{ secrets.PGP_SECRET }}
290299
GPG_EMAIL: ${{ secrets.GPG_EMAIL }}
291300

292-
website:
301+
website-nightly:
302+
needs: publish
303+
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/v')
304+
runs-on: ubuntu-latest
305+
steps:
306+
- uses: actions/checkout@v2
307+
with:
308+
fetch-depth: 0
309+
submodules: true
310+
- uses: actions/[email protected]
311+
with:
312+
node-version: '12.x'
313+
- run: .github/scripts/update-website.sh
314+
env:
315+
GIT_USER: VirtuslabRnD
316+
DEPLOYMENT_BRANCH: gh-pages
317+
GIT_PASS: ${{ secrets.GITHUB_TOKEN }}
318+
319+
# same as website-nightly above, but for the 'needs' and 'if' fields
320+
website-release:
293321
needs: [publish, update-packages]
294-
if: github.event_name == 'push'
322+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
295323
runs-on: ubuntu-latest
296324
steps:
297325
- uses: actions/checkout@v2
@@ -301,13 +329,7 @@ jobs:
301329
- uses: actions/[email protected]
302330
with:
303331
node-version: '12.x'
304-
- run: |
305-
git config --global user.name "gh-actions"
306-
git config --global user.email "[email protected]"
307-
cd website
308-
yarn install
309-
yarn build
310-
yarn deploy
332+
- run: .github/scripts/update-website.sh
311333
env:
312334
GIT_USER: VirtuslabRnD
313335
DEPLOYMENT_BRANCH: gh-pages

modules/bloop-rifle/src/main/scala/scala/build/blooprifle/internal/Operations.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ object Operations {
134134
promise.future
135135
}
136136

137+
private val ignoredErrnos = Set(
138+
61, // Connection refused
139+
111 //
140+
)
141+
137142
/** Opens a BSP connection to a running bloop server.
138143
*
139144
* Starts a thread to read output from the nailgun connection, and another one to pass input to
@@ -232,10 +237,10 @@ object Operations {
232237
catch {
233238
case ex: IOException
234239
if ex.getCause.isInstanceOf[NativeErrorException] &&
235-
ex.getCause.asInstanceOf[NativeErrorException].returnCode == 111 =>
240+
ignoredErrnos(ex.getCause.asInstanceOf[NativeErrorException].returnCode) =>
236241
logger.debug(s"Error when connecting to $socketFile: ${ex.getMessage}")
237242
null
238-
case e: NativeErrorException if e.returnCode == 111 =>
243+
case e: NativeErrorException if ignoredErrnos(e.returnCode) =>
239244
logger.debug(s"Error when connecting to $socketFile: ${e.getMessage}")
240245
null
241246
}

modules/integration/src/test/scala/scala/cli/integration/BspTestDefinitions.scala

Lines changed: 57 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ import java.nio.charset.Charset
88
import java.nio.file.Paths
99
import java.util.concurrent.TimeoutException
1010

11+
import scala.annotation.tailrec
1112
import scala.async.Async.{async, await}
1213
import scala.collection.JavaConverters._
1314
import scala.concurrent.{Await, Future, Promise}
1415
import scala.concurrent.ExecutionContext.Implicits.global
1516
import scala.concurrent.duration._
1617
import scala.io.Codec
1718
import scala.util.control.NonFatal
18-
import scala.util.Properties
19+
import scala.util.{Failure, Properties, Success, Try}
1920

2021
abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
2122
extends munit.FunSuite with TestScalaVersionArgs {
@@ -58,38 +59,61 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
5859
}
5960

6061
def withBsp[T](
61-
root: os.Path,
62-
args: Seq[String]
62+
inputs: TestInputs,
63+
args: Seq[String],
64+
attempts: Int = 3
6365
)(
64-
f: (TestBspClient, b.BuildServer with b.ScalaBuildServer with b.JavaBuildServer) => Future[T]
66+
f: (
67+
os.Path,
68+
TestBspClient,
69+
b.BuildServer with b.ScalaBuildServer with b.JavaBuildServer
70+
) => Future[T]
6571
): T = {
6672

67-
val proc = os.proc(TestUtil.cli, "bsp", extraOptions, args)
68-
.spawn(cwd = root)
69-
var remoteServer: b.BuildServer with b.ScalaBuildServer with b.JavaBuildServer = null
70-
71-
try {
72-
val (localClient, remoteServer0, shutdownFuture) =
73-
TestBspClient.connect(proc.stdout, proc.stdin, pool)
74-
remoteServer = remoteServer0
75-
val f0 = async {
76-
await(remoteServer.buildInitialize(initParams(root)).asScala)
77-
await(f(localClient, remoteServer))
73+
def attempt(): Try[T] = Try {
74+
val root = inputs.root()
75+
76+
val proc = os.proc(TestUtil.cli, "bsp", extraOptions, args)
77+
.spawn(cwd = root)
78+
var remoteServer: b.BuildServer with b.ScalaBuildServer with b.JavaBuildServer = null
79+
80+
try {
81+
val (localClient, remoteServer0, shutdownFuture) =
82+
TestBspClient.connect(proc.stdout, proc.stdin, pool)
83+
remoteServer = remoteServer0
84+
Await.result(remoteServer.buildInitialize(initParams(root)).asScala, 3.minutes)
85+
Await.result(f(root, localClient, remoteServer), 3.minutes)
86+
}
87+
finally {
88+
if (remoteServer != null)
89+
try Await.result(remoteServer.buildShutdown().asScala, 20.seconds)
90+
catch {
91+
case NonFatal(e) =>
92+
System.err.println(s"Ignoring $e while shutting down BSP server")
93+
}
94+
proc.join(2.seconds.toMillis)
95+
proc.destroy()
96+
proc.join(2.seconds.toMillis)
97+
proc.destroyForcibly()
7898
}
79-
Await.result(f0, 3.minutes)
8099
}
81-
finally {
82-
if (remoteServer != null)
83-
try Await.result(remoteServer.buildShutdown().asScala, 20.seconds)
84-
catch {
85-
case NonFatal(e) =>
86-
System.err.println(s"Ignoring $e while shutting down BSP server")
100+
101+
@tailrec
102+
def helper(count: Int): T =
103+
if (count <= 1)
104+
attempt() match {
105+
case Success(t) => t
106+
case Failure(ex) => throw new Exception(ex)
87107
}
88-
proc.join(2.seconds.toMillis)
89-
proc.destroy()
90-
proc.join(2.seconds.toMillis)
91-
proc.destroyForcibly()
92-
}
108+
else
109+
attempt() match {
110+
case Success(t) => t
111+
case Failure(ex) =>
112+
System.err.println(s"Caught $ex, trying again…")
113+
helper(count - 1)
114+
}
115+
116+
helper(attempts)
93117
}
94118

95119
def checkTargetUri(root: os.Path, uri: String): Unit = {
@@ -135,9 +159,8 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
135159
|""".stripMargin
136160
)
137161
)
138-
val root = inputs.root()
139162

140-
withBsp(root, Seq(".")) { (localClient, remoteServer) =>
163+
withBsp(inputs, Seq(".")) { (root, localClient, remoteServer) =>
141164
async {
142165
val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala)
143166
val target = {
@@ -263,9 +286,8 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
263286
|""".stripMargin
264287
)
265288
)
266-
val root = inputs.root()
267289

268-
withBsp(root, Seq(".")) { (localClient, remoteServer) =>
290+
withBsp(inputs, Seq(".")) { (root, localClient, remoteServer) =>
269291
async {
270292
val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala)
271293
val target = {
@@ -331,9 +353,8 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
331353
|""".stripMargin
332354
)
333355
)
334-
val root = inputs.root()
335356

336-
withBsp(root, Seq(".")) { (localClient, remoteServer) =>
357+
withBsp(inputs, Seq(".")) { (root, localClient, remoteServer) =>
337358
async {
338359
val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala)
339360
val target = {
@@ -400,12 +421,11 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
400421
|""".stripMargin
401422
)
402423
)
403-
val root = inputs.root()
404-
405424
val extraArgs =
406425
if (Properties.isWin) Seq("-v", "-v", "-v")
407426
else Nil
408-
withBsp(root, Seq(".") ++ extraArgs) { (localClient, remoteServer) =>
427+
428+
withBsp(inputs, Seq(".") ++ extraArgs) { (root, localClient, remoteServer) =>
409429
async {
410430
val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala)
411431
val target = {
@@ -518,9 +538,8 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
518538
|""".stripMargin
519539
)
520540
)
521-
val root = inputs.root()
522541

523-
withBsp(root, Seq(".")) { (localClient, remoteServer) =>
542+
withBsp(inputs, Seq(".")) { (root, localClient, remoteServer) =>
524543
async {
525544
val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala)
526545
val target = {

0 commit comments

Comments
 (0)