From 0624fef01cd1f76b94140c1b318812c30da5d20a Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Wed, 3 Apr 2024 18:41:30 +0200 Subject: [PATCH] . --- .github/workflows/ci.yml | 90 ++++++++++++------- .gitignore | 4 +- .mill-version | 1 + .scalafmt.conf | 3 +- build.sc | 41 +++++++++ justfile | 17 ++-- project.scala | 27 ------ hasher.scala => project/src/hasher.scala | 0 htmlGen.scala => project/src/htmlGen.scala | 0 .../src/live.server.scala | 0 .../test/src/liveServer.test.scala | 0 11 files changed, 112 insertions(+), 71 deletions(-) create mode 100644 .mill-version create mode 100644 build.sc delete mode 100644 project.scala rename hasher.scala => project/src/hasher.scala (100%) rename htmlGen.scala => project/src/htmlGen.scala (100%) rename live.server.scala => project/src/live.server.scala (100%) rename live.server.test.scala => project/test/src/liveServer.test.scala (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a3a99e..556ee84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,42 +1,68 @@ -name: CI +name: Continuous Integration + on: - push: - branches: - - main - tags: - - "v*" pull_request: + branches: ['**', '!update/**', '!pr/**'] + push: + branches: ['**', '!update/**', '!pr/**'] + tags: [v*] -jobs: +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - test: - if: github.event_name == 'push' || github.event_name == 'pull_request' - runs-on: ubuntu-latest + +concurrency: + group: ${{ github.workflow }} @ ${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build and Test + strategy: + matrix: + os: [ubuntu-latest] + scala: [3] + java: [temurin@17] + project: [jvm] + runs-on: ${{ matrix.os }} + timeout-minutes: 60 steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: coursier/cache-action@v6.4 - - uses: VirtusLab/scala-cli-setup@main - - uses: taiki-e/install-action@just - - name: Install Playwright - run: just setupPlaywright - - name: compile - run: just compile - - name: test - run: just test + - name: Checkout current branch (full) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Java (temurin@17) + id: setup-java-temurin-17 + if: matrix.java == 'temurin@17' + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + - name: Test + run: ./mill project.test publish: - needs: test - if: github.event_name == 'push' + if: github.repository == 'Quafadas/live-server-scala-cli-js' && contains(github.ref, 'refs/tags/') + needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: coursier/cache-action@v6.4 - - uses: VirtusLab/scala-cli-setup@main - - - name: Publish - run: scala-cli publish . --power --secret-key value:${{secrets.PUBLISH_SECRET_KEY}} --secret-key-password value:${{secrets.PUBLISH_SECRET_KEY_PASSWORD}} --user value:${{ secrets.PUBLISH_USER }} --password value:${{secrets.PUBLISH_PASSWORD}} \ No newline at end of file + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup GPG secrets + run: | + gpg --version + cat <(echo "${{ secrets.PUBLISH_SECRET_KEY }}") | base64 --decode | gpg --batch --import + gpg --list-secret-keys --keyid-format LONG + + - name: Publish to Maven Central + run: ./mill -i mill.scalalib.PublishModule/publishAll __.publishArtifacts --sonatypeUri https://s01.oss.sonatype.org/service/local --sonatypeCreds "${{ secrets.PUBLISH_USER }}:${{ secrets.PUBLISH_PASSWORD }}" --gpgArgs "--passphrase=${{ secrets.PUBLISH_SECRET_KEY_PASSWORD}},--batch,--yes,-a,-b,--pinentry-mode,loopback" --readTimeout 600000 --awaitTimeout 600000 --release true --signed true diff --git a/.gitignore b/.gitignore index a23a448..a2fc13d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ .bsp .vscode native -testDir \ No newline at end of file +testDir +.bsp +out \ No newline at end of file diff --git a/.mill-version b/.mill-version new file mode 100644 index 0000000..12edb29 --- /dev/null +++ b/.mill-version @@ -0,0 +1 @@ +0.11.7 \ No newline at end of file diff --git a/.scalafmt.conf b/.scalafmt.conf index 436cd48..10ca0d4 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -10,4 +10,5 @@ runner.dialectOverride.withAllowEndMarker = true runner.dialectOverride.allowSignificantIndentation = true rewrite.scala3.countEndMarkerLines = lastBlockOnly rewrite.scala3.insertEndMarkerMinLines = 1 -maxColumn = 120 \ No newline at end of file +maxColumn = 120 +project.excludeFilters = [ ".*/build\\.sc" ] \ No newline at end of file diff --git a/build.sc b/build.sc new file mode 100644 index 0000000..608967a --- /dev/null +++ b/build.sc @@ -0,0 +1,41 @@ +import mill._ +import mill.scalalib._ + +object project extends ScalaModule with PublishModule { + def scalaVersion = "3.4.1" + def ivyDeps = super.ivyDeps() ++ Seq( + ivy"org.http4s::http4s-ember-server::0.23.26", + ivy"org.http4s::http4s-dsl::0.23.26", + ivy"org.http4s::http4s-scalatags::0.25.2", + ivy"io.circe::circe-core::0.14.6", + ivy"io.circe::circe-generic::0.14.6", + ivy"co.fs2::fs2-io::3.10.2", + ivy"com.lihaoyi::scalatags::0.12.0" + ) + + def publishVersion = VcsVersion.vcsState().format() + + object test extends ScalaTests with TestModule.Munit { + def ivyDeps = super.ivyDeps() ++ Seq( + ivy"org.scalameta::munit::1.0.0-M11", + ivy"com.microsoft.playwright:playwright:1.41.1", + ivy"com.microsoft.playwright:driver-bundle:1.41.1", + ) + } + + override def pomSettings = T { + PomSettings( + description = "An experimental live server for scala JS projects", + organization = "io.github.quafadas", + url = "https://github.com/Quafadas/live-server-scala-cli-js", + licenses = Seq(License.`Apache-2.0`), + versionControl = + VersionControl.github("quafadas", "live-server-scala-cli-js"), + developers = Seq( + Developer("quafadas", "Simon Parten", "https://github.com/quafadas") + ) + ) + } + + +} diff --git a/justfile b/justfile index 8d50857..981b5d0 100644 --- a/justfile +++ b/justfile @@ -3,24 +3,21 @@ default: just --list setupIde: - scala-cli setup-ide . --exclude testDir --exclude native - -package: - scala-cli package . + mill mill.bsp.BSP/install compile: - scala-cli compile . --exclude testDir --exclude native --power + mill project.compile test: - scala-cli test . --exclude testDir --exclude native --power - -jvmWatch: - scala-cli run project.scala file.watcher.scala + mill project.test jvmServe: - scala-cli run project.scala live.serverJvm.scala htmlGen.scala file.hasher.scala -- "/Users/simon/Code/helloScalaJs/out" + scala-cli project.run /Users/simon/Code/helloScalaJs /Users/simon/Code/helloScalaJs/out setupPlaywright: cs launch com.microsoft.playwright:playwright:1.41.1 -M "com.microsoft.playwright.CLI" -- install --with-deps +publish: + mill + gha: setupPlaywright test diff --git a/project.scala b/project.scala deleted file mode 100644 index 3a7a095..0000000 --- a/project.scala +++ /dev/null @@ -1,27 +0,0 @@ -//> using scala 3.4.1 -//> using platform jvm - -//> using exclude testDir - -//> using dep org.http4s::http4s-ember-server::0.23.26 -//> using dep org.http4s::http4s-dsl::0.23.26 -//> using dep org.http4s::http4s-scalatags::0.25.2 -//> using dep io.circe::circe-core::0.14.6 -//> using dep io.circe::circe-generic::0.14.6 - -//> using dep co.fs2::fs2-io::3.10.2 -//> using dep com.lihaoyi::scalatags::0.12.0 - -//> using test.dep org.scalameta::munit::1.0.0-M11 -//> using test.dep com.microsoft.playwright:playwright:1.41.1 -//> using test.dep com.microsoft.playwright:driver-bundle:1.41.1 -//> using test.dep com.lihaoyi::os-lib:0.9.3 - -//> using publish.repository central-s01 -//> using publish.organization io.github.quafadas -//> using publish.name "live-server-scala-cli-js" -//> using publish.computeVersion "git:tag" -//> using publish.license "Apache-2.0" -//> using publish.url "https://github.com/quafadas/live-server-scala-cli-js" -//> using publish.versionControl "github:quafadas/live-server-scala-cli-js" -//> using publish.developer "Simon Parten||https://github.com/Quafadas" diff --git a/hasher.scala b/project/src/hasher.scala similarity index 100% rename from hasher.scala rename to project/src/hasher.scala diff --git a/htmlGen.scala b/project/src/htmlGen.scala similarity index 100% rename from htmlGen.scala rename to project/src/htmlGen.scala diff --git a/live.server.scala b/project/src/live.server.scala similarity index 100% rename from live.server.scala rename to project/src/live.server.scala diff --git a/live.server.test.scala b/project/test/src/liveServer.test.scala similarity index 100% rename from live.server.test.scala rename to project/test/src/liveServer.test.scala