diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..d5542c93 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,44 @@ +name: Continuous Integration + +on: + push: + branches: ['master'] + pull_request: + branches: ['*'] +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build: + name: Build and Test + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.12.12, 2.13.3] + java: [adopt@1.8] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Java and Scala + uses: olafurpg/setup-scala@v10 + with: + java-version: ${{ matrix.java }} + + - name: Cache sbt + uses: actions/cache@v2 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache/v1 + ~/.cache/coursier/v1 + ~/AppData/Local/Coursier/Cache/v1 + ~/Library/Caches/Coursier/v1 + key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + + - name: Build project + run: sbt ++${{ matrix.scala }} test diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml new file mode 100644 index 00000000..00208a14 --- /dev/null +++ b/.github/workflows/clean.yml @@ -0,0 +1,52 @@ +name: Clean + +on: push + +jobs: + delete-artifacts: + name: Delete Artifacts + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Delete artifacts + run: | + # Customize those three lines with your repository and credentials: + REPO=${GITHUB_API_URL}/repos/${{ github.repository }} + + # A shortcut to call GitHub API. + ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; } + + # A temporary file which receives HTTP response headers. + TMPFILE=/tmp/tmp.$$ + + # An associative array, key: artifact name, value: number of artifacts of that name. + declare -A ARTCOUNT + + # Process all artifacts on this repository, loop on returned "pages". + URL=$REPO/actions/artifacts + while [[ -n "$URL" ]]; do + + # Get current page, get response headers in a temporary file. + JSON=$(ghapi --dump-header $TMPFILE "$URL") + + # Get URL of next page. Will be empty if we are at the last page. + URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*.*//') + rm -f $TMPFILE + + # Number of artifacts on this page: + COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') )) + + # Loop on all artifacts on this page. + for ((i=0; $i < $COUNT; i++)); do + + # Get name of artifact and count instances of this name. + name=$(jq <<<$JSON -r ".artifacts[$i].name?") + ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1)) + + id=$(jq <<<$JSON -r ".artifacts[$i].id?") + size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") )) + printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size + ghapi -X DELETE $REPO/actions/artifacts/$id + done + done diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6bfe70d5..00000000 --- a/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -sudo: false -language: scala -scala: - - 2.12.12 - - 2.13.3 - -jdk: openjdk8 - -cache: - directories: - - "$HOME/.m2/repository" - - "$HOME/.sbt" - - "$HOME/.ivy2" - -before_cache: -- find $HOME/.sbt -name "*.lock" | xargs rm -- find $HOME/.ivy2 -name "ivydata-*.properties" | xargs rm -- rm -f $HOME/.ivy2/.sbt.ivy.lock - -script: sbt ";++2.12.12 publishLocal; ++$TRAVIS_SCALA_VERSION test" - -notifications: - email: - recipients: - - "mrzeznicki@iterato.rs" - on_success: change - on_failure: always - on_error: always - on_start: never - on_cancel: never - diff --git a/build.sbt b/build.sbt index fe66c4ba..f2b31735 100644 --- a/build.sbt +++ b/build.sbt @@ -3,12 +3,14 @@ val scala_2_13 = "2.13.3" val mainScalaVersion = scala_2_13 val supportedScalaVersions = Seq(scala_2_12, scala_2_13) +ThisBuild / crossScalaVersions := supportedScalaVersions +ThisBuild / scalaVersion := mainScalaVersion + lazy val baseSettings = Seq( organization := "pl.iterators", organizationName := "Iterators", organizationHomepage := Some(url("https://iterato.rs")), homepage := Some(url("https://github.com/theiterators/kebs")), - scalaVersion := mainScalaVersion, scalacOptions := Seq("-deprecation", "-unchecked", "-feature", "-encoding", "utf8"), scalafmtVersion := "1.3.0", scalafmtOnCompile := true