From 6789cd69b360a713d4887a5886749bb0e9d5e40c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Raddum=20Berg?= Date: Mon, 14 Nov 2022 00:17:16 +0100 Subject: [PATCH] github actions, run CI on macos and windows as well - ignore whitespace and blank lines when diffing (matches digesting logic) --- .circleci/config.yml | 54 ------------ .gitattributes | 2 + .github/workflows/ci-build.yml | 87 +++++++++++++++++++ .github/workflows/release-snapshot.yml | 18 ++++ .../internal/importer/ImporterHarness.scala | 11 ++- 5 files changed, 116 insertions(+), 56 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .gitattributes create mode 100644 .github/workflows/ci-build.yml create mode 100644 .github/workflows/release-snapshot.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 53b4ce099c..0000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,54 +0,0 @@ -# Scala CircleCI 2.0 configuration file -# -# Check https://circleci.com/docs/2.0/sample-config/ for more details -# -version: 2.1 -jobs: - build: - docker: - # specify the version you desire here - - image: circleci/openjdk:8-jdk-node - # Specify service dependencies here if necessary - # CircleCI maintains a library of pre-built images - # documented at https://circleci.com/docs/2.0/circleci-images/ - # - image: circleci/postgres:9.4 - - working_directory: ~/repo - - environment: - # Customize the JVM maximum heap limit - JVM_OPTS: -Xmx3200m - TERM: dumb - CI: 'true' - steps: - - checkout - - # Download and cache dependencies - - restore_cache: - keys: - - v2-dependencies--{{ checksum "build.sbt" }} - # fallback to using the latest cache if no exact match is found - - v2-dependencies- - - - run: cat /dev/null | sbt test scalafmtCheck - - - when: - condition: - equal: [ master, <> ] - steps: - - run: cat /dev/null | sbt ci-release - - - when: - condition: - equal: [ dotty-support, <> ] - steps: - - run: cat /dev/null | sbt ci-release - - - save_cache: - paths: - - ~/.sbt - - ~/.m2 - - ~/.ivy2/cache - - ~/.ivy2/local - - ~/.cache/scalablytyped/tests/artifacts - key: v2-dependencies--{{ checksum "build.sbt" }} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..4cab1f4d26 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml new file mode 100644 index 0000000000..3f03a552a4 --- /dev/null +++ b/.github/workflows/ci-build.yml @@ -0,0 +1,87 @@ +name: CI Build +on: + pull_request: + branches: [ 'master' ] + +jobs: + scalafmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: coursier/setup-action@v1.2.0-M3 + with: + apps: scalafmt + + - uses: coursier/cache-action@v6 + + - name: Scalafmt + run: scalafmt -c .scalafmt.conf --check + + build: + name: CI Build on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + timeout-minutes: 20 + strategy: + matrix: + include: + - os: ubuntu-latest + - os: macos-latest + - os: windows-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: coursier/cache-action@v6 + + - uses: coursier/setup-action@v1.2.0-M3 + with: + jvm: adopt:11 + apps: sbt + + - name: Get tests folder sha + id: get-tests-folder-sha + run: | + echo "::set-output name=sha::$(git ls-tree HEAD tests --object-only)" + + - uses: actions/cache@v3 + with: + path: test-cache + key: ${{ runner.os }}-${{ steps.get-tests-folder-sha.outputs.sha }}-test-cache-v1 + + - name: Build and test + run: sbt test + env: + CI: true + CI_TEST_CACHE: ../test-cache + +# commented out while I figure out how to speed it up or when to run it +# sbt-scripted-tests: +# name: Run sbt scripted tests +# runs-on: ubuntu-latest +# timeout-minutes: 25 +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 0 +# +# - uses: coursier/cache-action@v6 +# +# # cache artifacts within same date. should help a bit with the compile time +# - name: Get timestamp +# id: get-date +# run: | +# echo "::set-output name=time::$(date +%yy-%m-%d)" +# +# - uses: actions/cache@v3 +# with: +# path: ~/.ivy2/local/org.scalablytyped +# key: scripted-v1-${{ steps.get-date.outputs.time }} +# +# - uses: coursier/setup-action@v1.2.0-M3 +# with: +# jvm: adopt:11 +# apps: sbt +# +# - name: Run scripted +# run: sbt scripted diff --git a/.github/workflows/release-snapshot.yml b/.github/workflows/release-snapshot.yml new file mode 100644 index 0000000000..92d65ddeab --- /dev/null +++ b/.github/workflows/release-snapshot.yml @@ -0,0 +1,18 @@ +# note that the proper release is made manually with the release script because it's +# a heavy operation (builds all demo repos) +# that's why we don't trigger on tag +name: Release snapshot +on: + push: + branches: [ 'master' ] +jobs: + release-snapshot: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: coursier/cache-action@v6 + - uses: coursier/setup-action@v1.2.0-M3 + apps: sbt + + - name: publish snapshot + run: sbt ci-release diff --git a/importer/src/test/scala/org/scalablytyped/converter/internal/importer/ImporterHarness.scala b/importer/src/test/scala/org/scalablytyped/converter/internal/importer/ImporterHarness.scala index 9509243f73..5e0de98084 100644 --- a/importer/src/test/scala/org/scalablytyped/converter/internal/importer/ImporterHarness.scala +++ b/importer/src/test/scala/org/scalablytyped/converter/internal/importer/ImporterHarness.scala @@ -26,7 +26,7 @@ private object GitLock sealed trait Mode object Mode { - val isCi = sys.env.contains("CIRCLECI") + val isCi = sys.env.contains("CI") val isRelease = sys.env.contains("CI_COMMIT_TAG") val isLocalhost = !isCi def releaseOnly = if (isLocalhost || isRelease) RunDontStore else Skip @@ -39,7 +39,14 @@ object Mode { } trait ImporterHarness extends AnyFunSuite { - val baseDir = constants.defaultCacheFolder / 'tests + val baseDir = sys.env.get("CI_TEST_CACHE") match { + case Some(value) if value.startsWith("/") || value.contains(":") => + os.Path(value) + case Some(value) => + os.pwd / os.RelPath(value) + case None => + constants.defaultCacheFolder / 'tests + } val failureCacheDir = baseDir / 'compileFailures os.makeDir.all(failureCacheDir)