Skip to content

Commit af252f3

Browse files
authored
decouple code generator from sbt, add support for repeatable migrations, drop Scala 2 support
- release code generator as native binary with a command line interface that can be used with any build tool or standalone - add support for repeatable migrations (#22) - drop Scala 2 support
1 parent 15be8b1 commit af252f3

File tree

32 files changed

+1560
-1652
lines changed

32 files changed

+1560
-1652
lines changed

.git-blame-ignore-revs

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 53 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,55 +8,60 @@ concurrency:
88
group: ${{ github.workflow }} @ ${{ github.ref }}
99
cancel-in-progress: true
1010
jobs:
11+
build:
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, macos-15]
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: coursier/cache-action@v6
19+
- uses: VirtusLab/scala-cli-setup@main
20+
with:
21+
jvm: temurin:21
22+
- name: Install libpq (macOS)
23+
if: runner.os == 'macOS'
24+
run: brew install libpq && brew link --force libpq
25+
- run: |
26+
OUT=out/skunk-codegen-$(uname -m)-$(uname | tr '[:upper:]' '[:lower:]')
27+
echo "Compiling to $OUT"
28+
scala-cli --power package \
29+
--native \
30+
--native-mode release-fast PgCodeGen.scala \
31+
-o $OUT -f && \
32+
zip -j "${OUT}.zip" $OUT
33+
- name: Upload command line binaries
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: codegen-bin-${{ matrix.os }}
37+
path: out/*
1138
test:
1239
runs-on: ubuntu-latest
1340
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v4
16-
- name: Setup JDK
17-
uses: actions/setup-java@v4
18-
with:
19-
distribution: temurin
20-
java-version: 21
21-
cache: sbt
22-
- name: Start up Postgres
23-
run: docker run --rm -d -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:16-alpine
24-
- name: Generate code
25-
run: sbt '+core/Test/runMain com.anymindgroup.RunPgCodeGen'
26-
- name: Test generated code
27-
run: sbt '++2.13 Test/runMain com.anymindgroup.GeneratedCodeTest; ++3.3 Test/runMain com.anymindgroup.GeneratedCodeTest'
28-
- name: Test sbt plugin
29-
# for sbt < v2 which only supports scala 2.12
30-
run: sbt ++2.12 scripted
31-
release:
32-
name: Release
33-
runs-on: ubuntu-latest
34-
continue-on-error: false
35-
needs:
36-
- test
37-
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
41+
- uses: actions/checkout@v2
42+
- uses: coursier/cache-action@v6
43+
- uses: VirtusLab/scala-cli-setup@main
44+
with:
45+
jvm: temurin:21
46+
- run: ./test.sh
47+
48+
publish-bin:
49+
name: Publish command line binaries
50+
needs: [build]
51+
if: startsWith(github.ref, 'refs/tags/')
52+
strategy:
53+
matrix:
54+
os: [ubuntu-latest]
55+
runs-on: ${{ matrix.os }}
3856
steps:
39-
- name: Git Checkout
40-
uses: actions/checkout@v4
41-
- name: Setup JDK
42-
uses: actions/setup-java@v4
43-
with:
44-
distribution: temurin
45-
java-version: 21
46-
cache: sbt
47-
- name: Import signing key and strip passphrase
48-
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != ''
49-
env:
50-
PGP_SECRET: ${{ secrets.PGP_SECRET }}
51-
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
52-
run: |
53-
echo "$PGP_SECRET" | base64 -d -i - > /tmp/signing-key.gpg
54-
echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg
55-
(echo "$PGP_PASSPHRASE"; echo; echo) | gpg --command-fd 0 --pinentry-mode loopback --change-passphrase $(gpg --list-secret-keys --with-colons 2> /dev/null | grep '^sec:' | cut --delimiter ':' --fields 5 | tail -n 1)
56-
- name: Release
57-
run: sbt '++2.12 publishSigned; sonatypeCentralRelease'
58-
env:
59-
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
60-
PGP_SECRET: ${{ secrets.PGP_SECRET }}
61-
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
62-
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
57+
- name: Download command line binaries
58+
uses: actions/download-artifact@v4
59+
with:
60+
pattern: codegen-bin-*
61+
path: out
62+
merge-multiple: true
63+
64+
- name: Upload release binaries
65+
uses: softprops/action-gh-release@v1
66+
with:
67+
files: out/*

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ target/
1515
.vscode/
1616
.bloop/
1717
metals.sbt
18-
modules/core/src/test/scala-*/com/anymindgroup/generated/
19-
modules/core/src/test/scala-*/com/anymindgroup/GeneratedCodeTest.scala
18+
test-generated
19+
.scala-build/
20+
out

.scalafmt.conf

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,7 @@
1-
version = "3.7.7"
1+
version = "3.9.7"
22
maxColumn = 120
3-
align.preset = most
4-
align.multiline = false
5-
continuationIndent.defnSite = 2
6-
assumeStandardLibraryStripMargin = true
7-
docstrings.style = Asterisk
8-
docstrings.wrapMaxColumn = 80
9-
lineEndings = preserve
10-
trailingCommas = multiple
11-
includeCurlyBraceInSelectChains = false
12-
danglingParentheses.preset = true
13-
optIn.annotationNewlines = true
14-
newlines.alwaysBeforeMultilineDef = false
153
runner.dialect = scala3
16-
rewrite.rules = [RedundantBraces]
17-
indentOperator.exemptScope = aloneArgOrBody
18-
indentOperator.excludeRegex = "^(&&|\\|\\|)$"
19-
project.excludeFilters = []
20-
21-
rewrite.redundantBraces.generalExpressions = false
22-
rewriteTokens = {
23-
"⇒": "=>"
24-
"→": "->"
25-
"←": "<-"
26-
}
4+
rewrite.rules = [Imports]
5+
rewrite.imports.sort = scalastyle
6+
rewrite.imports.expand = false
7+
rewrite.imports.groups = [["scala\\..*"], ["java\\..*"]]

0 commit comments

Comments
 (0)