Skip to content

Commit 50d9e43

Browse files
committed
Initial commit
0 parents  commit 50d9e43

File tree

12 files changed

+680
-0
lines changed

12 files changed

+680
-0
lines changed

.github/workflows/ci.yml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# This file was automatically generated by sbt-github-actions using the
2+
# githubWorkflowGenerate task. You should add and commit this file to
3+
# your git repository. It goes without saying that you shouldn't edit
4+
# this file by hand! Instead, if you wish to make changes, you should
5+
# change your sbt build configuration to revise the workflow description
6+
# to meet your needs, then regenerate this file.
7+
8+
name: Continuous Integration
9+
10+
on:
11+
pull_request:
12+
branches: ['**', '!update/**', '!pr/**']
13+
push:
14+
branches: ['**', '!update/**', '!pr/**']
15+
tags: [v*]
16+
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
20+
21+
concurrency:
22+
group: ${{ github.workflow }} @ ${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
build:
27+
name: Test
28+
strategy:
29+
matrix:
30+
os: [ubuntu-22.04]
31+
scala: [2.12]
32+
java: [temurin@8]
33+
runs-on: ${{ matrix.os }}
34+
timeout-minutes: 60
35+
steps:
36+
- name: Checkout current branch (full)
37+
uses: actions/checkout@v4
38+
with:
39+
fetch-depth: 0
40+
41+
- name: Setup sbt
42+
uses: sbt/setup-sbt@v1
43+
44+
- name: Setup Java (temurin@8)
45+
id: setup-java-temurin-8
46+
if: matrix.java == 'temurin@8'
47+
uses: actions/setup-java@v4
48+
with:
49+
distribution: temurin
50+
java-version: 8
51+
cache: sbt
52+
53+
- name: sbt update
54+
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
55+
run: sbt +update
56+
57+
- name: Check that workflows are up to date
58+
run: sbt githubWorkflowCheck
59+
60+
- name: Check headers and formatting
61+
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-22.04'
62+
run: sbt '++ ${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck
63+
64+
- name: Test
65+
run: sbt '++ ${{ matrix.scala }}' test
66+
67+
- id: scripted-test
68+
run: sbt '++ ${{ matrix.scala }}' scripted
69+
70+
- name: Check binary compatibility
71+
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-22.04'
72+
run: sbt '++ ${{ matrix.scala }}' mimaReportBinaryIssues
73+
74+
- name: Generate API documentation
75+
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-22.04'
76+
run: sbt '++ ${{ matrix.scala }}' doc
77+
78+
- name: Make target directories
79+
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
80+
run: mkdir -p sbtPlugin/target project/target
81+
82+
- name: Compress target directories
83+
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
84+
run: tar cf targets.tar sbtPlugin/target project/target
85+
86+
- name: Upload target directories
87+
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}
91+
path: targets.tar
92+
93+
publish:
94+
name: Publish Artifacts
95+
needs: [build]
96+
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
97+
strategy:
98+
matrix:
99+
os: [ubuntu-22.04]
100+
java: [temurin@8]
101+
runs-on: ${{ matrix.os }}
102+
steps:
103+
- name: Checkout current branch (full)
104+
uses: actions/checkout@v4
105+
with:
106+
fetch-depth: 0
107+
108+
- name: Setup sbt
109+
uses: sbt/setup-sbt@v1
110+
111+
- name: Setup Java (temurin@8)
112+
id: setup-java-temurin-8
113+
if: matrix.java == 'temurin@8'
114+
uses: actions/setup-java@v4
115+
with:
116+
distribution: temurin
117+
java-version: 8
118+
cache: sbt
119+
120+
- name: sbt update
121+
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
122+
run: sbt +update
123+
124+
- name: Download target directories (2.12)
125+
uses: actions/download-artifact@v4
126+
with:
127+
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12
128+
129+
- name: Inflate target directories (2.12)
130+
run: |
131+
tar xf targets.tar
132+
rm targets.tar
133+
134+
- name: Import signing key
135+
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
136+
env:
137+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
138+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
139+
run: echo $PGP_SECRET | base64 -d -i - | gpg --import
140+
141+
- name: Import signing key and strip passphrase
142+
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != ''
143+
env:
144+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
145+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
146+
run: |
147+
echo "$PGP_SECRET" | base64 -d -i - > /tmp/signing-key.gpg
148+
echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg
149+
(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)
150+
151+
- name: Publish
152+
env:
153+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
154+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
155+
SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }}
156+
run: sbt tlCiRelease

.github/workflows/clean.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# This file was automatically generated by sbt-github-actions using the
2+
# githubWorkflowGenerate task. You should add and commit this file to
3+
# your git repository. It goes without saying that you shouldn't edit
4+
# this file by hand! Instead, if you wish to make changes, you should
5+
# change your sbt build configuration to revise the workflow description
6+
# to meet your needs, then regenerate this file.
7+
8+
name: Clean
9+
10+
on: push
11+
12+
jobs:
13+
delete-artifacts:
14+
name: Delete Artifacts
15+
runs-on: ubuntu-latest
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
steps:
19+
- name: Delete artifacts
20+
run: |
21+
# Customize those three lines with your repository and credentials:
22+
REPO=${GITHUB_API_URL}/repos/${{ github.repository }}
23+
24+
# A shortcut to call GitHub API.
25+
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }
26+
27+
# A temporary file which receives HTTP response headers.
28+
TMPFILE=/tmp/tmp.$$
29+
30+
# An associative array, key: artifact name, value: number of artifacts of that name.
31+
declare -A ARTCOUNT
32+
33+
# Process all artifacts on this repository, loop on returned "pages".
34+
URL=$REPO/actions/artifacts
35+
while [[ -n "$URL" ]]; do
36+
37+
# Get current page, get response headers in a temporary file.
38+
JSON=$(ghapi --dump-header $TMPFILE "$URL")
39+
40+
# Get URL of next page. Will be empty if we are at the last page.
41+
URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//')
42+
rm -f $TMPFILE
43+
44+
# Number of artifacts on this page:
45+
COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') ))
46+
47+
# Loop on all artifacts on this page.
48+
for ((i=0; $i < $COUNT; i++)); do
49+
50+
# Get name of artifact and count instances of this name.
51+
name=$(jq <<<$JSON -r ".artifacts[$i].name?")
52+
ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1))
53+
54+
id=$(jq <<<$JSON -r ".artifacts[$i].id?")
55+
size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") ))
56+
printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size
57+
ghapi -X DELETE $REPO/actions/artifacts/$id
58+
done
59+
done

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.direnv/
2+
.scala-build/
3+
**/target
4+
.bsp/
5+
6+
node_modules/
7+
.smithy.lsp.log
8+
build/smithy
9+
transformed
10+
**/test/**/actual.smithy

.mergify.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This file was automatically generated by sbt-typelevel-mergify using the
2+
# mergifyGenerate task. You should add and commit this file to
3+
# your git repository. It goes without saying that you shouldn't edit
4+
# this file by hand! Instead, if you wish to make changes, you should
5+
# change your sbt build configuration to revise the mergify configuration
6+
# to meet your needs, then regenerate this file.
7+
8+
pull_request_rules:
9+
- name: merge scala-steward's PRs
10+
conditions:
11+
- author=scala-steward
12+
- or:
13+
- body~=labels:.*early-semver-patch
14+
- body~=labels:.*early-semver-minor
15+
- status-success=Test (ubuntu-22.04, 2.12, temurin@8)
16+
actions:
17+
merge: {}
18+
- name: Label sbtPlugin PRs
19+
conditions:
20+
- files~=^sbtPlugin/
21+
actions:
22+
label:
23+
add:
24+
- sbtPlugin
25+
remove: []

.scalafmt.conf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version = 3.9.7
2+
runner.dialect=scala3
3+
4+
runner.dialectOverride.allowSignificantIndentation = false
5+
runner.dialectOverride.allowQuietSyntax = true
6+
7+
maxColumn = 100
8+
align.preset = some
9+
10+
newlines.beforeMultiline = unfold
11+
newlines.topLevelStatements = [before, after]
12+
newlines.topLevelStatementsMinBreaks = 2
13+
newlines.implicitParamListModifierForce = [before]
14+
continuationIndent.defnSite = 2
15+
continuationIndent.extendSite = 2
16+
optIn.breakChainOnFirstMethodDot = true
17+
includeCurlyBraceInSelectChains = true
18+
includeNoParensInSelectChains = true
19+
20+
trailingCommas = "multiple"
21+
22+
rewrite.rules = [
23+
RedundantBraces,
24+
RedundantParens,
25+
ExpandImportSelectors,
26+
PreferCurlyFors
27+
]
28+
29+
runner.optimizer.forceConfigStyleMinArgCount = 3
30+
danglingParentheses.defnSite = true
31+
danglingParentheses.callSite = true
32+
danglingParentheses.exclude = [
33+
"`trait`"
34+
]
35+
verticalMultiline.newlineAfterOpenParen = true
36+
verticalMultiline.atDefnSite = true

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2025 Jakub Kozłowski
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

build.sbt

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
ThisBuild / tlBaseVersion := "0.1"
2+
ThisBuild / organization := "org.polyvariant"
3+
ThisBuild / organizationName := "Polyvariant"
4+
ThisBuild / startYear := Some(2025)
5+
ThisBuild / licenses := Seq(License.Apache2)
6+
ThisBuild / developers := List(tlGitHubDev("kubukoz", "Jakub Kozłowski"))
7+
8+
ThisBuild / githubWorkflowPublishTargetBranches := Seq(
9+
RefPredicate.Equals(Ref.Branch("main")),
10+
RefPredicate.StartsWith(Ref.Tag("v")),
11+
)
12+
13+
ThisBuild / scalaVersion := "2.12.20"
14+
ThisBuild / tlJdkRelease := Some(8)
15+
ThisBuild / tlFatalWarnings := false
16+
ThisBuild / tlCiDependencyGraphJob := false
17+
ThisBuild / resolvers ++= Resolver.sonatypeOssRepos("snapshots")
18+
19+
ThisBuild / mergifyStewardConfig ~= (_.map(_.withMergeMinors(true)))
20+
21+
ThisBuild / githubWorkflowBuild ~= {
22+
_.flatMap {
23+
case step if step.name == Some("Test") =>
24+
step ::
25+
WorkflowStep.Sbt(commands = List("scripted"), id = Some("scripted-test")) ::
26+
Nil
27+
case other => other :: Nil
28+
}
29+
}
30+
31+
val commonSettings = Seq(
32+
libraryDependencies ++= Seq(
33+
"org.typelevel" %%% "weaver-cats" % "0.9.0" % Test
34+
)
35+
)
36+
37+
lazy val sbtPlugin = project
38+
.settings(
39+
name := "smithy-trait-codegen-sbt",
40+
commonSettings,
41+
scalaVersion := "2.12.20",
42+
libraryDependencies ++= Seq(
43+
"software.amazon.smithy" % "smithy-trait-codegen" % "1.59.0",
44+
"software.amazon.smithy" % "smithy-model" % "1.59.0",
45+
) ++ Seq(
46+
"com.lihaoyi" %% "os-lib" % "0.10.7"
47+
),
48+
pluginCrossBuild / sbtVersion := {
49+
scalaBinaryVersion.value match {
50+
case "2.12" => "1.9.8"
51+
}
52+
},
53+
scriptedLaunchOpts :=
54+
scriptedLaunchOpts.value ++
55+
Seq("-Xmx1024M", "-Dplugin.version=" + version.value),
56+
scriptedBufferLog := false,
57+
)
58+
.enablePlugins(SbtPlugin)
59+
60+
lazy val root = project
61+
.in(file("."))
62+
.aggregate(sbtPlugin)
63+
.enablePlugins(NoPublishPlugin)

project/build.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.11.2

project/plugins.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.8.0")
2+
addSbtPlugin("org.typelevel" % "sbt-typelevel-mergify" % "0.8.0")

0 commit comments

Comments
 (0)