Skip to content

Commit

Permalink
Merge pull request #93 from http4s/pr/nodejs-16
Browse files Browse the repository at this point in the history
Use Node.js 16 in CI
  • Loading branch information
armanbilge authored Sep 9, 2022
2 parents 5dbc300 + f09c9ec commit 049da83
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ jobs:
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

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

- name: Check that workflows are up to date
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' ''project /'' githubWorkflowCheck'
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ ThisBuild / crossScalaVersions := Seq("3.1.3", "2.12.16", "2.13.8")
ThisBuild / githubWorkflowBuildPreamble ++= Seq(
WorkflowStep.Use(
UseRef.Public("actions", "setup-node", "v2.4.0"),
name = Some("Setup NodeJS v14 LTS"),
params = Map("node-version" -> "14"),
name = Some("Setup NodeJS v16 LTS"),
params = Map("node-version" -> "16"),
cond = Some("matrix.project == 'rootJS' && matrix.jsenv == 'NodeJS'")
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,23 @@ private[crypto] trait HmacKeyGenCompanionPlatform {
new UnsealedHmacKeyGen[F] {
import facade.node._

override def generateKey[A <: HmacAlgorithm](algorithm: A): F[SecretKey[A]] =
override def generateKey[A <: HmacAlgorithm](algorithm: A): F[SecretKey[A]] = {
val options = new GenerateKeyOptions {
val length = algorithm.minimumKeyLength * java.lang.Byte.SIZE
}
Some(F)
.collect { case f: Async[F] => f }
.fold {
F.delay[SecretKey[A]] {
val key =
crypto.generateKeySync("hmac", GenerateKeyOptions(algorithm.minimumKeyLength))
crypto.generateKeySync("hmac", options)
SecretKeySpec(ByteVector.view(key.`export`()), algorithm)
}
} { F =>
F.async_[SecretKey[A]] { cb =>
crypto.generateKey(
"hmac",
GenerateKeyOptions(algorithm.minimumKeyLength),
options,
(err, key) =>
cb(
Option(err)
Expand All @@ -55,6 +58,7 @@ private[crypto] trait HmacKeyGenCompanionPlatform {
)
}
}
}

}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ private[crypto] trait crypto extends js.Any {

}

@js.native
private[crypto] trait GenerateKeyOptions extends js.Any
private[crypto] object GenerateKeyOptions {
def apply(length: Int): GenerateKeyOptions =
js.Dynamic.literal(length = length).asInstanceOf[GenerateKeyOptions]
private[crypto] trait GenerateKeyOptions extends js.Object {
val length: Int
}

private[crypto] object GenerateKeyOptions
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ final class HashSuite extends CatsEffectSuite {
if (Set("JVM", "NodeJS").contains(BuildInfo.runtime))
tests[SyncIO]

if (BuildInfo.runtime != "JVM")
tests[IO]
tests[IO]

}
12 changes: 4 additions & 8 deletions crypto/shared/src/test/scala/org/http4s/crypto/HmacSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,18 @@ final class HmacSuite extends CatsEffectSuite {
HmacKeyGen[F].generateKey(algorithm).map {
case SecretKeySpec(key, keyAlgorithm) =>
assertEquals(algorithm, keyAlgorithm)
assert(key.size >= algorithm.minimumKeyLength)
assert(clue(key.size) >= clue(algorithm.minimumKeyLength))
}
}

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

if (BuildInfo.runtime != "JVM")
tests[IO]
tests[IO]

if (BuildInfo.runtime == "JVM")
if (Set("JVM", "NodeJS").contains(BuildInfo.runtime))
List(SHA1, SHA256, SHA512).foreach(testGenerateKey[SyncIO])

if (!Set("JVM", "NodeJS").contains(
BuildInfo.runtime
)) // Disabled until testing against Node 16
List(SHA1, SHA256, SHA512).foreach(testGenerateKey[IO])
List(SHA1, SHA256, SHA512).foreach(testGenerateKey[IO])

}

0 comments on commit 049da83

Please sign in to comment.