From 1c7237fe1519365cdb3661164b391847048f8518 Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Fri, 14 Nov 2025 17:58:28 +0100 Subject: [PATCH 1/4] Use sbt-github-actions --- .github/workflows/ci.yml | 131 ++++++++++++++++++++++++++---------- .github/workflows/clean.yml | 63 +++++++++++++++++ build.sbt | 25 ++++++- project/plugins.sbt | 3 +- 4 files changed, 182 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/clean.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2d557408..86bcb6ccd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,60 +1,117 @@ -name: CI +# This file was automatically generated by sbt-github-actions using the +# githubWorkflowGenerate task. You should add and commit this file to +# your git repository. It goes without saying that you shouldn't edit +# this file by hand! Instead, if you wish to make changes, you should +# change your sbt build configuration to revise the workflow description +# to meet your needs, then regenerate this file. -env: - JAVA_OPTS: "-Dfile.encoding=UTF-8 -Xms1024M -Xmx3072M -Xss4M" +name: Continuous Integration on: - push: - branches: '**' - tags: [ "v[0-9]+*" ] pull_request: - # avoid duplicate checks (push & PR) further in the review process - types: [opened] + branches: ['**'] + push: + branches: ['**'] + tags: [v*] + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: - test: - name: Run tests - runs-on: ubuntu-22.04 # https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md + build: + name: Build and Test strategy: - fail-fast: false matrix: - scala: [ 2.13.16 ] - java-version: [ 17, 21, 25 ] - command: [ udash-jvm/test, udash-js/test, guide-selenium/test ] + os: [ubuntu-latest] + scala: [2.13.16] + java: [temurin@17, temurin@21, temurin@25] + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v4 + - name: Checkout current branch (full) + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Setup Java (temurin@17) + if: matrix.java == 'temurin@17' + uses: actions/setup-java@v5 with: distribution: temurin - java-version: ${{ matrix.java-version }} + java-version: 17 cache: sbt - - uses: actions/setup-node@v4 + + - name: Setup Java (temurin@21) + if: matrix.java == 'temurin@21' + uses: actions/setup-java@v5 with: - cache: npm - - name: Install npm dependencies - run: npm install - - name: Run tests - run: sbt ++${{ matrix.scala }} ${{ matrix.command }} + distribution: temurin + java-version: 21 + cache: sbt + + - name: Setup Java (temurin@25) + if: matrix.java == 'temurin@25' + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: 25 + cache: sbt + + - name: Setup sbt + uses: sbt/setup-sbt@v1 + + - name: Setup Node.js + uses: actions/setup-node@v4 + + - name: Check that workflows are up to date + run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck + + - name: Build project + run: sbt '++ ${{ matrix.scala }}' test publish: - name: Publish to Sonatype - # only run on tag push - if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v')) - needs: [ test ] - runs-on: ubuntu-22.04 + name: Publish Artifacts + needs: [build] + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v')) + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.13.16] + java: [temurin@17] + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 + - name: Checkout current branch (full) + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Setup Java (temurin@17) + if: matrix.java == 'temurin@17' + uses: actions/setup-java@v5 with: distribution: temurin java-version: 17 cache: sbt - - name: Get version - id: get_tag_name - run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT - - name: Publish artifacts - env: + + - name: Setup Java (temurin@21) + if: matrix.java == 'temurin@21' + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: 21 + cache: sbt + + - name: Setup Java (temurin@25) + if: matrix.java == 'temurin@25' + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: 25 + cache: sbt + + - name: Setup sbt + uses: sbt/setup-sbt@v1 + + - env: PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} PGP_SECRET: ${{ secrets.PGP_SECRET }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml new file mode 100644 index 000000000..4bb28c89d --- /dev/null +++ b/.github/workflows/clean.yml @@ -0,0 +1,63 @@ +# This file was automatically generated by sbt-github-actions using the +# githubWorkflowGenerate task. You should add and commit this file to +# your git repository. It goes without saying that you shouldn't edit +# this file by hand! Instead, if you wish to make changes, you should +# change your sbt build configuration to revise the workflow description +# to meet your needs, then regenerate this file. + +name: Clean + +on: push + +permissions: + actions: write + +jobs: + delete-artifacts: + name: Delete Artifacts + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Delete artifacts + shell: bash {0} + 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=$(mktemp) + + # 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/build.sbt b/build.sbt index 73031d0bc..daf542a7c 100644 --- a/build.sbt +++ b/build.sbt @@ -22,6 +22,29 @@ inThisBuild(Seq( developers := List( Developer("ddworak", "Dawid Dworak", "d.dworak@avsystem.com", url("https://github.com/ddworak")), ), + scalaVersion := Dependencies.versionOfScala, + + + githubWorkflowTargetTags ++= Seq("v*"), + + githubWorkflowArtifactUpload := false, + githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17"), JavaSpec.temurin("21"), JavaSpec.temurin("25")), + githubWorkflowBuildPreamble += WorkflowStep.Use( + UseRef.Public("actions", "setup-node", "v4"), + name = Some("Setup Node.js"), + ), + + githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))), + + githubWorkflowPublish := Seq(WorkflowStep.Sbt( + List("ci-release"), + env = Map( + "PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}", + "PGP_SECRET" -> "${{ secrets.PGP_SECRET }}", + "SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}", + "SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}" + ) + )), )) val forIdeaImport = System.getProperty("idea.managed", "false").toBoolean && System.getProperty("idea.runid") == null @@ -34,8 +57,6 @@ val browserCapabilities: Capabilities = { } val commonSettings = Seq( - scalaVersion := Dependencies.versionOfScala, - crossScalaVersions := Seq(Dependencies.versionOfScala), scalacOptions ++= Seq( "-feature", "-deprecation", diff --git a/project/plugins.sbt b/project/plugins.sbt index bc55418e7..4cd030576 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -10,4 +10,5 @@ addSbtPlugin("org.jetbrains.scala" % "sbt-ide-settings" % "1.1.3") addSbtPlugin("com.github.sbt" % "sbt-less" % "2.0.1") addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.11.4") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.11.2") -addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.8") \ No newline at end of file +addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.8") +addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.28.0") \ No newline at end of file From 28e2221044c82ea80b0a73f466aa8ec6b45f8e65 Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Fri, 14 Nov 2025 18:09:46 +0100 Subject: [PATCH 2/4] Add JAVA_OPTS --- .github/workflows/ci.yml | 1 + build.sbt | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86bcb6ccd..d4e64befc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ on: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + JAVA_OPTS: '-Dfile.encoding=UTF-8 -Xmx4G' jobs: build: diff --git a/build.sbt b/build.sbt index daf542a7c..d7279b181 100644 --- a/build.sbt +++ b/build.sbt @@ -35,6 +35,7 @@ inThisBuild(Seq( ), githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))), + githubWorkflowEnv += "JAVA_OPTS" -> "-Dfile.encoding=UTF-8 -Xmx4G", githubWorkflowPublish := Seq(WorkflowStep.Sbt( List("ci-release"), From a980a4b84810baed4fa48daffe5c31f786dfcaf3 Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Sun, 16 Nov 2025 16:39:33 +0100 Subject: [PATCH 3/4] Install npm dependencies --- .github/workflows/ci.yml | 3 +++ build.sbt | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d4e64befc..4f26059bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,6 +63,9 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 + - name: Install npm dependencies + run: npm install + - name: Check that workflows are up to date run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck diff --git a/build.sbt b/build.sbt index d7279b181..6ea927455 100644 --- a/build.sbt +++ b/build.sbt @@ -29,9 +29,15 @@ inThisBuild(Seq( githubWorkflowArtifactUpload := false, githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17"), JavaSpec.temurin("21"), JavaSpec.temurin("25")), - githubWorkflowBuildPreamble += WorkflowStep.Use( - UseRef.Public("actions", "setup-node", "v4"), - name = Some("Setup Node.js"), + githubWorkflowBuildPreamble ++= Seq( + WorkflowStep.Use( + ref = UseRef.Public("actions", "setup-node", "v4"), + name = Some("Setup Node.js"), + ), + WorkflowStep.Run( + commands = List("npm install"), + name = Some("Install npm dependencies") + ) ), githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))), From 1b8c0021a76e1beeb192172a433a6d725c19e603 Mon Sep 17 00:00:00 2001 From: Dawid Dworak Date: Sun, 16 Nov 2025 16:57:15 +0100 Subject: [PATCH 4/4] Add udash CI command matrix --- .github/workflows/ci.yml | 6 ++++-- build.sbt | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4f26059bd..8503d8f01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,10 +22,12 @@ jobs: build: name: Build and Test strategy: + fail-fast: false matrix: os: [ubuntu-latest] scala: [2.13.16] java: [temurin@17, temurin@21, temurin@25] + command: [udash-jvm/test, udash-js/test, guide-selenium/test] runs-on: ${{ matrix.os }} steps: - name: Checkout current branch (full) @@ -69,8 +71,8 @@ jobs: - name: Check that workflows are up to date run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck - - name: Build project - run: sbt '++ ${{ matrix.scala }}' test + - name: Run tests + run: sbt '++ ${{ matrix.scala }}' '${{ matrix.command }}' publish: name: Publish Artifacts diff --git a/build.sbt b/build.sbt index 6ea927455..1cd70084f 100644 --- a/build.sbt +++ b/build.sbt @@ -24,9 +24,7 @@ inThisBuild(Seq( ), scalaVersion := Dependencies.versionOfScala, - githubWorkflowTargetTags ++= Seq("v*"), - githubWorkflowArtifactUpload := false, githubWorkflowJavaVersions := Seq(JavaSpec.temurin("17"), JavaSpec.temurin("21"), JavaSpec.temurin("25")), githubWorkflowBuildPreamble ++= Seq( @@ -39,10 +37,14 @@ inThisBuild(Seq( name = Some("Install npm dependencies") ) ), - githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))), githubWorkflowEnv += "JAVA_OPTS" -> "-Dfile.encoding=UTF-8 -Xmx4G", - + githubWorkflowBuildMatrixFailFast := Some(false), + githubWorkflowBuildMatrixAdditions += "command" -> List("udash-jvm/test", "udash-js/test", "guide-selenium/test"), + githubWorkflowBuild := Seq(WorkflowStep.Sbt( + commands = List("${{ matrix.command }}"), + name = Some("Run tests"), + )), githubWorkflowPublish := Seq(WorkflowStep.Sbt( List("ci-release"), env = Map(