Skip to content

Commit 049da83

Browse files
authored
Merge pull request #93 from http4s/pr/nodejs-16
Use Node.js 16 in CI
2 parents 5dbc300 + f09c9ec commit 049da83

File tree

6 files changed

+20
-22
lines changed

6 files changed

+20
-22
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ jobs:
125125
~/Library/Caches/Coursier/v1
126126
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
127127

128-
- name: Setup NodeJS v14 LTS
128+
- name: Setup NodeJS v16 LTS
129129
if: matrix.project == 'rootJS' && matrix.jsenv == 'NodeJS'
130130
uses: actions/[email protected]
131131
with:
132-
node-version: 14
132+
node-version: 16
133133

134134
- name: Check that workflows are up to date
135135
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' ''project /'' githubWorkflowCheck'

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ ThisBuild / crossScalaVersions := Seq("3.1.3", "2.12.16", "2.13.8")
3636
ThisBuild / githubWorkflowBuildPreamble ++= Seq(
3737
WorkflowStep.Use(
3838
UseRef.Public("actions", "setup-node", "v2.4.0"),
39-
name = Some("Setup NodeJS v14 LTS"),
40-
params = Map("node-version" -> "14"),
39+
name = Some("Setup NodeJS v16 LTS"),
40+
params = Map("node-version" -> "16"),
4141
cond = Some("matrix.project == 'rootJS' && matrix.jsenv == 'NodeJS'")
4242
)
4343
)

crypto/js/src/main/scala/org/http4s/crypto/HmacKeyGenPlatform.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,23 @@ private[crypto] trait HmacKeyGenCompanionPlatform {
3333
new UnsealedHmacKeyGen[F] {
3434
import facade.node._
3535

36-
override def generateKey[A <: HmacAlgorithm](algorithm: A): F[SecretKey[A]] =
36+
override def generateKey[A <: HmacAlgorithm](algorithm: A): F[SecretKey[A]] = {
37+
val options = new GenerateKeyOptions {
38+
val length = algorithm.minimumKeyLength * java.lang.Byte.SIZE
39+
}
3740
Some(F)
3841
.collect { case f: Async[F] => f }
3942
.fold {
4043
F.delay[SecretKey[A]] {
4144
val key =
42-
crypto.generateKeySync("hmac", GenerateKeyOptions(algorithm.minimumKeyLength))
45+
crypto.generateKeySync("hmac", options)
4346
SecretKeySpec(ByteVector.view(key.`export`()), algorithm)
4447
}
4548
} { F =>
4649
F.async_[SecretKey[A]] { cb =>
4750
crypto.generateKey(
4851
"hmac",
49-
GenerateKeyOptions(algorithm.minimumKeyLength),
52+
options,
5053
(err, key) =>
5154
cb(
5255
Option(err)
@@ -55,6 +58,7 @@ private[crypto] trait HmacKeyGenCompanionPlatform {
5558
)
5659
}
5760
}
61+
}
5862

5963
}
6064
else

crypto/js/src/main/scala/org/http4s/crypto/facade/node/crypto.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ private[crypto] trait crypto extends js.Any {
5252

5353
}
5454

55-
@js.native
56-
private[crypto] trait GenerateKeyOptions extends js.Any
57-
private[crypto] object GenerateKeyOptions {
58-
def apply(length: Int): GenerateKeyOptions =
59-
js.Dynamic.literal(length = length).asInstanceOf[GenerateKeyOptions]
55+
private[crypto] trait GenerateKeyOptions extends js.Object {
56+
val length: Int
6057
}
58+
59+
private[crypto] object GenerateKeyOptions

crypto/shared/src/test/scala/org/http4s/crypto/HashSuite.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ final class HashSuite extends CatsEffectSuite {
5656
if (Set("JVM", "NodeJS").contains(BuildInfo.runtime))
5757
tests[SyncIO]
5858

59-
if (BuildInfo.runtime != "JVM")
60-
tests[IO]
59+
tests[IO]
6160

6261
}

crypto/shared/src/test/scala/org/http4s/crypto/HmacSuite.scala

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,18 @@ final class HmacSuite extends CatsEffectSuite {
5858
HmacKeyGen[F].generateKey(algorithm).map {
5959
case SecretKeySpec(key, keyAlgorithm) =>
6060
assertEquals(algorithm, keyAlgorithm)
61-
assert(key.size >= algorithm.minimumKeyLength)
61+
assert(clue(key.size) >= clue(algorithm.minimumKeyLength))
6262
}
6363
}
6464

6565
if (Set("JVM", "NodeJS").contains(BuildInfo.runtime))
6666
tests[SyncIO]
6767

68-
if (BuildInfo.runtime != "JVM")
69-
tests[IO]
68+
tests[IO]
7069

71-
if (BuildInfo.runtime == "JVM")
70+
if (Set("JVM", "NodeJS").contains(BuildInfo.runtime))
7271
List(SHA1, SHA256, SHA512).foreach(testGenerateKey[SyncIO])
7372

74-
if (!Set("JVM", "NodeJS").contains(
75-
BuildInfo.runtime
76-
)) // Disabled until testing against Node 16
77-
List(SHA1, SHA256, SHA512).foreach(testGenerateKey[IO])
73+
List(SHA1, SHA256, SHA512).foreach(testGenerateKey[IO])
7874

7975
}

0 commit comments

Comments
 (0)