Skip to content

Commit afb12ac

Browse files
authored
Merge pull request #1756 from bjaglin/setup-scala
Refactor testing setup
2 parents 919e37a + 86a0a9b commit afb12ac

File tree

62 files changed

+655
-672
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+655
-672
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,69 +6,46 @@ on:
66
pull_request:
77
jobs:
88
test:
9-
name: ${{ matrix.command }}
10-
runs-on: ubuntu-latest
119
strategy:
1210
fail-fast: false
1311
matrix:
14-
command:
15-
- "ci-212"
16-
- "ci-213"
17-
- "ci-3"
18-
steps:
19-
- uses: actions/checkout@v3
20-
- uses: olafurpg/setup-scala@v14
21-
- run: sbt ${{ matrix.command }}
22-
jdk11_212:
23-
name: JDK11/scala_2.12 tests
24-
runs-on: ubuntu-latest
25-
steps:
26-
- uses: actions/checkout@v3
27-
- uses: olafurpg/setup-scala@v14
28-
with:
29-
java-version: adopt@1.11
30-
- run: sbt ci-212
31-
jdk11_213:
32-
name: JDK11/scala_2.13 tests
33-
runs-on: ubuntu-latest
12+
os: ["ubuntu"]
13+
jvm: ["8", "11", "17"]
14+
include:
15+
- os: windows
16+
jvm: 17
17+
name: ${{ matrix.os }} / JDK${{ matrix.jvm }}
18+
runs-on: ${{ matrix.os }}-latest
3419
steps:
3520
- uses: actions/checkout@v3
36-
- uses: olafurpg/setup-scala@v14
21+
- uses: coursier/setup-action@v1
3722
with:
38-
java-version: adopt@1.11
39-
- run: sbt ci-213
40-
41-
jdk17_213:
42-
name: JDK17/scala_2.13 tests
23+
jvm: temurin:${{ matrix.jvm }}
24+
- if: ${{ matrix.os != 'windows' }}
25+
run: sbt test
26+
- if: ${{ matrix.os == 'windows' }}
27+
run: sbt testWindows
28+
docs:
29+
name: Compile docs
4330
runs-on: ubuntu-latest
4431
steps:
4532
- uses: actions/checkout@v3
46-
- uses: olafurpg/setup-scala@v14
47-
with:
48-
java-version: 17
49-
- run: sbt ci-213
50-
51-
windows_213:
52-
name: Windows/scala_2.13 tests
53-
runs-on: windows-latest
54-
steps:
55-
- uses: actions/checkout@v3
56-
- uses: olafurpg/setup-scala@v14
57-
- run: sbt ci-213-windows
58-
shell: bash
59-
checks:
33+
- uses: coursier/setup-action@v1
34+
- run: sbt ci-docs
35+
formatting:
6036
name: Scalafmt and Scalafix
6137
runs-on: ubuntu-latest
6238
steps:
6339
- uses: actions/checkout@v3
64-
- uses: olafurpg/setup-scala@v14
40+
- uses: coursier/setup-action@v1
6541
- run: sbt "scalafixAll --check"
6642
- run: ./bin/scalafmt --test
6743
mima:
6844
name: Version Policy
6945
runs-on: ubuntu-latest
7046
steps:
7147
- uses: actions/checkout@v3
72-
- uses: olafurpg/setup-scala@v14
73-
- run: git fetch --unshallow
48+
with:
49+
fetch-depth: 0
50+
- uses: coursier/setup-action@v1
7451
- run: sbt versionPolicyCheck

.github/workflows/deploy-website.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- uses: actions/checkout@v3
1111
with:
1212
fetch-depth: 0
13-
- uses: olafurpg/setup-scala@v14
13+
- uses: coursier/setup-action@v1
1414
- name: Publish ${{ github.ref }}
1515
run: sbt docs2_13/docusaurusPublishGhpages
1616
env:

.github/workflows/release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v3
11-
- uses: olafurpg/setup-scala@v14
11+
with:
12+
fetch-depth: 0
13+
- uses: coursier/setup-action@v1
1214
- uses: olafurpg/setup-gpg@v3
13-
- run: git fetch --unshallow
1415
- name: Check that major or minor was bumped upon compatibility breakage
1516
if: startsWith(github.ref, 'refs/tags/v')
1617
run: sbt versionCheck

CONTRIBUTING.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,37 @@ hesitate to ask in the [Discord channel](https://discord.gg/8AHaqGx3Qj).
1919

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

2525
## Testing
2626

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

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

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

38-
# Only run only ProcedureSyntax unit test.
39-
> unit2_13Target2_13/testOnly *RuleSuite -- -z ProcedureSyntax
39+
# Use testWindows to exclude tests that are not expected to succeed
40+
# on that OS.
41+
> unit2_13/testWindows
42+
> integration2_13/testWindows
43+
44+
# Only run tests for built-in rules, using scalafix-testkit.
45+
> expect2_13Target2_13_10/test
46+
47+
# Only run ProcedureSyntax unit tests.
48+
> expect2_13Target2_13_10/testOnly -- -z ProcedureSyntax
4049
```
4150

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

5059
```
5160
scalafix-tests
61+
|
62+
├── unit # Unit test suites
63+
|
64+
├── integration # Integration test suites
65+
|
5266
├── input # Source files to be analyzed and fixed by rules
5367
├── output # Expected output from running rewrite rules
54-
├── shared # Code that is shared between input and unit projects
55-
└── unit # Unit test suites.
68+
└── expect # Verify expectations defined in input/output using testkit
5669
```
5770

5871
## Formatting

0 commit comments

Comments
 (0)