Skip to content

Commit

Permalink
scala 3-RC2, ci
Browse files Browse the repository at this point in the history
  • Loading branch information
yurique committed Apr 4, 2021
1 parent 6fbec70 commit 43352c2
Show file tree
Hide file tree
Showing 13 changed files with 271 additions and 57 deletions.
123 changes: 123 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# This file was automatically generated by sbt-github-actions using the
# githubWorkflowGenerate task. You should add and commit this file to
# your git repository. It goes without saying that you shouldn't edit
# this file by hand! Instead, if you wish to make changes, you should
# change your sbt build configuration to revise the workflow description
# to meet your needs, then regenerate this file.

name: Continuous Integration

on:
pull_request:
branches: ['*']
push:
branches: ['*']
tags: [v*]

env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
name: Build and Test
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.5, 3.0.0-RC2]
java: [[email protected]]
runs-on: ${{ matrix.os }}
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: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck

- run: sbt ++${{ matrix.scala }} test website/fastLinkJS

- name: Compress target directories
run: tar cf targets.tar target stringdiff/.jvm/target stringdiff/.js/target project/target

- name: Upload target directories
uses: actions/upload-artifact@v2
with:
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
path: targets.tar

publish:
name: Publish Artifacts
needs: [build]
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.5]
java: [[email protected]]
runs-on: ${{ matrix.os }}
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: Download target directories (2.13.5)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-2.13.5-${{ matrix.java }}

- name: Inflate target directories (2.13.5)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (3.0.0-RC2)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-3.0.0-RC2-${{ matrix.java }}

- name: Inflate target directories (3.0.0-RC2)
run: |
tar xf targets.tar
rm targets.tar
- run: sbt ++${{ matrix.scala }} ci-release
59 changes: 59 additions & 0 deletions .github/workflows/clean.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This file was automatically generated by sbt-github-actions using the
# githubWorkflowGenerate task. You should add and commit this file to
# your git repository. It goes without saying that you shouldn't edit
# this file by hand! Instead, if you wish to make changes, you should
# change your sbt build configuration to revise the workflow description
# to meet your needs, then regenerate this file.

name: Clean

on: push

jobs:
delete-artifacts:
name: Delete Artifacts
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Delete artifacts
run: |
# Customize those three lines with your repository and credentials:
REPO=${GITHUB_API_URL}/repos/${{ github.repository }}
# A shortcut to call GitHub API.
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }
# A temporary file which receives HTTP response headers.
TMPFILE=/tmp/tmp.$$
# An associative array, key: artifact name, value: number of artifacts of that name.
declare -A ARTCOUNT
# Process all artifacts on this repository, loop on returned "pages".
URL=$REPO/actions/artifacts
while [[ -n "$URL" ]]; do
# Get current page, get response headers in a temporary file.
JSON=$(ghapi --dump-header $TMPFILE "$URL")
# Get URL of next page. Will be empty if we are at the last page.
URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//')
rm -f $TMPFILE
# Number of artifacts on this page:
COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') ))
# Loop on all artifacts on this page.
for ((i=0; $i < $COUNT; i++)); do
# Get name of artifact and count instances of this name.
name=$(jq <<<$JSON -r ".artifacts[$i].name?")
ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1))
id=$(jq <<<$JSON -r ".artifacts[$i].id?")
size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") ))
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size
ghapi -X DELETE $REPO/actions/artifacts/$id
done
done
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### 0.3.2

Scala 3-RC2.

### 0.3.1

Myers algorithm.
Expand Down
65 changes: 28 additions & 37 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
ThisBuild / organization := "app.tulz"
ThisBuild / homepage := Some(url("https://github.com/tulz-app/stringdiff"))
ThisBuild / licenses += ("MIT", url("https://github.com/tulz-app/stringdiff/blob/main/LICENSE.md"))
ThisBuild / developers := List(
Developer(
id = "yurique",
name = "Iurii Malchenko",
email = "[email protected]",
url = url("https://github.com/yurique")
inThisBuild(
List(
organization := "app.tulz",
homepage := Some(url("https://github.com/tulz-app/stringdiff")),
licenses := List("MIT" -> url("https://github.com/tulz-app/stringdiff/blob/main/LICENSE.md")),
scmInfo := Some(ScmInfo(url("https://github.com/tulz-app/stringdiff"), "scm:[email protected]/tulz-app/laminext.git")),
developers := List(Developer("yurique", "Iurii Malchenko", "[email protected]", url("https://github.com/yurique"))),
scalaVersion := ScalaVersions.v213,
description := "String diff for Scala",
crossScalaVersions := Seq(
ScalaVersions.v213,
ScalaVersions.v3RC2
),
Test / publishArtifact := false,
Test / parallelExecution := false,
githubWorkflowJavaVersions := Seq("[email protected]"),
githubWorkflowTargetTags ++= Seq("v*"),
githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))),
githubWorkflowPublish := Seq(WorkflowStep.Sbt(List("ci-release"))),
githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("test", "website/fastLinkJS"))),
githubWorkflowEnv ~= (_ ++ Map(
"PGP_PASSPHRASE" -> s"$${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> s"$${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> s"$${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> s"$${{ secrets.SONATYPE_USERNAME }}"
))
)
)
ThisBuild / releasePublishArtifactsAction := PgpKeys.publishSigned.value
ThisBuild / publishTo := sonatypePublishToBundle.value
ThisBuild / pomIncludeRepository := { _ => false }
ThisBuild / sonatypeProfileName := "yurique"
ThisBuild / publishArtifact in Test := false
ThisBuild / publishMavenStyle := true
ThisBuild / releaseCrossBuild := false
ThisBuild / crossScalaVersions := Seq("2.13.4")

lazy val noPublish = Seq(
publishLocal / skip := true,
Expand All @@ -29,27 +38,9 @@ lazy val stringdiff =
.crossType(CrossType.Pure)
.in(file("stringdiff"))
.settings(
scalaVersion := "2.13.4",
scalacOptions := Seq(
"-unchecked",
"-deprecation",
"-feature",
"-Xlint:nullary-unit,inaccessible,infer-any,missing-interpolator,private-shadow,type-parameter-shadow,poly-implicit-overload,option-implicit,delayedinit-select,stars-align",
"-Xcheckinit",
"-Ywarn-value-discard",
"-language:implicitConversions",
"-encoding",
"utf8"
),
ScalaOptions.fixOptions,
libraryDependencies ++= Seq(
"org.scalatest" %%% "scalatest" % "3.2.0" % Test
),
description := "String diff for scala.",
scmInfo := Some(
ScmInfo(
url("https://github.com/tulz-app/stringdiff"),
"scm:[email protected]/tulz-app/stringdiff.git"
)
"org.scalatest" %%% "scalatest" % "3.2.7" % Test
)
)

Expand Down
41 changes: 41 additions & 0 deletions project/ScalaOptions.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import sbt.Keys._
import sbt._

object ScalaOptions {
val fixOptions = Seq(
scalacOptions ~= (_.filterNot(
Set(
"-Wdead-code",
"-Wunused:implicits",
"-Wunused:explicits",
"-Wunused:imports",
"-Wunused:params"
)
)),
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, _)) =>
Seq(
"-Ymacro-annotations"
)
case Some((3, _)) => Seq()
case _ => Seq()
}),
(Compile / doc / scalacOptions) ~= (_.filterNot(
Set(
"-scalajs",
"-deprecation",
"-explain-types",
"-explain",
"-feature",
"-language:existentials,experimental.macros,higherKinds,implicitConversions",
"-unchecked",
"-Xfatal-warnings",
"-Ykind-projector",
"-from-tasty",
"-encoding",
"utf8"
)
))
)

}
4 changes: 4 additions & 0 deletions project/ScalaVersions.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object ScalaVersions {
val v213 = "2.13.5"
val v3RC2 = "3.0.0-RC2"
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.4.6
sbt.version=1.5.0-RC2
12 changes: 8 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
logLevel := Level.Warn

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.1.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.5.0")

addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")

addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.2")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.5")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7")

addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.10.1")

addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.17")

addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ object AnsiDiffFormat extends DiffFormat[String] {
sb.appendAll(second)
sb.append(RESET)
sb.append("]")
case _ =>
}

sb.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ object AnsiDiffFormatBoth extends DiffFormat[(String, String)] {
sb1.append(UNDERLINED)
sb1.appendAll(first)
sb1.append(RESET)
case _ =>
}

val sb2 = new StringBuilder
Expand All @@ -58,7 +57,6 @@ object AnsiDiffFormatBoth extends DiffFormat[(String, String)] {
sb2.append(UNDERLINED)
sb2.appendAll(second)
sb2.append(RESET)
case _ =>
}

(sb1.toString(), sb2.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ object TextDiffFormat extends DiffFormat[String] {
sb.append("|")
sb.appendAll(second)
sb.append("]")
case _ =>
}
sb.toString()
}
Expand Down
Loading

0 comments on commit 43352c2

Please sign in to comment.