Skip to content

Commit

Permalink
Merge pull request #224 from typelevel/update/sbt-typelevel-0.7.2
Browse files Browse the repository at this point in the history
Update sbt-typelevel to 0.7.2
  • Loading branch information
lenguyenthanh authored Aug 19, 2024
2 parents f89d6d9 + 26a6a3c commit 0dec6f2
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 71 deletions.
148 changes: 87 additions & 61 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,55 +15,45 @@ on:
tags: [v*]

env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


concurrency:
group: ${{ github.workflow }} @ ${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build and Test
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.18]
scala: [2.12]
java: [temurin@8]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- name: Install sbt
if: contains(runner.os, 'macos')
run: brew install sbt

- name: Checkout current branch (full)
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download Java (temurin@8)
id: download-java-temurin-8
if: matrix.java == 'temurin@8'
uses: typelevel/download-java@v2
with:
distribution: temurin
java-version: 8

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: jdkfile
distribution: temurin
java-version: 8
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}
cache: sbt

- name: Cache sbt
uses: actions/cache@v3
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt +update

- name: Check that workflows are up to date
run: sbt githubWorkflowCheck
Expand All @@ -85,15 +75,15 @@ jobs:

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
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
run: mkdir -p plugin/target scalafix/rules/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
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
run: tar cf targets.tar plugin/target scalafix/rules/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-${{ matrix.scala }}
path: targets.tar
Expand All @@ -108,59 +98,95 @@ jobs:
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
- name: Install sbt
if: contains(runner.os, 'macos')
run: brew install sbt

- name: Checkout current branch (full)
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download Java (temurin@8)
id: download-java-temurin-8
- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
uses: typelevel/download-java@v2
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
cache: sbt

- name: Setup Java (temurin@8)
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v3
with:
distribution: jdkfile
java-version: 8
jdkFile: ${{ steps.download-java-temurin-8.outputs.jdkFile }}
- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt +update

- name: Cache sbt
uses: actions/cache@v3
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Download target directories (2.12.18)
uses: actions/download-artifact@v3
- name: Download target directories (2.12)
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12.18
name: target-${{ matrix.os }}-${{ matrix.java }}-2.12

- name: Inflate target directories (2.12.18)
- name: Inflate target directories (2.12)
run: |
tar xf targets.tar
rm targets.tar
- name: Import signing key
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE == ''
run: echo $PGP_SECRET | base64 -di | gpg --import
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: echo $PGP_SECRET | base64 -d -i - | gpg --import

- name: Import signing key and strip passphrase
if: env.PGP_SECRET != '' && env.PGP_PASSPHRASE != ''
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: |
echo "$PGP_SECRET" | base64 -di > /tmp/signing-key.gpg
echo "$PGP_SECRET" | base64 -d -i - > /tmp/signing-key.gpg
echo "$PGP_PASSPHRASE" | gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/signing-key.gpg
(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)
- name: Publish
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }}
run: sbt tlCiRelease

dependency-submission:
name: Submit Dependencies
if: github.event_name != 'pull_request'
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
- name: Install sbt
if: contains(runner.os, 'macos')
run: brew install sbt

- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@8)
id: setup-java-temurin-8
if: matrix.java == 'temurin@8'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
run: sbt +update

- name: Submit Dependencies
uses: scalacenter/sbt-dependency-submission@v2
with:
modules-ignore: sbt-tpolecat_2.12
configs-ignore: test scala-tool scala-doc-tool test-internal
2 changes: 2 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ lazy val `sbt-tpolecat-scalafix` = scalafixProject("sbt-tpolecat")
)
)
.inputSettings(addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.4.0"))
.inputSettings(tlFatalWarnings := false)
.inputConfigure(_.enablePlugins(SbtPlugin))
.outputSettings(tlFatalWarnings := false)
.outputConfigure(_.dependsOn(`sbt-tpolecat-plugin`))
.outputConfigure(_.enablePlugins(SbtPlugin))
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.22")
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.7.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4")
18 changes: 9 additions & 9 deletions scalafix/rules/src/main/scala/fix/v0_5.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ class v0_5 extends SemanticRule("v0_5") {

def handleImports(importees: List[Importee], createNewImport: Importee => Patch): Patch =
importees.collect {
case importee @ Importee.Name(name) =>
case importee @ Importee.Name(_) =>
createNewImport(importee) + Patch.removeImportee(importee)
case rename @ Importee.Rename(name, _) =>
case rename @ Importee.Rename(_, _) =>
createNewImport(rename) + Patch.removeImportee(rename)
case importee @ Importee.Wildcard() =>
createNewImport(importee) + Patch.removeImportee(importee)
Expand All @@ -108,7 +108,7 @@ class v0_5 extends SemanticRule("v0_5") {
override def fix(implicit doc: SemanticDocument): Patch =
doc.tree.collect {
// Handle imports from `io.github.davidgregory084`
case importer @ Importer(ref, importees) if PackageSym.matches(ref) =>
case _ @Importer(ref, importees) if PackageSym.matches(ref) =>
importees.collect {
case importee @ Importee.Name(name) if PluginSym.matches(name) =>
makePluginImport(importee) + Patch.removeImportee(importee)
Expand All @@ -124,25 +124,25 @@ class v0_5 extends SemanticRule("v0_5") {
Patch.removeImportee(importee)
}.asPatch
// Handle imports from `io.github.davidgregory084.TpolecatPlugin`
case importer @ Importer(ref, importees) if TpolecatPluginSym.matches(ref) =>
case _ @Importer(ref, importees) if TpolecatPluginSym.matches(ref) =>
handleImports(importees, makeTpolecatPluginObjectImport)
// Handle imports from `io.github.davidgregory084.ScalaVersion`
case importer @ Importer(ref, importees) if ScalaVersionSym.matches(ref) =>
case _ @Importer(ref, importees) if ScalaVersionSym.matches(ref) =>
handleImports(importees, makeScalaVersionObjectImport)
// Handle imports from `io.github.davidgregory084.TpolecatPlugin.ScalacOptions`
case importer @ Importer(ref, importees) if TpolecatPluginScalacOptionsSym.matches(ref) =>
case _ @Importer(ref, importees) if TpolecatPluginScalacOptionsSym.matches(ref) =>
handleImports(importees, makeScalacOptionsObjectImport)
// Handle imports from `io.github.davidgregory084.TpolecatPlugin.autoImport`
case importer @ Importer(ref, importees) if TpolecatPluginAutoImportSym.matches(ref) =>
case _ @Importer(ref, importees) if TpolecatPluginAutoImportSym.matches(ref) =>
importees.collect {
// The `ScalacOptions` object moved to `scalac-options`
case importee @ Importee.Name(name) if TpolecatPluginScalacOptionsSym.matches(name) =>
makeScalacOptionsImport(importee) + Patch.removeImportee(importee)
case rename @ Importee.Rename(name, _) if TpolecatPluginScalacOptionsSym.matches(name) =>
makeScalacOptionsImport(rename) + Patch.removeImportee(rename)
case importee @ Importee.Name(name) =>
case importee @ Importee.Name(_) =>
makeAutoImportObjectImport(importee) + Patch.removeImportee(importee)
case rename @ Importee.Rename(name, _) =>
case rename @ Importee.Rename(_, _) =>
makeAutoImportObjectImport(rename) + Patch.removeImportee(rename)
case importee @ Importee.Wildcard() =>
makeAutoImportObjectImport(importee) + Patch.removeImportee(importee)
Expand Down

0 comments on commit 0dec6f2

Please sign in to comment.