Skip to content

Commit 61bf79f

Browse files
authored
Merge pull request #53 from http4s/integration/bobcats-main
Merge in latest bobcats
2 parents 4974b76 + dc8bb58 commit 61bf79f

File tree

14 files changed

+245
-140
lines changed

14 files changed

+245
-140
lines changed

.github/workflows/ci.yml

Lines changed: 143 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,49 @@ on:
1515
tags: [v*]
1616

1717
env:
18-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19-
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
18+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
2019
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
20+
SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }}
21+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
2122
PGP_SECRET: ${{ secrets.PGP_SECRET }}
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2224

2325
jobs:
2426
build:
2527
name: Build and Test
2628
strategy:
29+
fail-fast: false
2730
matrix:
2831
os: [ubuntu-latest]
2932
scala: [3.1.1, 2.12.15, 2.13.8]
30-
java: [temurin@8]
33+
java: [temurin@8, temurin@11, temurin@17]
34+
project: [rootJS, rootJVM]
35+
jsenv: [NodeJS, Chrome, Firefox]
36+
exclude:
37+
- scala: 3.1.1
38+
java: temurin@11
39+
- scala: 3.1.1
40+
java: temurin@17
41+
- scala: 2.12.15
42+
java: temurin@11
43+
- scala: 2.12.15
44+
java: temurin@17
45+
- project: rootJS
46+
java: temurin@11
47+
- project: rootJS
48+
java: temurin@17
49+
- scala: 3.1.1
50+
jsenv: Chrome
51+
- scala: 3.1.1
52+
jsenv: Firefox
53+
- scala: 2.12.15
54+
jsenv: Chrome
55+
- scala: 2.12.15
56+
jsenv: Firefox
57+
- project: rootJVM
58+
jsenv: Chrome
59+
- project: rootJVM
60+
jsenv: Firefox
3161
runs-on: ${{ matrix.os }}
3262
steps:
3363
- name: Checkout current branch (full)
@@ -42,6 +72,20 @@ jobs:
4272
distribution: temurin
4373
java-version: 8
4474

75+
- name: Setup Java (temurin@11)
76+
if: matrix.java == 'temurin@11'
77+
uses: actions/setup-java@v2
78+
with:
79+
distribution: temurin
80+
java-version: 11
81+
82+
- name: Setup Java (temurin@17)
83+
if: matrix.java == 'temurin@17'
84+
uses: actions/setup-java@v2
85+
with:
86+
distribution: temurin
87+
java-version: 17
88+
4589
- name: Cache sbt
4690
uses: actions/cache@v2
4791
with:
@@ -55,22 +99,50 @@ jobs:
5599
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
56100

57101
- name: Setup NodeJS v14 LTS
102+
if: matrix.project == 'rootJS' && matrix.jsenv == 'NodeJS'
58103
uses: actions/[email protected]
59104
with:
60105
node-version: 14
61106

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

65-
- run: sbt ++${{ matrix.scala }} ci
110+
- name: Check headers and formatting
111+
if: matrix.java == 'temurin@8'
112+
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' headerCheckAll scalafmtCheckAll ''project /'' scalafmtSbtCheck'
113+
114+
- name: scalaJSLink
115+
if: matrix.project == 'rootJS'
116+
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' Test/scalaJSLinkerResult'
117+
118+
- name: Test
119+
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' test'
120+
121+
- name: Check binary compatibility
122+
if: matrix.java == 'temurin@8'
123+
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' mimaReportBinaryIssues'
124+
125+
- name: Generate API documentation
126+
if: matrix.java == 'temurin@8'
127+
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' doc'
128+
129+
- name: Check unused compile dependencies
130+
if: matrix.java == 'temurin@8'
131+
run: 'sbt ''project ${{ matrix.project }}'' ''++${{ matrix.scala }}'' ''set Global / useJSEnv := JSEnv.${{ matrix.jsenv }}'' unusedCompileDependenciesTest'
132+
133+
- name: Make target directories
134+
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
135+
run: mkdir -p crypto/jvm/target target .js/target .jvm/target .native/target test-runtime/.jvm/target crypto/js/target test-runtime/.js/target project/target
66136

67137
- name: Compress target directories
68-
run: tar cf targets.tar crypto/jvm/target target rootJS/target rootJVM/target test-runtime/.jvm/target crypto/js/target test-runtime/.js/target project/target
138+
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
139+
run: tar cf targets.tar crypto/jvm/target target .js/target .jvm/target .native/target test-runtime/.jvm/target crypto/js/target test-runtime/.js/target project/target
69140

70141
- name: Upload target directories
142+
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
71143
uses: actions/upload-artifact@v2
72144
with:
73-
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
145+
name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}-${{ matrix.jsenv }}-${{ matrix.project }}
74146
path: targets.tar
75147

76148
publish:
@@ -96,6 +168,20 @@ jobs:
96168
distribution: temurin
97169
java-version: 8
98170

171+
- name: Setup Java (temurin@11)
172+
if: matrix.java == 'temurin@11'
173+
uses: actions/setup-java@v2
174+
with:
175+
distribution: temurin
176+
java-version: 11
177+
178+
- name: Setup Java (temurin@17)
179+
if: matrix.java == 'temurin@17'
180+
uses: actions/setup-java@v2
181+
with:
182+
distribution: temurin
183+
java-version: 17
184+
99185
- name: Cache sbt
100186
uses: actions/cache@v2
101187
with:
@@ -108,37 +194,76 @@ jobs:
108194
~/Library/Caches/Coursier/v1
109195
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
110196

111-
- name: Download target directories (3.1.1)
197+
- name: Download target directories (3.1.1, NodeJS, rootJS)
198+
uses: actions/download-artifact@v2
199+
with:
200+
name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.1-NodeJS-rootJS
201+
202+
- name: Inflate target directories (3.1.1, NodeJS, rootJS)
203+
run: |
204+
tar xf targets.tar
205+
rm targets.tar
206+
207+
- name: Download target directories (3.1.1, NodeJS, rootJVM)
112208
uses: actions/download-artifact@v2
113209
with:
114-
name: target-${{ matrix.os }}-3.1.1-${{ matrix.java }}
210+
name: target-${{ matrix.os }}-${{ matrix.java }}-3.1.1-NodeJS-rootJVM
115211

116-
- name: Inflate target directories (3.1.1)
212+
- name: Inflate target directories (3.1.1, NodeJS, rootJVM)
117213
run: |
118214
tar xf targets.tar
119215
rm targets.tar
120216
121-
- name: Download target directories (2.12.15)
217+
- name: Download target directories (2.12.15, NodeJS, rootJS)
122218
uses: actions/download-artifact@v2
123219
with:
124-
name: target-${{ matrix.os }}-2.12.15-${{ matrix.java }}
220+
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-NodeJS-rootJS
125221

126-
- name: Inflate target directories (2.12.15)
222+
- name: Inflate target directories (2.12.15, NodeJS, rootJS)
127223
run: |
128224
tar xf targets.tar
129225
rm targets.tar
130226
131-
- name: Download target directories (2.13.8)
227+
- name: Download target directories (2.12.15, NodeJS, rootJVM)
132228
uses: actions/download-artifact@v2
133229
with:
134-
name: target-${{ matrix.os }}-2.13.8-${{ matrix.java }}
230+
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.15-NodeJS-rootJVM
135231

136-
- name: Inflate target directories (2.13.8)
232+
- name: Inflate target directories (2.12.15, NodeJS, rootJVM)
233+
run: |
234+
tar xf targets.tar
235+
rm targets.tar
236+
237+
- name: Download target directories (2.13.8, NodeJS, rootJS)
238+
uses: actions/download-artifact@v2
239+
with:
240+
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-NodeJS-rootJS
241+
242+
- name: Inflate target directories (2.13.8, NodeJS, rootJS)
243+
run: |
244+
tar xf targets.tar
245+
rm targets.tar
246+
247+
- name: Download target directories (2.13.8, NodeJS, rootJVM)
248+
uses: actions/download-artifact@v2
249+
with:
250+
name: target-${{ matrix.os }}-${{ matrix.java }}-2.13.8-NodeJS-rootJVM
251+
252+
- name: Inflate target directories (2.13.8, NodeJS, rootJVM)
137253
run: |
138254
tar xf targets.tar
139255
rm targets.tar
140256
141257
- name: Import signing key
142-
run: echo $PGP_SECRET | base64 -d | gpg --import
258+
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
259+
run: echo $PGP_SECRET | base64 -di | gpg --import
260+
261+
- name: Import signing key and strip passphrase
262+
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != ''
263+
run: |
264+
echo "$PGP_SECRET" | base64 -di > /tmp/signing-key.gpg
265+
echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg
266+
(echo "$PGP_PASSPHRASE"; echo; echo) | gpg --command-fd 0 --pinentry-mode loopback --change-passphrase $(gpg --list-secret-keys --with-colons 2> /dev/null | grep '^sec:' | cut --delimiter ':' --fields 5 | tail -n 1)
143267
144-
- run: sbt ++${{ matrix.scala }} release
268+
- name: Publish
269+
run: sbt '++${{ matrix.scala }}' tlRelease

build.sbt

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,39 @@ import JSEnv._
2424

2525
name := "http4s-crypto"
2626

27-
ThisBuild / baseVersion := "0.2"
27+
ThisBuild / tlBaseVersion := "0.2"
28+
ThisBuild / tlUntaggedAreSnapshots := false
2829

29-
ThisBuild / organization := "org.http4s"
30-
ThisBuild / organizationName := "http4s.org"
31-
ThisBuild / publishGithubUser := "armanbilge"
32-
ThisBuild / publishFullName := "Arman Bilge"
33-
34-
enablePlugins(SonatypeCiReleasePlugin)
35-
ThisBuild / spiewakCiReleaseSnapshots := true
36-
ThisBuild / spiewakMainBranches := Seq("main")
37-
38-
ThisBuild / homepage := Some(url("https://github.com/http4s/http4s-crypto"))
39-
ThisBuild / scmInfo := Some(
40-
ScmInfo(
41-
url("https://github.com/http4s/http4s-crypto"),
42-
"https://github.com/http4s/http4s-crypto.git"))
30+
ThisBuild / developers := List(
31+
tlGitHubDev("armanbilge", "Arman Bilge")
32+
)
33+
ThisBuild / startYear := Some(2021)
4334

4435
ThisBuild / crossScalaVersions := Seq("3.1.1", "2.12.15", "2.13.8")
4536

46-
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8"))
47-
4837
ThisBuild / githubWorkflowBuildPreamble ++= Seq(
4938
WorkflowStep.Use(
5039
UseRef.Public("actions", "setup-node", "v2.4.0"),
5140
name = Some("Setup NodeJS v14 LTS"),
52-
params = Map("node-version" -> "14")
41+
params = Map("node-version" -> "14"),
42+
cond = Some("matrix.project == 'rootJS' && matrix.jsenv == 'NodeJS'")
5343
)
5444
)
5545

56-
replaceCommandAlias("ci", CI.AllCIs.map(_.toString).mkString)
57-
addCommandAlias("ciJVM", CI.JVM.toString)
58-
addCommandAlias("ciNodeJS", CI.NodeJS.toString)
59-
addCommandAlias("ciFirefox", CI.Firefox.toString)
60-
addCommandAlias("ciChrome", CI.Chrome.toString)
61-
62-
addCommandAlias("prePR", "; root/clean; scalafmtSbt; +root/scalafmtAll; +root/headerCreate")
46+
val jsenvs = List(NodeJS, Chrome, Firefox).map(_.toString)
47+
ThisBuild / githubWorkflowBuildMatrixAdditions += "jsenv" -> jsenvs
48+
ThisBuild / githubWorkflowBuildSbtStepPreamble += s"set Global / useJSEnv := JSEnv.$${{ matrix.jsenv }}"
49+
ThisBuild / githubWorkflowBuildMatrixExclusions ++= {
50+
for {
51+
scala <- (ThisBuild / crossScalaVersions).value.init
52+
jsenv <- jsenvs.tail
53+
} yield MatrixExclude(Map("scala" -> scala, "jsenv" -> jsenv))
54+
}
55+
ThisBuild / githubWorkflowBuildMatrixExclusions ++= {
56+
for {
57+
jsenv <- jsenvs.tail
58+
} yield MatrixExclude(Map("project" -> "rootJVM", "jsenv" -> jsenv))
59+
}
6360

6461
lazy val useJSEnv =
6562
settingKey[JSEnv]("Use Node.js or a headless browser for running Scala.js tests")
@@ -88,12 +85,7 @@ val munitVersion = "0.7.29"
8885
val munitCEVersion = "1.0.7"
8986
val disciplineMUnitVersion = "1.0.9"
9087

91-
lazy val root =
92-
project.in(file(".")).aggregate(rootJS, rootJVM).enablePlugins(NoPublishPlugin)
93-
lazy val rootJVM =
94-
project.aggregate(crypto.jvm, testRuntime.jvm).enablePlugins(NoPublishPlugin)
95-
lazy val rootJS =
96-
project.aggregate(crypto.js, testRuntime.js).enablePlugins(NoPublishPlugin)
88+
lazy val root = tlCrossRootProject.aggregate(crypto, testRuntime)
9789

9890
lazy val crypto = crossProject(JSPlatform, JVMPlatform)
9991
.in(file("crypto"))
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2021 http4s.org
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.http4s.crypto
18+
19+
import scodec.bits.ByteVector
20+
21+
private[crypto] trait SecureEqCompanionPlatform { this: SecureEq.type =>
22+
23+
implicit lazy val secureEqForByteVector: SecureEq[ByteVector] =
24+
if (facade.isNodeJSRuntime)
25+
new NodeJSSecureEq
26+
else
27+
new ByteVectorSecureEq
28+
29+
private[this] final class NodeJSSecureEq extends SecureEq[ByteVector] {
30+
import facade.node._
31+
32+
override def eqv(x: ByteVector, y: ByteVector): Boolean =
33+
x.length == y.length && crypto.timingSafeEqual(x.toUint8Array, y.toUint8Array)
34+
}
35+
36+
}

crypto/js/src/main/scala/org/http4s/crypto/facade/browser/SubtleCrypto.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import scala.annotation.nowarn
2020
import scala.scalajs.js
2121

2222
@js.native
23-
@nowarn("cat=unused")
23+
@nowarn("msg=never used")
2424
private[crypto] trait SubtleCrypto extends js.Any {
2525

2626
def digest(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import scala.scalajs.js.annotation.JSGlobal
2222

2323
@js.native
2424
@JSGlobal
25-
@nowarn("cat=unused")
25+
@nowarn("msg=never used")
2626
private[crypto] object crypto extends js.Any {
2727

2828
def subtle: SubtleCrypto = js.native

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import scala.scalajs.js
2020
import scala.annotation.nowarn
2121

2222
@js.native
23-
@nowarn("cat=unused")
23+
@nowarn("msg=never used")
2424
private[crypto] trait Hash extends js.Any {
2525

2626
def digest(): js.typedarray.Uint8Array = js.native

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import scala.scalajs.js
2020
import scala.annotation.nowarn
2121

2222
@js.native
23-
@nowarn("cat=unused")
23+
@nowarn("msg=never used")
2424
private[crypto] trait Hmac extends js.Any {
2525

2626
def digest(): js.typedarray.Uint8Array = js.native

0 commit comments

Comments
 (0)