diff options
| author | Jack Koenig | 2021-01-19 11:51:33 -0800 |
|---|---|---|
| committer | GitHub | 2021-01-19 11:51:33 -0800 |
| commit | bbd7fc4115728ecc7cf88bf0524f2126d8220c34 (patch) | |
| tree | 1d49d377c0da72490f70a2dbcc9e6a4881b0d7d1 | |
| parent | 15013df6f6ac2dafeb35d7ed15cf95c7ac8a5bef (diff) | |
Switch from Travis to Github Actions CI (#2041)
* Fix .run_formal_checks for Github Actions instead of Travis
* Remove .run_chisel_tests
Because we publish SNAPSHOTs on every merge to master, the Chisel repo
checks against master of FIRRTL regularly
* Only run unidoc for Scala 2.12
Under Travis we ran for 2.11, 2.12, and 2.13, but it doesn't work when
using ++2.<major>.<minor> when major != to 2.12. It seems if we want to
run all 3, we have to run as `sbt +unidoc`. It's not clear how much
benefit we get from building on the other versions, so stick with 2.12
for now.
* Generate .mergify.yml with script in chisel-repo-tools
Generated with config:
conditions:
- status-success=all tests passed
branches:
- 1.2.x
- 1.3.x
- 1.4.x
| -rw-r--r-- | .github/workflows/test.yml | 108 | ||||
| -rw-r--r-- | .mergify.yml | 219 | ||||
| -rw-r--r-- | .run_chisel_tests.sh | 20 | ||||
| -rwxr-xr-x | .run_formal_checks.sh | 26 | ||||
| -rw-r--r-- | .travis.yml | 151 | ||||
| -rw-r--r-- | build.sbt | 5 | ||||
| -rw-r--r-- | project/plugins.sbt | 2 | ||||
| -rwxr-xr-x | scripts/formal_equiv.sh | 2 |
8 files changed, 235 insertions, 298 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..3f57a1a6 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,108 @@ +name: Continuous Integration + +on: + pull_request: + push: + branches: + - master + - 1.4.x + - 1.3.x + - 1.2.x + +jobs: + test: + name: sbt test + runs-on: ubuntu-latest + strategy: + matrix: + scala: [2.13.2, 2.12.12, 2.11.12] + container: + image: ucbbar/chisel3-tools + options: --user github --entrypoint /bin/bash + env: + CONTAINER_HOME: /home/github + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Scala + uses: olafurpg/setup-scala@v10 + with: + java-version: adopt@1.8 + - name: Cache Scala + uses: coursier/cache-action@v5 + - name: Unidoc builds (Scala 2.12 only) + if: matrix.scala == '2.12.12' + run: sbt ++${{ matrix.scala }} unidoc + - name: Sanity check benchmarking scripts (Scala 2.12 only) + if: matrix.scala == '2.12.12' + run: | + benchmark/scripts/benchmark_cold_compile.py -N 2 --designs regress/ICache.fir --versions HEAD + benchmark/scripts/find_heap_bound.py -- -cp firrtl*jar firrtl.stage.FirrtlMain -i regress/ICache.fir -o out -X verilog + - name: Test + run: sbt ++${{ matrix.scala }} test + - name: Binary compatibility + run: sbt ++${{ matrix.scala }} mimaReportBinaryIssues + + # TODO find better way to express Ops and AddNot as single test + equiv: + name: formal equivalence + runs-on: ubuntu-latest + strategy: + matrix: + design: [RocketCore, FPU, ICache, Ops, AddNot] + container: + image: ucbbar/chisel3-tools + options: --user github --entrypoint /bin/bash + env: + CONTAINER_HOME: /home/github + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Scala + uses: olafurpg/setup-scala@v10 + with: + java-version: adopt@1.8 + - name: Cache Scala + uses: coursier/cache-action@v5 + - name: Run Formal Equivalence + run: ./.run_formal_checks.sh ${{ matrix.design }} + + # Sentinel job to simplify how we specify which checks need to pass in branch + # protection and in Mergify + # + # When adding new jobs, please add them to `needs` below + all_tests_passed: + name: "all tests passed" + needs: [test, equiv] + runs-on: ubuntu-latest + steps: + - run: echo Success! + + # sbt ci-release publishes all cross versions so this job needs to be + # separate from a Scala versions build matrix to avoid duplicate publishing + publish: + needs: [all_tests_passed] + runs-on: ubuntu-latest + if: github.event_name == 'push' + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Scala + uses: olafurpg/setup-scala@v10 + with: + java-version: adopt@1.8 + - name: Cache Scala + uses: coursier/cache-action@v5 + - name: Setup GPG (for Publish) + uses: olafurpg/setup-gpg@v3 + - name: Publish + run: sbt ci-release + env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + diff --git a/.mergify.yml b/.mergify.yml index b09c861a..a4b8697f 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -1,116 +1,107 @@ pull_request_rules: - - name: remove outdated reviews - conditions: - - base=master - actions: - dismiss_reviews: +- name: automatic squash-and-merge on CI success and review + conditions: + - status-success=all tests passed + - '#approved-reviews-by>=1' + - '#changes-requested-reviews-by=0' + - base=master + - label="Please Merge" + - label!="DO NOT MERGE" + - label!="bp-conflict" + actions: + merge: + method: squash + strict: smart + strict_method: merge +- name: backport to 1.4.x + conditions: + - merged + - base=master + - milestone=1.4.x + actions: + backport: + branches: + - 1.4.x + ignore_conflicts: true + label_conflicts: bp-conflict + label: + add: + - Backported +- name: backport to 1.3.x, 1.4.x + conditions: + - merged + - base=master + - milestone=1.3.x + actions: + backport: + branches: + - 1.3.x + - 1.4.x + ignore_conflicts: true + label_conflicts: bp-conflict + label: + add: + - Backported +- name: backport to 1.2.x, 1.3.x, 1.4.x + conditions: + - merged + - base=master + - milestone=1.2.x + actions: + backport: + branches: + - 1.2.x + - 1.3.x + - 1.4.x + ignore_conflicts: true + label_conflicts: bp-conflict + label: + add: + - Backported +- name: label Mergify backport PR + conditions: + - body~=This is an automated backport of pull request \#\d+ done by Mergify + actions: + label: + add: + - Backport +- name: automatic squash-and-mege of 1.2.x backport PRs + conditions: + - status-success=all tests passed + - '#changes-requested-reviews-by=0' + - base=1.2.x + - label="Backport" + - label!="DO NOT MERGE" + - label!="bp-conflict" + actions: + merge: + method: squash + strict: smart + strict_method: merge +- name: automatic squash-and-mege of 1.3.x backport PRs + conditions: + - status-success=all tests passed + - '#changes-requested-reviews-by=0' + - base=1.3.x + - label="Backport" + - label!="DO NOT MERGE" + - label!="bp-conflict" + actions: + merge: + method: squash + strict: smart + strict_method: merge +- name: automatic squash-and-mege of 1.4.x backport PRs + conditions: + - status-success=all tests passed + - '#changes-requested-reviews-by=0' + - base=1.4.x + - label="Backport" + - label!="DO NOT MERGE" + - label!="bp-conflict" + actions: + merge: + method: squash + strict: smart + strict_method: merge -pull_request_rules: - - name: automatic squash-and-merge on CI success and review - conditions: - - status-success=Travis CI - Pull Request - - "#approved-reviews-by>=1" - - "#changes-requested-reviews-by=0" - - base=master - - label="Please Merge" - - label!="DO NOT MERGE" - - label!="bp-conflict" - actions: - merge: - method: squash - strict: smart - strict_method: merge - - - name: backport to 1.4.x - conditions: - - merged - - base=master - - milestone=1.4.x - actions: - backport: - branches: - - 1.4.x - ignore_conflicts: True - label_conflicts: "bp-conflict" - label: - add: [Backported] - - - name: backport to 1.3.x and 1.4.x - conditions: - - merged - - base=master - - milestone=1.3.x - actions: - backport: - branches: - - 1.3.x - - 1.4.x - ignore_conflicts: True - label_conflicts: "bp-conflict" - label: - add: [Backported] - - - name: backport to 1.2.x, 1.3.x, and 1.4.x - conditions: - - merged - - base=master - - milestone=1.2.X - actions: - backport: - branches: - - 1.2.x - - 1.3.x - - 1.4.x - ignore_conflicts: True - label_conflicts: "bp-conflict" - label: - add: [Backported] - - - name: label Mergify backport PR - conditions: - - body~=This is an automated backport of pull request \#\d+ done by Mergify - actions: - label: - add: [Backport] - - - name: automatic squash-and-merge of 1.4.x backport PRs - conditions: - - status-success=Travis CI - Pull Request - - "#changes-requested-reviews-by=0" - - base=1.4.x - - label="Backport" - - label!="DO NOT MERGE" - - label!="bp-conflict" - actions: - merge: - method: squash - strict: smart - strict_method: merge - - - name: automatic squash-and-merge of 1.3.x backport PRs - conditions: - - status-success=Travis CI - Pull Request - - "#changes-requested-reviews-by=0" - - base=1.3.x - - label="Backport" - - label!="DO NOT MERGE" - - label!="bp-conflict" - actions: - merge: - method: squash - strict: smart - strict_method: merge - - - name: automatic squash-and-merge of 1.2.x backport PRs - conditions: - - status-success=Travis CI - Pull Request - - "#changes-requested-reviews-by=0" - - base=1.2.x - - label="Backport" - - label!="DO NOT MERGE" - - label!="bp-conflict" - actions: - merge: - method: squash - strict: smart - strict_method: merge diff --git a/.run_chisel_tests.sh b/.run_chisel_tests.sh deleted file mode 100644 index dbec894e..00000000 --- a/.run_chisel_tests.sh +++ /dev/null @@ -1,20 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -set -e - -# Use appropriate branches. -# Each stable branch of FIRRTL should have a fixed value for these branches. -CHISEL_BRANCH="master" -TREADLE_BRANCH="master" - -# Skip chisel tests if the commit message says to -# Replace ... with .. in TRAVIS_COMMIT_RANGE, see https://github.com/travis-ci/travis-ci/issues/4596 -if git log --format=%B --no-merges ${TRAVIS_COMMIT_RANGE/.../..} | grep '\[skip chisel tests\]'; then - exit 0 -else - sbt $SBT_ARGS publishLocal - git clone https://github.com/freechipsproject/treadle.git --single-branch -b ${TREADLE_BRANCH} --depth 10 - (cd treadle && sbt $SBT_ARGS publishLocal) - git clone https://github.com/ucb-bar/chisel3.git --single-branch -b ${CHISEL_BRANCH} - cd chisel3 - sbt $SBT_ARGS test -fi diff --git a/.run_formal_checks.sh b/.run_formal_checks.sh index f5ffec25..0a28a1d1 100755 --- a/.run_formal_checks.sh +++ b/.run_formal_checks.sh @@ -11,23 +11,25 @@ fi DUT=$1 -# Run formal check only for PRs -if [ $TRAVIS_PULL_REQUEST = "false" ]; then - echo "Not a pull request, no formal check" - exit 0 -else - # $TRAVIS_BRANCH is branch targeted by PR - # Travis does a shallow clone, checkout PR target so that we have it - # THen return to previous branch so HEAD points to the commit we're testing - git remote set-branches origin $TRAVIS_BRANCH && git fetch - git checkout $TRAVIS_BRANCH +# See https://docs.github.com/en/actions/reference/environment-variables +# for info about these variables + +# Run formal check only for PRs, GITHUB_BASE_REF is only set for PRs +if [ ! -z "$GITHUB_BASE_REF" ]; then + # Github Actions does a shallow clone, checkout PR target so that we have it + # Then return to previous branch so HEAD points to the commit we're testing + git remote set-branches origin $GITHUB_BASE_REF && git fetch + git checkout $GITHUB_BASE_REF git checkout - # Skip if '[skip formal checks]' shows up in any of the commit messages in the PR - if git log --format=%B --no-merges $TRAVIS_BRANCH..HEAD | grep '\[skip formal checks\]'; then + if git log --format=%B --no-merges $GITHUB_BASE_REF..HEAD | grep '\[skip formal checks\]'; then echo "Commit message says to skip formal checks" exit 0 else cp regress/$DUT.fir $DUT.fir - ./scripts/formal_equiv.sh HEAD $TRAVIS_BRANCH $DUT + ./scripts/formal_equiv.sh HEAD $GITHUB_BASE_REF $DUT fi +else + echo "Not a pull request, no formal check" + exit 0 fi diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index efcb6434..00000000 --- a/.travis.yml +++ /dev/null @@ -1,151 +0,0 @@ -language: scala -sudo: false - -jdk: openjdk8 - -branches: - only: - - master - - 1.4.x - - 1.3.x - - 1.2.x - -cache: - directories: - $HOME/.cache/coursier - $HOME/.sbt - $INSTALL_DIR - -git: - depth: 10 - -env: - global: - INSTALL_DIR=$TRAVIS_BUILD_DIR/install - VERILATOR_ROOT=$INSTALL_DIR - PATH=$PATH:$VERILATOR_ROOT/bin:$TRAVIS_BUILD_DIR/utils/bin - SBT_ARGS="-Dsbt.log.noformat=true" - -before_script: - - OLDEST_SHARED=`git log --format=%H $TRAVIS_COMMIT_RANGE | tail -n1` - - OLDEST_COMMIT=`git log --format=%H | tail -n1` - - if [ $OLDEST_SHARED == $OLDEST_COMMIT ]; then git fetch --unshallow; fi - -stages: - - name: prepare - - name: test - - name: release - if: (branch IN (master, 1.4.x, 1.3.x, 1.2.x)) AND (type = push) AND (NOT fork) - -# We do not use the built-in tests as generated by using multiple Scala -# versions because the cache is not shared between stages with any -# environmental differences. -# Instead, we specify the version of Scala manually for each test (or leave it -# as the default as defined in FIRRTL's build.sbt). -jobs: - include: - # Because these write to the same install directory, they must run in the - # same script - - stage: prepare - name: "Install: [Verilator, Yosys, Z3]" - script: - - bash .install_verilator.sh - - verilator --version - - bash .install_yosys.sh - - yosys -V - - bash .install_z3.sh - - z3 -version - - stage: prepare - name: "Compile FIRRTL to share with subsequent stages" - script: - - sbt $SBT_ARGS assembly - workspaces: - create: - name: firrtl_build - paths: - - target/ - - utils/bin/firrtl.jar - - project/project/ - - project/target/ - - stage: test - name: "All files must be formatted with scalafmt" - workspaces: - use: firrtl_build - script: - - sbt scalafmtCheckAll - - stage: test - name: "Unidoc builds (no warnings)" - workspaces: - use: firrtl_build - script: - - sbt $SBT_ARGS +unidoc - - stage: test - name: "Tests: FIRRTL (2.13)" - workspaces: - use: firrtl_build - script: - - verilator --version - - sbt ++2.13.2 $SBT_ARGS test - - stage: test - name: "Tests: FIRRTL (2.12)" - workspaces: - use: firrtl_build - script: - - verilator --version - - sbt $SBT_ARGS test - - stage: test - name: "Tests: FIRRTL (2.11)" - script: - - verilator --version - - sbt ++2.11.12 $SBT_ARGS test - - stage: test - name: "Tests: chisel3 (2.12)" - workspaces: - use: firrtl_build - script: - - verilator --version - - bash .run_chisel_tests.sh - - stage: test - name: "Formal equivalence: RocketCore" - workspaces: - use: firrtl_build - script: - - yosys -V - - "travis_wait 30 sleep 1800 &" - - ./.run_formal_checks.sh RocketCore - - stage: test - name: "Formal equivalence: FPU" - workspaces: - use: firrtl_build - script: - - yosys -V - - "travis_wait 30 sleep 1800 &" - - ./.run_formal_checks.sh FPU - - stage: test - name: "Formal equivalence: ICache" - workspaces: - use: firrtl_build - script: - - yosys -V - - "travis_wait 30 sleep 1800 &" - - ./.run_formal_checks.sh ICache - - stage: test - name: "Formal equivalence: small expression-tree stress tests" - workspaces: - use: firrtl_build - script: - - yosys -V - - "travis_wait 30 sleep 1800 &" - - ./.run_formal_checks.sh Ops - - ./.run_formal_checks.sh AddNot - - stage: test - name: "Sanity check benchmarking scripts" - workspaces: - use: firrtl_build - script: - - benchmark/scripts/benchmark_cold_compile.py -N 2 --designs regress/ICache.fir --versions HEAD - - benchmark/scripts/find_heap_bound.py -- -cp firrtl*jar firrtl.stage.FirrtlMain -i regress/ICache.fir -o out -X verilog - # run ci-release only if previous stages passed - - stage: release - name: "Publish SNAPSHOT release" - script: sbt ci-release @@ -55,6 +55,10 @@ lazy val commonSettings = Seq( ) ) +lazy val mimaSettings = Seq( + mimaPreviousArtifacts := Set() +) + lazy val protobufSettings = Seq( sourceDirectory in ProtobufConfig := baseDirectory.value / "src" / "main" / "proto", protobufRunProtoc in ProtobufConfig := (args => @@ -179,6 +183,7 @@ lazy val firrtl = (project in file(".")) buildInfoUsePackageAsPath := true, buildInfoKeys := Seq[BuildInfoKey](buildInfoPackage, version, scalaVersion, sbtVersion) ) + .settings(mimaSettings) lazy val benchmark = (project in file("benchmark")) .dependsOn(firrtl) diff --git a/project/plugins.sbt b/project/plugins.sbt index 346e2560..3ed7accf 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -24,6 +24,8 @@ addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.0") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.8.1") + addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.4") libraryDependencies += "com.github.os72" % "protoc-jar" % "3.11.4" diff --git a/scripts/formal_equiv.sh b/scripts/formal_equiv.sh index 2304b74e..c3d45357 100755 --- a/scripts/formal_equiv.sh +++ b/scripts/formal_equiv.sh @@ -28,7 +28,7 @@ make_verilog () { git checkout $1 local filename="$DUT.$1.v" - sbt "runMain firrtl.Driver -i $DUT.fir -o $filename -X verilog" + sbt "runMain firrtl.stage.FirrtlMain -i $DUT.fir -o $filename -X verilog" RET=$filename } |
