From af0d75515de85abd4ccf11eeea3d5119baf69d4a Mon Sep 17 00:00:00 2001 From: Matthias Kurz Date: Fri, 6 May 2022 16:18:23 +0200 Subject: [PATCH 1/4] Update badge in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8ca3ca60..c042012a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Anorm +[![Build Status](https://github.com/playframework/anorm/actions/workflows/build-test.yml/badge.svg)](https://github.com/playframework/anorm/actions/workflows/build-test.yml) + Anorm is a simple data access layer that uses plain SQL to interact with the database and provides an API to parse and transform the resulting datasets. - [User guide](https://playframework.github.io/anorm/) @@ -24,8 +26,6 @@ To run the tests, use: sbt test -[CircleCI](https://circleci.com/gh/playframework/anorm): ![CircleCI build status](https://circleci.com/gh/playframework/anorm.png?branch=main) - ## Documentation To run the documentation server, run: From a0b231da8ce09bcb8403ef10a28d6297c0f93449 Mon Sep 17 00:00:00 2001 From: Matthias Kurz Date: Fri, 6 May 2022 17:40:25 +0200 Subject: [PATCH 2/4] Switch to GitHub actions --- .ci_scripts/jvmopts.sh | 14 --- .ci_scripts/validate.sh | 24 ----- .circleci/config.yml | 156 ------------------------------- .github/workflows/build-test.yml | 46 +++++++++ .github/workflows/publish.yml | 17 ++++ bin/travis | 10 -- build.sbt | 8 ++ 7 files changed, 71 insertions(+), 204 deletions(-) delete mode 100644 .ci_scripts/jvmopts.sh delete mode 100755 .ci_scripts/validate.sh delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/build-test.yml create mode 100644 .github/workflows/publish.yml delete mode 100755 bin/travis diff --git a/.ci_scripts/jvmopts.sh b/.ci_scripts/jvmopts.sh deleted file mode 100644 index 192b72b1..00000000 --- a/.ci_scripts/jvmopts.sh +++ /dev/null @@ -1,14 +0,0 @@ -JVM_MAX_MEM="1G" - -JAVA_MAJOR=`java -version 2>&1 | head -n 1 | cut -d '"' -f 2 | sed -e 's/\.[0-9a-zA-Z_]*$//'` - -if [ "v$JAVA_MAJOR" = "v10.0" -o "v$JAVA_MAJOR" = "v11.0" ]; then - JVM_OPTS="-XX:+UseContainerSupport -XX:MaxRAMPercentage=70" -else - JVM_MAX_MEM="1632M" # 1760M" - JVM_OPTS="-Xmx$JVM_MAX_MEM -XX:ReservedCodeCacheSize=192m" -fi - -#JVM_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap" - -export _JAVA_OPTIONS="$JVM_OPTS" diff --git a/.ci_scripts/validate.sh b/.ci_scripts/validate.sh deleted file mode 100755 index 53e44fa6..00000000 --- a/.ci_scripts/validate.sh +++ /dev/null @@ -1,24 +0,0 @@ -#! /bin/bash - -set -e - -SCRIPT_DIR=`dirname $0 | sed -e "s|^\./|$PWD/|"` - -source "$SCRIPT_DIR/jvmopts.sh" - -sbt ++$SCALA_VERSION scalariformFormat test:scalariformFormat > /dev/null #scalafixAll -git diff --exit-code || (cat >> /dev/stdout <>/sbt-<< parameters.sbt_version >>.tgz - tar -xzvf sbt.tgz && rm -f sbt.tgz - fi - - - save_cache: - paths: - - ~/sbt - key: *sbt_cache_key - - build_n_tests: - description: Build & Run tests - steps: - - restore_cache: - keys: - - &scala_cache_key scala-{{ .Environment.CIRCLE_JOB }}-{{ checksum "version.sbt" }}-{{ checksum "build.sbt" }} - - - run: - name: Build & Run tests - command: | - export PATH=$PATH:~/sbt/bin - - ./.ci_scripts/validate.sh - - - save_cache: - paths: - - ~/.ivy2 - - ~/.coursier/cache - - ~/.sbt - key: *scala_cache_key - - collect_test_reports: - description: Collect test reports - steps: - - run: - name: Collect test report - command: | - mkdir test-reports - find . -path '*/test-reports/*' -name '*.xml' \ - -print -exec cp {} test-reports \; - when: always - -jobs: - scala211_jdk8: - docker: - - image: circleci/openjdk:8-jdk - - working_directory: ~/repo - - environment: - SCALA_VERSION: 2.11.12 - - steps: - - checkout - - setup_sbt - - build_n_tests - - collect_test_reports - - store_test_results: - path: test-reports - - scala212_jdk8: - docker: - - image: circleci/openjdk:8-jdk - - working_directory: ~/repo - - environment: - SCALA_VERSION: 2.12.15 - - steps: - - checkout - - setup_sbt - - build_n_tests - - collect_test_reports - - store_test_results: - path: test-reports - - scala213_jdk8: - docker: - - image: circleci/openjdk:8-jdk - - working_directory: ~/repo - - environment: - SCALA_VERSION: 2.13.8 - - steps: - - checkout - - setup_sbt - - build_n_tests - - collect_test_reports - - store_test_results: - path: test-reports - - scala212_jdk9: - docker: - - image: circleci/openjdk:9-jdk - - working_directory: ~/repo - - environment: - SCALA_VERSION: 2.12.15 - - steps: - - checkout - - setup_sbt - - build_n_tests - - collect_test_reports - - store_test_results: - path: test-reports - - scala213_jdk11: - docker: - - image: circleci/openjdk:11-jdk - - working_directory: ~/repo - - environment: - SCALA_VERSION: 2.13.8 - - steps: - - checkout - - setup_sbt - - build_n_tests - - collect_test_reports - - store_test_results: - path: test-reports - -workflows: - version: 2 - - main_suite: - jobs: - - scala211_jdk8 - - scala212_jdk8 - - scala213_jdk8 - - scala212_jdk9 - - scala213_jdk11 diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 00000000..478af0e2 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,46 @@ +name: Check + +on: + pull_request: + +concurrency: + # Only run once for latest commit per ref and cancel other (previous) runs. + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + check-code-style: + name: Code Style + uses: playframework/.github/.github/workflows/cmd.yml@v2 + with: + cmd: sbt validateCode + + check-binary-compatibility: + name: Binary Compatibility + uses: playframework/.github/.github/workflows/binary-check.yml@v2 + + check-docs: + name: Docs + uses: playframework/.github/.github/workflows/cmd.yml@v2 + with: + java: 11, 8 + scala: 2.11.12, 2.12.15, 2.13.8 + cmd: sbt ++$MATRIX_SCALA docs/test + + tests: + name: Tests + needs: # Waiting more lightweight checks + - "check-code-style" + - "check-binary-compatibility" + - "check-docs" + uses: playframework/.github/.github/workflows/cmd.yml@v2 + with: + java: 11, 8 + scala: 2.11.12, 2.12.15, 2.13.8 + cmd: sbt ++$MATRIX_SCALA publishLocal test # scapegoat + + finish: + name: Finish + needs: # Should be last + - "tests" + uses: playframework/.github/.github/workflows/rtm.yml@v2 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..14b41c9d --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,17 @@ +name: Publish + +on: + push: + branches: # Snapshots + - main + tags: ["*"] # Releases + +jobs: + publish-artifacts: + name: Publish / Artifacts + uses: playframework/.github/.github/workflows/publish.yml@v2 + secrets: + username: ${{ secrets.SONATYPE_USERNAME }} + password: ${{ secrets.SONATYPE_PASSWORD }} + pgp_passphrase: ${{ secrets.PGP_PASSPHRASE }} + pgp_secret: ${{ secrets.PGP_SECRET }} diff --git a/bin/travis b/bin/travis deleted file mode 100755 index 9a4abc33..00000000 --- a/bin/travis +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/bash - -set -ev - -if [ `echo "$TRAVIS_SCALA_VERSION" | grep '^2\.12\.' | wc -l` -eq 1 ]; then - # TODO: Remove when everything is ok for 2.12 - sbt ++$TRAVIS_SCALA_VERSION mimaReportBinaryIssues test -else - sbt ++$TRAVIS_SCALA_VERSION mimaReportBinaryIssues test docs/test -fi diff --git a/build.sbt b/build.sbt index dcf33fd4..2d02da5d 100644 --- a/build.sbt +++ b/build.sbt @@ -303,3 +303,11 @@ lazy val docs = project Scapegoat.settings ThisBuild / playBuildRepoName := "anorm" + +addCommandAlias( + "validateCode", + List( + "scalafmtSbtCheck", + "scalafmtCheckAll", + ).mkString(";") +) From 70990b3d805bd543879f274e0dfb188e59851307 Mon Sep 17 00:00:00 2001 From: Sergey Morgunov Date: Fri, 13 May 2022 15:13:10 +0300 Subject: [PATCH 3/4] Use secrets inherit for publish workflow --- .github/workflows/publish.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 14b41c9d..79951079 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,8 +10,4 @@ jobs: publish-artifacts: name: Publish / Artifacts uses: playframework/.github/.github/workflows/publish.yml@v2 - secrets: - username: ${{ secrets.SONATYPE_USERNAME }} - password: ${{ secrets.SONATYPE_PASSWORD }} - pgp_passphrase: ${{ secrets.PGP_PASSPHRASE }} - pgp_secret: ${{ secrets.PGP_SECRET }} + secrets: inherit From b78e1faf501c7e91f1465de408967fc490588640 Mon Sep 17 00:00:00 2001 From: Sergey Morgunov Date: Fri, 13 May 2022 15:43:16 +0300 Subject: [PATCH 4/4] Fix test compile --- core/src/test/scala/anorm/AnormSpec.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/test/scala/anorm/AnormSpec.scala b/core/src/test/scala/anorm/AnormSpec.scala index 08f7aee0..d3dee46b 100644 --- a/core/src/test/scala/anorm/AnormSpec.scala +++ b/core/src/test/scala/anorm/AnormSpec.scala @@ -285,9 +285,9 @@ final class AnormSpec extends Specification with H2Database with AnormTest { ) { implicit c => SQL("SELECT * FROM test") - .as((SqlParser.int("id") ~ SqlParser.str("val").?).map({ case id ~ v => + .as((SqlParser.int("id") ~ SqlParser.str("val").?).map { case id ~ v => (id -> v) - } *)) + } *) .aka("parsed list") must_=== List(9 -> None, 2 -> Some("str")) }