From 0a6390482a4c895de4ededcecf8c1a8636274edd Mon Sep 17 00:00:00 2001 From: Jim Lawson Date: Fri, 2 Nov 2018 13:56:01 -0700 Subject: Circleci (#920) Be consistent with the use of /dev/null for sbt's stdin (force sbt to exit instead of bringing up a dialog). Enforce Jenkins' scalastyle limit of 40 warnings via CHECKSTYLE_LIMIT in environment. Force tests to run sequentially if -DminimalResources is set on the command line. Ensure we see valid scalastyle output. Make checkstyle dependent on one of the tests (so a style failure will fail the build only after tests pass). --- .circleci/config.yml | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++ build.sbt | 7 ++- 2 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..7c881d12 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,163 @@ +# Scala CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/sample-config/ for more details +# +# Use the chisel3-tools image to build and run FIRRTL and chisel tests. +defaultImageUserWDEnv: &defaultImageUserWDEnv + docker: + - image: ucbbar/chisel3-tools + user: "chisel" + + working_directory: ~/repo + + environment: + # Customize the JVM maximum heap limit + JVM_OPTS: -Xmx3200m + TERM: dumb + CHISEL_REV: origin/master + FIRRTL_REPO: git@github.com:freechipsproject/firrtl.git + FIRRTL_BRANCH: master + FIRRTL_REV: master + CHECKSTYLE_LIMIT: 40 + SBT_ARGS: "" + + +version: 2 + +jobs: + build-prep: + <<: *defaultImageUserWDEnv + + steps: + + # Perform a "default" checkout to get ssh set up. + - checkout: + path: chisel3 + + - run: + command: | + date > date.prep + printenv + ls -l + git clone --depth 10 --branch $FIRRTL_BRANCH "$FIRRTL_REPO" firrtl && (cd firrtl && git checkout $FIRRTL_REV) + echo $FIRRTL_REV && (cd firrtl && git log -1 > ../firrtl.log) + + + - persist_to_workspace: + root: /home/chisel + paths: + - repo + - .ivy2 + - .m2 + - .sbt + + build-firrtl: + <<: *defaultImageUserWDEnv + + steps: + - attach_workspace: + at: /home/chisel + + # publish FIRRTL + - run: + command: | + date > date.firrtl + (cd firrtl && cat /dev/null | sbt $SBT_ARGS +publishLocal) + + - persist_to_workspace: + root: /home/chisel + paths: + - repo + - .ivy2 + - .m2 + - .sbt + + # Define a pure build chisel - currently unused since we can compile and test chisel in one step + # and we don't have downstream jobs that need the published version of chisel. + build-chisel: + <<: *defaultImageUserWDEnv + + steps: + - attach_workspace: + at: /home/chisel + + # publish chisel + - run: date > date.chisel3 && (cd chisel3 && cat /dev/null | sbt $SBT_ARGS +publishLocal) + + - persist_to_workspace: + root: /home/chisel + paths: + - repo + - .ivy2 + - .m2 + - .sbt + + test-chisel-2.11: + <<: *defaultImageUserWDEnv + + steps: + - attach_workspace: + at: /home/chisel + + # Set environment + - run: echo 'export PATH="/opt/verilator/verilator_3_922/bin:/opt/yosys/bin:$PATH"' >> $BASH_ENV + + # The -DminimalResources flag causes sbt to run tests sequentially, + # so we could actually use "sbt +test" to run all the crossVersioned tests. + # We currently run them separately so we can run them in parallel. + - run: + command: | + (cd chisel3 && cat /dev/null | sbt $SBT_ARGS -DminimalResources "++2.11.12" test) + + test-chisel-2.12: + <<: *defaultImageUserWDEnv + + steps: + - attach_workspace: + at: /home/chisel + + # Set environment + - run: echo 'export PATH="/opt/verilator/verilator_3_922/bin:/opt/yosys/bin:$PATH"' >> $BASH_ENV + + # The -DminimalResources flag causes sbt to run tests sequentially, + # so we could actually use "sbt +test" to run all the crossVersioned tests. + # We currently run them separately so we can run them in parallel. + - run: + command: | + (cd chisel3 && cat /dev/null | sbt $SBT_ARGS -DminimalResources "++2.12.6" test) + + checkstyle-chisel: + <<: *defaultImageUserWDEnv + + steps: + - attach_workspace: + at: /home/chisel + + - run: + command: | + # We expect the "[info]" field from sbt so the warning count will be in column 4 + (cd chisel3 && cat /dev/null | sbt $SBT_ARGS scalastyle | gawk -v WARN_FAIL=2 -e '/scalastyle Found [0-9]+ warnings/ { print $0; if ($4 > ENVIRON["CHECKSTYLE_LIMIT"]) WARN_FAIL=1; else if (WARN_FAIL == 2) WARN_FAIL=0 }' -e 'END { exit WARN_FAIL}') + +workflows: + version: 2 + + build_and_test: + jobs: + - build-prep + - build-firrtl: + requires: + - build-prep + - test-chisel-2.11: + requires: + - build-firrtl + - test-chisel-2.12: + requires: + - build-firrtl + - checkstyle-chisel: + # Strictly speaking, this is only dependent on build-firrtl, + # but it is faster than the test jobs so if it fails, + # it fails the entire build before we get a chance to complete the tests. + # If we make it dependent on at least one of the tests, + # there's a better chance to see if the tests fail before we flag a style failure + requires: + - test-chisel-2.12 diff --git a/build.sbt b/build.sbt index 0763414f..e06d27e6 100644 --- a/build.sbt +++ b/build.sbt @@ -99,8 +99,11 @@ lazy val chiselSettings = Seq ( "com.github.scopt" %% "scopt" % "3.7.0" ), - // Tests from other projects may still run concurrently. - parallelExecution in Test := true, + // Tests from other projects may still run concurrently + // if we're not running with -DminimalResources. + // Another option would be to experiment with: + // concurrentRestrictions in Global += Tags.limit(Tags.Test, 1), + Test / parallelExecution := !sys.props.contains("minimalResources"), javacOptions ++= javacOptionsVersion(scalaVersion.value) ) -- cgit v1.2.3