Skip to content

Commit 0ec7555

Browse files
committed
Run tests and build on GitHub Actions
1 parent a5d4174 commit 0ec7555

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed

.github/workflows/ci.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- '*'
6+
tags:
7+
- 'v*'
8+
pull_request:
9+
branches:
10+
- main
11+
jobs:
12+
test:
13+
runs-on: blacksmith-2vcpu-ubuntu-2204
14+
env:
15+
ENABLE_ASSERTIONS: 1
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
persist-credentials: false
20+
- name: Coursier cache
21+
uses: useblacksmith/coursier-cache-action@v6
22+
- uses: coursier/setup-action@v1
23+
with:
24+
jvm: zulu:11.0.10
25+
apps: sbt scala
26+
- name: dynver check
27+
run: sbt dynverAssertVersion
28+
- name: Scalafmt
29+
run: sbt scalafmtCheck test:scalafmtCheck
30+
- name: Test
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
run: sbt coverage test coverageReport
34+
- name: Upload coverage
35+
uses: codecov/codecov-action@v5
36+
if: ${{ github.actor != 'dependabot[bot]' }}
37+
with:
38+
token: ${{ secrets.CODECOV_TOKEN }}
39+
fail_ci_if_error: true
40+
- name: Clean up
41+
run: |
42+
rm -rf "$HOME/.ivy2/local" || true
43+
find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true
44+
find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true
45+
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
46+
find $HOME/.sbt -name "*.lock" -delete || true
47+
48+
assemble:
49+
needs: [test]
50+
runs-on: blacksmith-2vcpu-ubuntu-2204
51+
permissions:
52+
id-token: write
53+
attestations: write
54+
contents: read
55+
steps:
56+
- uses: actions/checkout@v4
57+
with:
58+
persist-credentials: false
59+
- name: Coursier cache
60+
uses: useblacksmith/coursier-cache-action@v6
61+
- uses: taiki-e/install-action@parse-changelog
62+
- name: Set build timestamp
63+
run: echo "SOURCE_DATE_EPOCH=$(date -d $(parse-changelog CHANGELOG.md -t | rev | cut -d' ' -f1 | rev) '+%s')" >> "$GITHUB_ENV"
64+
- uses: coursier/setup-action@v1
65+
with:
66+
jvm: zulu:11.0.10
67+
apps: sbt scala
68+
- name: Assemble
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: sbt assembly
72+
- name: Upload JAR
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: jsonoid-server.jar
76+
if-no-files-found: error
77+
path: target/scala-2.13/jsonoid-server*.jar
78+
- name: Attest build provenance
79+
uses: actions/attest-build-provenance@v2
80+
if: ${{ github.event_name != 'pull_request' }}
81+
with:
82+
subject-path: 'target/scala-2.13/jsonoid-server*.jar'

build.sbt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,17 @@ lazy val root = (project in file("."))
5757
)
5858

5959
enablePlugins(PlayScala)
60+
61+
ThisBuild / assemblyShadeRules := Seq(
62+
ShadeRule.rename("org.apache.commons.logging.**" -> "shadelogging.@1").inAll
63+
)
64+
65+
assembly / assemblyMergeStrategy := {
66+
case "module-info.class" => MergeStrategy.discard
67+
case "META-INF/versions/9/module-info.class" => MergeStrategy.discard
68+
case PathList("shadelogging", xs @ _*) => MergeStrategy.discard
69+
case "play/reference-overrides.conf" => MergeStrategy.concat
70+
case x =>
71+
val oldStrategy = (assembly / assemblyMergeStrategy).value
72+
oldStrategy(x)
73+
}

conf/application.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,10 @@
22
play.filters.hosts {
33
allowed = ["."]
44
}
5+
6+
## Secret key
7+
# http://www.playframework.com/documentation/latest/ApplicationSecret
8+
# ~~~~~
9+
# The secret key is used to sign Play's session cookie.
10+
# This must be changed for production, but we don't recommend you change it in this file.
11+
play.http.secret.key=${?APPLICATION_SECRET}

project/plugins.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.14.2")
2+
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.3.1")
23
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.13.1")
34
addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.1.0")
45
addSbtPlugin("com.github.sbt" % "sbt-git" % "2.1.0")

0 commit comments

Comments
 (0)