Skip to content

Commit 5b800f4

Browse files
DavidGregory084David Gregory
authored andcommitted
Typelevel Migration II: return of the Typelevel migration
1 parent 8b739d8 commit 5b800f4

File tree

7 files changed

+244
-75
lines changed

7 files changed

+244
-75
lines changed

.github/workflows/ci.yml

Lines changed: 156 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,166 @@
1-
name: CI
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
29

310
on:
4-
push:
511
pull_request:
12+
branches: ['**', '!update/**', '!pr/**']
13+
push:
14+
branches: ['**', '!update/**', '!pr/**']
15+
tags: [v*]
16+
17+
env:
18+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
19+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
20+
SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }}
21+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
22+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
624

725
jobs:
826
build:
9-
runs-on: ubuntu-latest
10-
27+
name: Build and Test
1128
strategy:
1229
matrix:
13-
java-version: [8, 11, 17]
30+
os: [ubuntu-latest]
31+
scala: [2.12.18]
32+
java: [temurin@8]
33+
runs-on: ${{ matrix.os }}
34+
steps:
35+
- name: Checkout current branch (full)
36+
uses: actions/checkout@v3
37+
with:
38+
fetch-depth: 0
39+
40+
- name: Download Java (temurin@8)
41+
id: download-java-temurin-8
42+
if: matrix.java == 'temurin@8'
43+
uses: typelevel/download-java@v2
44+
with:
45+
distribution: temurin
46+
java-version: 8
47+
48+
- name: Setup Java (temurin@8)
49+
if: matrix.java == 'temurin@8'
50+
uses: actions/setup-java@v3
51+
with:
52+
distribution: jdkfile
53+
java-version: 8
54+
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}
55+
56+
- name: Cache sbt
57+
uses: actions/cache@v3
58+
with:
59+
path: |
60+
~/.sbt
61+
~/.ivy2/cache
62+
~/.coursier/cache/v1
63+
~/.cache/coursier/v1
64+
~/AppData/Local/Coursier/Cache/v1
65+
~/Library/Caches/Coursier/v1
66+
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
67+
68+
- name: Check that workflows are up to date
69+
run: sbt githubWorkflowCheck
70+
71+
- name: Check headers and formatting
72+
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
73+
run: sbt '++ ${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck
74+
75+
- name: Test
76+
run: sbt '++ ${{ matrix.scala }}' test
77+
78+
- name: Check binary compatibility
79+
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
80+
run: sbt '++ ${{ matrix.scala }}' mimaReportBinaryIssues
81+
82+
- name: Generate API documentation
83+
if: matrix.java == 'temurin@8' && matrix.os == 'ubuntu-latest'
84+
run: sbt '++ ${{ matrix.scala }}' doc
1485

86+
- name: Make target directories
87+
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
88+
run: mkdir -p plugin/target scalafix/rules/target target/sbt-tpolecat-scalafix-aggregate/target scalafix/output/target scalafix/tests/target target scalafix/input/target project/target
89+
90+
- name: Compress target directories
91+
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
92+
run: tar cf targets.tar plugin/target scalafix/rules/target target/sbt-tpolecat-scalafix-aggregate/target scalafix/output/target scalafix/tests/target target scalafix/input/target project/target
93+
94+
- name: Upload target directories
95+
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
96+
uses: actions/upload-artifact@v3
97+
with:
98+
name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}
99+
path: targets.tar
100+
101+
publish:
102+
name: Publish Artifacts
103+
needs: [build]
104+
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
105+
strategy:
106+
matrix:
107+
os: [ubuntu-latest]
108+
java: [temurin@8]
109+
runs-on: ${{ matrix.os }}
15110
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v2
18-
19-
- name: Download Java
20-
id: download-java
21-
uses: typelevel/download-java@v1
22-
with:
23-
distribution: temurin
24-
java-version: ${{ matrix.java-version }}
25-
26-
- name: Setup Java
27-
uses: actions/setup-java@v2
28-
with:
29-
distribution: jdkfile
30-
java-version: ${{ matrix.java-version }}
31-
jdkFile: ${{ steps.download-java.outputs.jdkFile }}
32-
33-
- name: Scalafmt
34-
run: sbt scalafmtCheckAll scalafmtSbtCheck
35-
36-
- name: Run tests
37-
run: |
38-
sbt headerCheck
39-
sbt test
40-
sbt mimaReportBinaryIssues
111+
- name: Checkout current branch (full)
112+
uses: actions/checkout@v3
113+
with:
114+
fetch-depth: 0
115+
116+
- name: Download Java (temurin@8)
117+
id: download-java-temurin-8
118+
if: matrix.java == 'temurin@8'
119+
uses: typelevel/download-java@v2
120+
with:
121+
distribution: temurin
122+
java-version: 8
123+
124+
- name: Setup Java (temurin@8)
125+
if: matrix.java == 'temurin@8'
126+
uses: actions/setup-java@v3
127+
with:
128+
distribution: jdkfile
129+
java-version: 8
130+
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}
131+
132+
- name: Cache sbt
133+
uses: actions/cache@v3
134+
with:
135+
path: |
136+
~/.sbt
137+
~/.ivy2/cache
138+
~/.coursier/cache/v1
139+
~/.cache/coursier/v1
140+
~/AppData/Local/Coursier/Cache/v1
141+
~/Library/Caches/Coursier/v1
142+
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
143+
144+
- name: Download target directories (2.12.18)
145+
uses: actions/download-artifact@v3
146+
with:
147+
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.18
148+
149+
- name: Inflate target directories (2.12.18)
150+
run: |
151+
tar xf targets.tar
152+
rm targets.tar
153+
154+
- name: Import signing key
155+
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
156+
run: echo $PGP_SECRET | base64 -di | gpg --import
157+
158+
- name: Import signing key and strip passphrase
159+
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != ''
160+
run: |
161+
echo "$PGP_SECRET" | base64 -di > /tmp/signing-key.gpg
162+
echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg
163+
(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)
164+
165+
- name: Publish
166+
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

build.sbt

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,16 @@
11
import com.typesafe.tools.mima.core._
22

3+
ThisBuild / tlBaseVersion := "0.4"
4+
35
ThisBuild / organization := "org.typelevel"
46
ThisBuild / organizationName := "Typelevel"
57

68
ThisBuild / startYear := Some(2022)
7-
ThisBuild / licenses += ("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html"))
8-
ThisBuild / scmInfo := Some(
9-
ScmInfo(
10-
url("https://github.com/typelevel/sbt-tpolecat"),
11-
"scm:git:[email protected]:typelevel/sbt-tpolecat.git"
12-
)
13-
)
14-
ThisBuild / developers := List(
15-
Developer(
16-
"DavidGregory084",
17-
"David Gregory",
18-
19-
url("https://github.com/DavidGregory084")
20-
)
21-
)
9+
ThisBuild / licenses := Seq(License.Apache2)
2210

23-
ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org"
24-
ThisBuild / sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
25-
26-
ThisBuild / homepage := scmInfo.value.map(_.browseUrl)
11+
ThisBuild / developers ++= List(
12+
tlGitHubDev("DavidGregory084", "David Gregory")
13+
)
2714

2815
ThisBuild / semanticdbEnabled := true
2916
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision
@@ -32,21 +19,10 @@ ThisBuild / versionScheme := Some(VersionScheme.EarlySemVer)
3219

3320
lazy val `sbt-tpolecat` = project
3421
.in(file("."))
22+
.enablePlugins(NoPublishPlugin)
3523
.aggregate(
3624
`sbt-tpolecat-plugin`,
37-
`sbt-tpolecat-scalafix`.rules,
38-
`sbt-tpolecat-scalafix`.input,
39-
`sbt-tpolecat-scalafix`.tests
40-
/* TODO: change individual Scalafix project dependencies to `sbt-tpolecat-scalafix`.all when the package rename is in main;
41-
* the Scalafix `output` project will not compile until the package renaming is done.
42-
*/
43-
)
44-
.settings(
45-
publish := {},
46-
publishLocal := {},
47-
publishArtifact := false,
48-
publish / skip := true,
49-
mimaReportBinaryIssues := {}
25+
`sbt-tpolecat-scalafix`.all
5026
)
5127

5228
lazy val `sbt-tpolecat-plugin` = project

project/plugins.sbt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0")
2-
3-
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
4-
5-
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4")
6-
7-
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
8-
9-
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.0")
10-
11-
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3")
1+
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.22")
2+
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.0")
3+
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4")
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import org.typelevel.sbt.tpolecat.{ DevMode => Dev, TpolecatPlugin, _ }
2-
import org.typelevel.scalacoptions.{ ScalaVersion => Version, ScalacOption, _ }
1+
import org.typelevel.sbt.tpolecat.{DevMode => Dev, TpolecatPlugin, _}
2+
import org.typelevel.scalacoptions.{ScalaVersion => Version, ScalacOption, _}
33

44
object Tests
File renamed without changes.

scalafix/tests/src/test/scala/org/typelevel/fix/RuleSuite.scala

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

319
import scalafix.testkit._

0 commit comments

Comments
 (0)