Skip to content

Commit

Permalink
Merge pull request #1756 from bjaglin/setup-scala
Browse files Browse the repository at this point in the history
Refactor testing setup
  • Loading branch information
bjaglin authored May 16, 2023
2 parents 919e37a + 86a0a9b commit afb12ac
Show file tree
Hide file tree
Showing 62 changed files with 655 additions and 672 deletions.
67 changes: 22 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,69 +6,46 @@ on:
pull_request:
jobs:
test:
name: ${{ matrix.command }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
command:
- "ci-212"
- "ci-213"
- "ci-3"
steps:
- uses: actions/checkout@v3
- uses: olafurpg/setup-scala@v14
- run: sbt ${{ matrix.command }}
jdk11_212:
name: JDK11/scala_2.12 tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: olafurpg/setup-scala@v14
with:
java-version: [email protected]
- run: sbt ci-212
jdk11_213:
name: JDK11/scala_2.13 tests
runs-on: ubuntu-latest
os: ["ubuntu"]
jvm: ["8", "11", "17"]
include:
- os: windows
jvm: 17
name: ${{ matrix.os }} / JDK${{ matrix.jvm }}
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v3
- uses: olafurpg/setup-scala@v14
- uses: coursier/setup-action@v1
with:
java-version: [email protected]
- run: sbt ci-213

jdk17_213:
name: JDK17/scala_2.13 tests
jvm: temurin:${{ matrix.jvm }}
- if: ${{ matrix.os != 'windows' }}
run: sbt test
- if: ${{ matrix.os == 'windows' }}
run: sbt testWindows
docs:
name: Compile docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: olafurpg/setup-scala@v14
with:
java-version: 17
- run: sbt ci-213

windows_213:
name: Windows/scala_2.13 tests
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: olafurpg/setup-scala@v14
- run: sbt ci-213-windows
shell: bash
checks:
- uses: coursier/setup-action@v1
- run: sbt ci-docs
formatting:
name: Scalafmt and Scalafix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: olafurpg/setup-scala@v14
- uses: coursier/setup-action@v1
- run: sbt "scalafixAll --check"
- run: ./bin/scalafmt --test
mima:
name: Version Policy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: olafurpg/setup-scala@v14
- run: git fetch --unshallow
with:
fetch-depth: 0
- uses: coursier/setup-action@v1
- run: sbt versionPolicyCheck
2 changes: 1 addition & 1 deletion .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: olafurpg/setup-scala@v14
- uses: coursier/setup-action@v1
- name: Publish ${{ github.ref }}
run: sbt docs2_13/docusaurusPublishGhpages
env:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: olafurpg/setup-scala@v14
with:
fetch-depth: 0
- uses: coursier/setup-action@v1
- uses: olafurpg/setup-gpg@v3
- run: git fetch --unshallow
- name: Check that major or minor was bumped upon compatibility breakage
if: startsWith(github.ref, 'refs/tags/v')
run: sbt versionCheck
Expand Down
37 changes: 25 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,37 @@ hesitate to ask in the [Discord channel](https://discord.gg/8AHaqGx3Qj).

The project should import normally into IntelliJ and there should not be any
false red squiggles. To use the debugger or run tests from within IntelliJ, run
at least once `sbt unit2_13Target2_13/test` to generate a `BuildInfo` file and
property files for Scalafix testkit.
at least once tests through sbt to generate a `BuildInfo` file and property
files for Scalafix testkit.

## Testing

Start the SBT shell with `$ sbt`. The commands below assume you have a running
sbt shell.

```sh
# Fast unit tests for rules, cli, core. Contains a lot
# of different test suites, so it's recommended to use testOnly.
> unit2_13Target2_13/test
# Fast unit tests for rules, cli, core.
> unit2_13/test

# Only run tests for rules, using scalafix-testkit.
> unit2_13Target2_13/testOnly *RuleSuite
# Integration tests for rules, cli, core. Contains a lot
# of different test suites, so it's recommended to use testOnly
# and/or testQuick.
> integration2_13/test

# Only run only ProcedureSyntax unit test.
> unit2_13Target2_13/testOnly *RuleSuite -- -z ProcedureSyntax
# Use testWindows to exclude tests that are not expected to succeed
# on that OS.
> unit2_13/testWindows
> integration2_13/testWindows

# Only run tests for built-in rules, using scalafix-testkit.
> expect2_13Target2_13_10/test

# Only run ProcedureSyntax unit tests.
> expect2_13Target2_13_10/testOnly -- -z ProcedureSyntax
```

[sbt-projectmatrix](https://github.com/sbt/sbt-projectmatrix) is used to
generate several sbt projects `unitXTargetY` with the same source code,
generate several sbt projects `expectTargetY` with the same source code,
but for a combination of Scala versions:
- used for compiling the framework and rules (`X`)
- used for compiling and generating SemanticDB files for the test input (`Y`)
Expand All @@ -49,10 +58,14 @@ Unit tests for rules are written using scalafix-testkit

```
scalafix-tests
|
├── unit # Unit test suites
|
├── integration # Integration test suites
|
├── input # Source files to be analyzed and fixed by rules
├── output # Expected output from running rewrite rules
├── shared # Code that is shared between input and unit projects
└── unit # Unit test suites.
└── expect # Verify expectations defined in input/output using testkit
```

## Formatting
Expand Down
Loading

0 comments on commit afb12ac

Please sign in to comment.