Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release under leviysoft #2

Merged
merged 5 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 65 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
branches: ['**']
push:
branches: ['**']
tags: [v*]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -43,7 +44,6 @@ jobs:
uses: sbt/setup-sbt@v1

- name: Setup scala native dependencies
if: matrix.scala == '2.12.19'
run: sudo apt install clang libunwind-dev libgc-dev libre2-dev

- name: Check that workflows are up to date
Expand All @@ -53,5 +53,68 @@ jobs:
run: 'sbt ''++ ${{ matrix.scala }}'' test test:doc mimaReportBinaryIssues'

- name: Run native build
if: matrix.scala == '2.12.19'
run: sbt '++ ${{ matrix.scala }}' coreNative/test examplesNative/test

- name: Compress target directories
run: tar cf targets.tar examples/.native/target target core/.native/target core/.js/target examples/.js/target core/.jvm/target examples/.jvm/target project/target

- name: Upload target directories
uses: actions/upload-artifact@v4
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.12.19]
java: [temurin@11]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@11)
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
cache: sbt

- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Download target directories (2.12.19)
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-2.12.19-${{ matrix.java }}

- name: Inflate target directories (2.12.19)
run: |
tar xf targets.tar
rm targets.tar

- name: Download target directories (2.13.14)
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-2.13.14-${{ matrix.java }}

- name: Inflate target directories (2.13.14)
run: |
tar xf targets.tar
rm targets.tar

- name: Publish artifacts
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
run: sbt ci-release
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
simulacrum
==========

[![Continuous Integration](https://github.com/typelevel/simulacrum/actions/workflows/ci.yml/badge.svg)](https://github.com/typelevel/simulacrum/actions/workflows/ci.yml)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.typelevel/simulacrum_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.typelevel/simulacrum_2.13)
[![Continuous Integration](https://github.com/leviysoft/simulacrum/actions/workflows/ci.yml/badge.svg)](https://github.com/leviysoft/simulacrum/actions/workflows/ci.yml)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.leviysoft/simulacrum_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.leviysoft/simulacrum_2.13)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mpilquist/simulacrum?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

----
Expand All @@ -11,6 +11,8 @@ simulacrum

This fork is created to maintain functioning binaries of simulacrum since [Typelevel's repo](https://github.com/typelevel/simulacrum) seems stale

Package name is changed to `simulacrum_` so that LeviySoft's artifact can be used alongside Typelevel's one

----

Type classes rock. Alas, their encoding in Scala requires a lot of boilerplate, which doesn't rock. There is inconsistency between projects, where type classes are encoded differently. There is inconsistency within projects, where object-oriented forwarders (aka. ops, syntax) accidentally differ in exact parameter lists or forwarders are missing where they are expected to be. Even in disciplined teams, the bike-shedding opportunities alone are a source of lost productivity.
Expand Down Expand Up @@ -153,7 +155,7 @@ Note that the second approach will not include the `map` operation of its grandp
This project supports Scala 2.12, and 2.13. The project is based on macro paradise. To use the project, add the following to your build.sbt:

```scala
libraryDependencies += "org.typelevel" %% "simulacrum" % "1.0.1"
libraryDependencies += "io.github.leviysoft" %% "simulacrum" % "1.0.1"

// For Scala 2.12
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)
Expand Down
105 changes: 45 additions & 60 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import sbtrelease._
import com.typesafe.tools.mima.core._
import sbtcrossproject.CrossPlugin.autoImport.crossProject
import sbtcrossproject.CrossType
import ReleaseTransformations._

val Scala212 = "2.12.19"
val NativeCond = s"matrix.scala == '$Scala212'"
val Scala213 = "2.13.14"

ThisBuild / crossScalaVersions := Seq("2.12.19", "2.13.14")
ThisBuild / crossScalaVersions := Seq(Scala212, Scala213)
ThisBuild / scalaVersion := Scala212

ThisBuild / githubWorkflowPublishTargetBranches := Seq()
Expand All @@ -16,30 +14,51 @@ ThisBuild / githubWorkflowBuildPreamble +=
WorkflowStep.Run(
List("sudo apt install clang libunwind-dev libgc-dev libre2-dev"),
name = Some("Setup scala native dependencies"),
cond = Some(NativeCond))
)

ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(
List("test", "test:doc", "mimaReportBinaryIssues"),
name = Some("Run main build")),
name = Some("Run main build")
),

WorkflowStep.Sbt(
List("coreNative/test", "examplesNative/test"),
name = Some("Run native build"),
cond = Some(NativeCond)))
)
)

ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
ThisBuild / githubWorkflowPublishTargetBranches :=
Seq(RefPredicate.StartsWith(Ref.Tag("v")))

ThisBuild / githubWorkflowPublish := Seq(
WorkflowStep.Sbt(
List("ci-release"),
name = Some("Publish artifacts"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}"
)
)
)

ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("11"))

val scalatestVersion = "3.2.19"

lazy val nativeCommonSettings = Def.settings(
scalaVersion := Scala212,
crossScalaVersions := Seq(Scala212),
crossScalaVersions := Seq(Scala212, Scala213),
//nativeLinkStubs := true
)

lazy val commonSettings = Seq(
organization := "org.typelevel",
sonatypeCredentialHost := "s01.oss.sonatype.org",
sonatypeRepository := "https://s01.oss.sonatype.org/service/local",
organization := "io.github.leviysoft",
scalacOptions ++= Seq(
"-deprecation",
"-feature",
Expand Down Expand Up @@ -73,56 +92,21 @@ lazy val commonSettings = Seq(
Nil
}
},
licenses += ("Three-clause BSD-style", url("https://github.com/mpilquist/simulacrum/blob/master/LICENSE")),
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (version.value.trim.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
publishMavenStyle := true,
Test / publishArtifact := false,
pomIncludeRepository := { x => false },
pomExtra := (
<url>http://github.com/mpilquist/simulacrum</url>
<scm>
<url>[email protected]:mpilquist/simulacrum.git</url>
<connection>scm:git:[email protected]:mpilquist/simulacrum.git</connection>
</scm>
<developers>
<developer>
<id>mpilquist</id>
<name>Michael Pilquist</name>
<url>http://github.com/mpilquist</url>
</developer>
</developers>
),
pomPostProcess := { node =>
import scala.xml._
import scala.xml.transform._
def stripIf(f: Node => Boolean) = new RewriteRule {
override def transform(n: Node) =
if (f(n)) NodeSeq.Empty else n
}
val stripTestScope = stripIf { n => n.label == "dependency" && (n \ "scope").text == "test" }
new RuleTransformer(stripTestScope).transform(node)(0)
},
releaseCrossBuild := true,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
releaseStepCommandAndRemaining("test:doc"),
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishArtifacts,
releaseStepCommandAndRemaining(s";++${Scala212}!;coreNative/publish"),
setNextVersion,
commitNextVersion,
pushChanges
licenses += ("Three-clause BSD-style", url("https://github.com/leviysoft/simulacrum/blob/master/LICENSE")),
homepage := Some(url("https://github.com/leviysoft/simulacrum")),
developers := List(
Developer(
"mpilquist",
"Michael Pilquist",
"-",
url("http://github.com/mpilquist")
),
Developer(
"danslapman",
"Daniil Smirnov",
"[email protected]",
url("https://github.com/danslapman")
)
),
Test / compile / wartremoverErrors ++= Seq(
Wart.ExplicitImplicitTypes,
Expand Down Expand Up @@ -199,5 +183,6 @@ lazy val examplesNative = examples.native
lazy val noPublishSettings = Seq(
publish := {},
publishLocal := {},
publishArtifact := false
publishArtifact := false,
publish / skip := true
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package simulacrum
package simulacrum_

import scala.annotation.{ compileTimeOnly, StaticAnnotation }
import scala.language.experimental.macros
Expand Down Expand Up @@ -103,7 +103,7 @@ class TypeClassMacros(val c: Context) {
val suppress = sourceMethod.mods.annotations.filter { ann =>
val typed = c.typecheck(ann)
typed.tpe.typeSymbol.fullName match {
case "simulacrum.noop" => true
case "simulacrum_.noop" => true
case _ => false
}
}.nonEmpty
Expand All @@ -127,7 +127,7 @@ class TypeClassMacros(val c: Context) {
val overrides = sourceMethod.mods.annotations.flatMap { ann =>
val typed = c.typecheck(ann)
typed.tpe.typeSymbol.fullName match {
case "simulacrum.op" =>
case "simulacrum_.op" =>
val q"new ${_}(${Literal(Constant(alias: String))}, ..$rest)" = typed
List(genAlias(alias, rest))
case _ => Nil
Expand All @@ -141,8 +141,8 @@ class TypeClassMacros(val c: Context) {
val filteredAnnotations = mods.annotations.filter { ann =>
val typed = c.typecheck(ann)
typed.tpe.typeSymbol.fullName match {
case "simulacrum.op" => false
case "simulacrum.noop" => false
case "simulacrum_.op" => false
case "simulacrum_.noop" => false
case _ => true
}
}
Expand Down Expand Up @@ -321,7 +321,7 @@ class TypeClassMacros(val c: Context) {
val tparamNames = tparams.map { _.name }
val tcargs = typeClass.mods.annotations.flatMap { ann =>
val typed = c.typecheck(ann)
if (typed.tpe.typeSymbol.fullName == "simulacrum.typeclass") {
if (typed.tpe.typeSymbol.fullName == "simulacrum_.typeclass") {
val q"new ${_}(..${args})" = typed
List(args)
} else Nil
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package simulacrum

package simulacrum_

// NB: These imports are because the tests are compiled with `-Yno-imports`, to
// ensure that simulacrum works in projects that use that flag.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package simulacrum
package simulacrum_

import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
Expand Down Expand Up @@ -121,7 +121,7 @@ class TypeClassTest extends AnyWordSpec with Matchers {
"supports aliasing the name of adapted methods (without named arg)" in {
@typeclass trait Sg[A] {
@op("|+|", true) def append(x: A, y: A): A
@simulacrum.op("~", true) def foo(x: A, y: A): A = append(x, y)
@op("~", true) def foo(x: A, y: A): A = append(x, y)
}
implicit val sgInt: Sg[Int] = new Sg[Int] {
def append(x: Int, y: Int) = x + y
Expand All @@ -137,7 +137,7 @@ class TypeClassTest extends AnyWordSpec with Matchers {
"supports suppression of adapter methods" in {
@typeclass trait Sg[A] {
@noop def append(x: A, y: A): A
@simulacrum.noop def foo(x: A, y: A): A = append(x, y)
@noop def foo(x: A, y: A): A = append(x, y)
}
implicit val sgInt: Sg[Int] = new Sg[Int] {
def append(x: Int, y: Int) = x + y
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package simulacrum.jvmexamples
package simulacrum_.jvmexamples

import simulacrum._
import simulacrum_._
import shapeless.test.illTyped

import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package simulacrum.examples

import simulacrum._
package simulacrum_.examples

import simulacrum_._
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec

Expand Down
9 changes: 4 additions & 5 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ val scalaNativeVersion =
Option(System.getenv("SCALANATIVE_VERSION")).getOrElse("0.5.5")

addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.24.0")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("io.crashbox" % "sbt-gpg" % "0.2.1")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.6.1")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.1")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.4")
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "3.2.1")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.2.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion)
1 change: 0 additions & 1 deletion version.sbt

This file was deleted.