diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 00000000..33623f91 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,27 @@ +name: Pull Request +on: + pull_request: +jobs: + test: + name: Unit Tests + runs-on: ubuntu-latest + strategy: + matrix: + scala: [ "2.12.15", "2.13.8" ] + steps: + - uses: actions/checkout@v3 + - uses: olafurpg/setup-scala@v13 + with: + java-version: openjdk@1.17 + - uses: coursier/cache-action@v6.3 + - run: sbt ++${{ matrix.scala }} test + + format: + name: Check formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: olafurpg/setup-scala@v13 + with: + java-version: openjdk@1.17 + - run: sbt scalafmtCheckAll diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..20c6b3ea --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,25 @@ +name: Publish Release +on: + push: + branches: [master, main] + tags: ["*"] +jobs: + publish: + name: Publish to Sonatype Releases + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: olafurpg/setup-scala@v13 + with: + java-version: openjdk@1.17 + - uses: coursier/cache-action@v6.3 + - run: sudo apt update && sudo apt install -y gnupg + - run: echo $PGP_SECRET | base64 --decode | gpg --batch --import + env: + PGP_SECRET: ${{ secrets.PGP_SECRET }} + - run: sbt +test ciReleaseTagNextVersion ciReleaseSonatype + env: + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} diff --git a/.github/workflows/run-ci.yml b/.github/workflows/run-ci.yml deleted file mode 100644 index bee78381..00000000 --- a/.github/workflows/run-ci.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Test - -on: - pull_request: - push: - branches: - - master - -jobs: - test: - name: Unit Tests - runs-on: ubuntu-latest - strategy: - matrix: - scala: [ 2.12.14 ] - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup Scala - uses: olafurpg/setup-scala@v10 - - name: Cache - uses: coursier/cache-action@v5 - - name: Get submodules - run: git submodule update --init - - name: Test - run: sbt test - - doc: - name: Documentation and formatting - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Setup Scala - uses: olafurpg/setup-scala@v10 - - name: Check Formatting - run: sbt scalafmtCheckAll - - all_test_passed: - name: "all tests passed" - runs-on: ubuntu-latest - needs: [test, doc] - steps: - - run: echo Success diff --git a/.gitignore b/.gitignore index 12c0f6ad..bdf44def 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ test_run_dir/ *.fir *.f *.anno.json +/gnupg-* ### XilinxISE template # intermediate build files @@ -326,6 +327,7 @@ lib_managed/ src_managed/ project/boot/ project/plugins/project/ +.bsp # Scala-IDE specific .scala_dependencies diff --git a/README.md b/README.md index 30d55252..36e7ebe9 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Barstools --- -![Test](https://github.com/freechipsproject/ucb-bar/barstools/Test/badge.svg) +![CI Status](https://github.com/ucb-bar/barstools/actions/workflows/publish.yml/badge.svg) **Barstools** is a collection of useful utilities for BAR projects diff --git a/build.sbt b/build.sbt index 1a972764..8bfba400 100644 --- a/build.sbt +++ b/build.sbt @@ -1,31 +1,57 @@ // See LICENSE for license details. +enablePlugins(GitVersioning) +addCompilerPlugin("edu.berkeley.cs" % "chisel3-plugin" % defaultVersions("chisel3") cross CrossVersion.full) + val defaultVersions = Map( - "chisel3" -> "3.5.1", + "chisel3" -> "3.5.3", "chisel-iotesters" -> "2.5.1" ) -organization := "edu.berkeley.cs" -version := "0.4-SNAPSHOT" -name := "tapeout" -scalaVersion := "2.12.13" -crossScalaVersions := Seq("2.12.13", "2.13.6") -scalacOptions := Seq("-deprecation", "-feature", "-language:reflectiveCalls") -Test / scalacOptions ++= Seq("-language:reflectiveCalls") -fork := true -mainClass := Some("barstools.macros.MacroCompiler") -libraryDependencies ++= Seq("chisel3","chisel-iotesters").map { - dep: String => "edu.berkeley.cs" %% dep % sys.props.getOrElse(dep + "Version", defaultVersions(dep)) -} -libraryDependencies ++= Seq( - "com.typesafe.play" %% "play-json" % "2.9.2", - "org.scalatest" %% "scalatest" % "3.2.9" % "test", - "org.apache.logging.log4j" % "log4j-api" % "2.11.2", - "org.apache.logging.log4j" % "log4j-core" % "2.11.2" +lazy val buildSettings = Seq( + organization := "edu.berkeley.cs", + // version computed by sbt-ci-release-early + name := "barstools", + scalaVersion := "2.12.15", + crossScalaVersions := Seq("2.12.15", "2.13.8"), + scalacOptions := Seq("-deprecation", "-feature", "-language:reflectiveCalls"), + + Test / scalacOptions ++= Seq("-language:reflectiveCalls"), + fork := true, + + mainClass := Some("barstools.macros.MacroCompiler"), + + libraryDependencies ++= (Seq("chisel3","chisel-iotesters").map { + dep: String => "edu.berkeley.cs" %% dep % sys.props.getOrElse(dep + "Version", defaultVersions(dep)) + }), + + libraryDependencies ++= Seq( + "com.typesafe.play" %% "play-json" % "2.9.2", + "org.apache.logging.log4j" % "log4j-api" % "2.18.0", + "org.apache.logging.log4j" % "log4j-core" % "2.18.0", + "org.scalatest" %% "scalatest" % "3.2.9" % "test" + ), + + resolvers ++= Seq( + Resolver.sonatypeRepo("snapshots"), + Resolver.sonatypeRepo("releases"), + Resolver.mavenLocal + ) ) -addCompilerPlugin("edu.berkeley.cs" % "chisel3-plugin" % defaultVersions("chisel3") cross CrossVersion.full) -resolvers ++= Seq( - Resolver.sonatypeRepo("snapshots"), - Resolver.sonatypeRepo("releases"), - Resolver.mavenLocal + +lazy val publishSettings = Seq( + scmInfo := Some(ScmInfo( + url("https://github.com/ucb-bar/barstools"), + "scm:git@github.com:ucb-bar/barstools.git")), + licenses := List("BSD 3-Clause" -> url("https://opensource.org/licenses/BSD-3-Clause")), + developers := List(Developer("edwardcwang", "Edward Wang", "", url("https://github.com/edwardcwang")), Developer("chick", "Chick Markley", "", url("https://github.com/chick"))), + homepage := Some(url("https://github.com/ucb-bar/barstools/")), + publishTo := sonatypePublishToBundle.value, + + Test / publishArtifact := false, + publishMavenStyle := true ) + +lazy val barstools = (project in file(".")) + .settings(buildSettings) + .settings(publishSettings) diff --git a/project/build.properties b/project/build.properties index 0837f7a1..c8fcab54 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.3.13 +sbt.version=1.6.2 diff --git a/project/plugins.sbt b/project/plugins.sbt index 5d6b1779..d939d901 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,4 @@ addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3") addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2") +addSbtPlugin("io.shiftleft" % "sbt-ci-release-early" % "2.0.32") diff --git a/src/test/scala/barstools/tapeout/transforms/GenerateTopSpec.scala b/src/test/scala/barstools/tapeout/transforms/GenerateTopSpec.scala index d967c8df..b6e5ba90 100644 --- a/src/test/scala/barstools/tapeout/transforms/GenerateTopSpec.scala +++ b/src/test/scala/barstools/tapeout/transforms/GenerateTopSpec.scala @@ -13,7 +13,7 @@ class GenerateTopSpec extends AnyFreeSpec with Matchers { "Generate top and harness" - { "should include the following transforms" in { val targetDir = "test_run_dir/generate_top_and_harness" - val transformListName = s"$targetDir/ExampleModuleNeesResetInvertTransforms.log" + val transformListName = s"$targetDir/ExampleModuleNeedsResetInvertTransforms.log" FileUtils.makeDirectory(targetDir) (new ChiselStage).emitChirrtl(new ExampleModuleNeedsResetInverted, Array("--target-dir", targetDir)) @@ -24,7 +24,11 @@ class GenerateTopSpec extends AnyFreeSpec with Matchers { "-ll", "info", "--log-file", - transformListName + transformListName, + "-o", + s"$targetDir/ExampleModuleNeedsResetInverted.top.v", + "-tho", + s"$targetDir/ExampleModuleNeedsResetInverted.harness.v" ) )