Skip to content

Commit

Permalink
Merge pull request #2 from ScorexFoundation/remove-spire-dependence
Browse files Browse the repository at this point in the history
Remove spire dependence
  • Loading branch information
aslesarenko authored Jun 2, 2022
2 parents 8c2048a + bc54cd3 commit 469d384
Show file tree
Hide file tree
Showing 20 changed files with 205 additions and 512 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CI

on:
push:
branches:
- master
- develop
pull_request:
types:
- opened
- synchronize

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
name: Test and publish a snapshot
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.8, 2.12.15, 2.11.12]
java: [adopt@1.8]
runs-on: ${{ matrix.os }}
env:
HAS_SECRETS: ${{ secrets.SONATYPE_PASSWORD != '' }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v10
with:
java-version: ${{ matrix.java }}

- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Runs tests and collect coverage
run: sbt -jvm-opts ci/ci.jvmopts ++${{ matrix.scala }} test

- name: Publish a snapshot ${{ github.ref }}
if: env.HAS_SECRETS == 'true'
run: sbt ++${{ matrix.scala }} publish
env:
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish a release

on:
release:
types: [published]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
publish_release:
name: Publish release to Sonatype
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v10
with:
java-version: adopt@1.8

- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Import GPG key
run: ci/import_gpg.sh
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}

- name: Publish release ${{ github.ref }}
run: sbt +publishSigned sonatypeBundleRelease
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ TAGS
*~
.#*
.lib
.idea/
.bsp/
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package debox.benchmark
import scala.collection.mutable.ArrayBuffer
import scala.util.Random.nextLong

import spire.syntax.cfor._
import debox._

import org.openjdk.jmh.annotations._
Expand Down
5 changes: 2 additions & 3 deletions benchmark/src/main/scala/debox/benchmark/MapBenchmark.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package debox.benchmark

import debox.cfor

import scala.collection.mutable
import scala.util.Random._

import spire.syntax.cfor._

import org.openjdk.jmh.annotations._

object MapBenchmark {
Expand Down
3 changes: 2 additions & 1 deletion benchmark/src/main/scala/debox/benchmark/SetBenchmark.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package debox.benchmark

import debox.cfor

import scala.collection.mutable
import scala.util.Random.nextLong
import spire.syntax.cfor._
import org.openjdk.jmh.annotations._

object SetBenchmark {
Expand Down
1 change: 0 additions & 1 deletion benchmark/src/main/scala/debox/benchmark/Util.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package debox

import scala.{specialized => sp}
import scala.reflect.ClassTag
import spire.syntax.cfor._

package object benchmark {
def init[@sp A: ClassTag](size: Int)(init: => A): Array[A] = {
Expand Down
89 changes: 53 additions & 36 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ReleaseTransformations._
import sbt.Keys.{fork, publishArtifact}

lazy val scalac: Seq[String] = Seq(
"-deprecation", // Emit warning and location for usages of deprecated APIs.
Expand Down Expand Up @@ -96,25 +96,29 @@ lazy val scalac213: Seq[String] = Seq(
"-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope.
)

lazy val scala213 = "2.13.8"
lazy val scala212 = "2.12.15"
lazy val scala211 = "2.11.12"


lazy val deboxSettings = Seq(
organization := "org.spire-math",
organization := "org.scorexfoundation",
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
homepage := Some(url("http://github.com/non/debox")),
homepage := Some(url("http://github.com/ScorexFoundation/debox")),
description := "Fast, deboxed, specialized data structures for Scala (fork of non/debox)",

scalaVersion := "2.13.6",
crossScalaVersions := Seq("2.11.12", "2.12.10", "2.13.6"),

resolvers += Resolver.sonatypeRepo("releases"),
scalaVersion := scala213,
crossScalaVersions := Seq(scala211, scala212, scala213),
resolvers += Resolver.sonatypeRepo("public"),
libraryDependencies ++= Seq(
"org.typelevel" %% "spire" % "0.17.0-M1",
"org.typelevel" %% "spire-macros" % "0.17.0-M1",
"org.scalatest" %% "scalatest" % "3.3.0-SNAP3" % Test,
"org.scalatest" %% "scalatest-propspec" % "3.3.0-SNAP3" % Test,
"org.scalatest" %% "scalatest-shouldmatchers" % "3.3.0-SNAP3" % Test,
"org.scalatestplus" %% "scalacheck-1-15" % "3.3.0.0-SNAP3" % Test,
"org.scalacheck" %% "scalacheck" % "1.15.2" % Test
),


scalacOptions := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n == 13 =>
Expand All @@ -139,41 +143,25 @@ lazy val deboxSettings = Seq(
}
},

releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
publishMavenStyle := true,
Test / publishArtifact := false,
pomIncludeRepository := Function.const(false),

publishTo := Some(if (isSnapshot.value) Opts.resolver.sonatypeSnapshots else Opts.resolver.sonatypeStaging),

publishTo := sonatypePublishToBundle.value,
pomExtra := (
<scm>
<url>git@github.com:non/debox.git</url>
<connection>scm:git:git@github.com:non/debox.git</connection>
</scm>
<developers>
<developer>
<id>d_m</id>
<name>Erik Osheim</name>
<url>http://github.com/non/</url>
<id>aslesarenko</id>
<name>Alexander Slesarenko</name>
<url>https://github.com/aslesarenko/</url>
</developer>
</developers>
),

releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishArtifacts,
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges))
scmInfo := Some(
ScmInfo(
url("https://github.com/ScorexFoundation/debox"),
"scm:git@github.com:ScorexFoundation/debox.git"
)
)
)

lazy val noPublishSettings = Seq(
publish := {},
Expand All @@ -195,3 +183,32 @@ lazy val benchmark = project.dependsOn(core)
run / javaOptions += "-Xmx3G",
run / fork := true))
.settings(noPublishSettings)

// prefix version with "-SNAPSHOT" for builds without a git tag
dynverSonatypeSnapshots in ThisBuild := true
// use "-" instead of default "+"
dynverSeparator in ThisBuild := "-"

Test / publishArtifact := true
pomIncludeRepository := { _ => false }

val credentialFile = Path.userHome / ".sbt" / ".sigma-sonatype-credentials"
credentials ++= (for {
file <- if (credentialFile.exists) Some(credentialFile) else None
} yield Credentials(file)).toSeq

credentials ++= (for {
username <- Option(System.getenv().get("SONATYPE_USERNAME"))
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)).toSeq


// PGP key for signing a release build published to sonatype
// signing is done by sbt-pgp plugin
// how to generate a key - https://central.sonatype.org/pages/working-with-pgp-signatures.html
// how to export a key and use it with Travis - https://docs.scala-lang.org/overviews/contributors/index.html#export-your-pgp-key-pair
pgpPublicRing := file("ci/pubring.asc")
pgpSecretRing := file("ci/secring.asc")
pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toArray)
usePgpKeyHex("C1FD62B4D44BDF702CDF2B726FF59DA944B150DD")

6 changes: 6 additions & 0 deletions ci/ci.jvmopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-Xmx6g
-Xss2m
-XX:+CMSClassUnloadingEnabled
-XX:+UseConcMarkSweepGC
-XX:ReservedCodeCacheSize=96m
-XX:+TieredCompilation
21 changes: 21 additions & 0 deletions ci/import_gpg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# setting up gpg2 for reading passphrase from parameters
# via https://github.com/beautiful-scala/scalastyle/blob/master/.github/workflows/release.yml#L16
# from https://github.com/olafurpg/sbt-ci-release/issues/95

# setup gpg
mkdir ~/.gnupg && chmod 700 ~/.gnupg
echo use-agent >> ~/.gnupg/gpg.conf
echo pinentry-mode loopback >> ~/.gnupg/gpg.conf
echo allow-loopback-pinentry >> ~/.gnupg/gpg-agent.conf
chmod 600 ~/.gnupg/*
echo RELOADAGENT | gpg-connect-agent

# decode key
# private key should be previously exported with:
# gpg --export-secret-keys [id] | base64 | pbcopy
# and stored as github repository secret under the following name (see env var name below)
printf "$GPG_SIGNING_KEY" | base64 --decode > ~/.gnupg/private.key

# import key
gpg --no-tty --batch --yes --import ~/.gnupg/private.key
7 changes: 4 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.7")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.0")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.5")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")
Loading

0 comments on commit 469d384

Please sign in to comment.