Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@v13

- name: Main project tests
run: nix develop .#jdk${{ matrix.java }} --command sbt test
run: nix develop .#jdk${{ matrix.java }} --command gradle test --no-daemon

docker_test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -83,8 +83,8 @@ jobs:

- uses: DeterminateSystems/magic-nix-cache-action@v13

- run: nix develop --command sbt cli/pack
- run: echo "$PWD/scip-java/target/pack/bin" >> "$GITHUB_PATH"
- run: nix develop --command gradle :scip-java:installDist --no-daemon
- run: echo "$PWD/scip-java/build/install/scip-java/bin" >> "$GITHUB_PATH"
- name: Auto-index scip-java codebase
run: |
# shellcheck disable=SC2016
Expand Down Expand Up @@ -113,10 +113,10 @@ jobs:
- uses: DeterminateSystems/magic-nix-cache-action@v13

- name: scip-kotlinc tests
run: nix develop --command sbt scipKotlinc/test
run: nix develop --command gradle :scip-kotlinc:test --no-daemon

- name: Regenerate snapshots
run: nix develop --command sbt scipSnapshots/run
run: nix develop --command gradle :scip-snapshots:saveSnapshots --no-daemon

- name: Check snapshot drift
run: |
Expand All @@ -141,13 +141,13 @@ jobs:

- run: |
nix develop .#jdk${{ matrix.java }} --command \
sbt --error cli/pack publishM2 publishLocal
gradle --no-daemon :scip-java:installDist publishToMavenLocal
SCIP_JAVA_VERSION="$(
sed -n 's/^version:=//p' scip-java/target/pack/VERSION
sed -n 's/^version:=//p' scip-java/build/install/scip-java/VERSION
)"
test -n "$SCIP_JAVA_VERSION"
printf 'SCIP_JAVA_VERSION=%s\n' "$SCIP_JAVA_VERSION" >> "$GITHUB_ENV"
printf 'SCIP_JAVA_CLI=%s\n' "$PWD/scip-java/target/pack/bin/scip-java" >> "$GITHUB_ENV"
printf 'SCIP_JAVA_CLI=%s\n' "$PWD/scip-java/build/install/scip-java/bin/scip-java" >> "$GITHUB_ENV"

- run: |
nix develop "$GITHUB_WORKSPACE#jdk${{ matrix.java }}" --command \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
cd "$OUT_DIR"

VERSION=${VERSION#v}
ARTIFACT="com.sourcegraph:scip-java_2.13:${VERSION}"
ARTIFACT="com.sourcegraph:scip-java:${VERSION}"

for attempt in {1..10}; do
if cs resolve "$ARTIFACT" >/dev/null 2>&1; then
Expand Down
24 changes: 18 additions & 6 deletions .github/workflows/release-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@ jobs:
with:
summarize: false
- uses: DeterminateSystems/magic-nix-cache-action@v13
- name: Publish ${{ github.ref }}
run: nix develop --command sbt ci-release
- name: Publish snapshot ${{ github.ref }}
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: nix develop --command gradle --no-daemon publishToMavenCentral
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.PGP_SECRET }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.PGP_PASSPHRASE }}
- name: Publish release ${{ github.ref }}
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: |
version="${GITHUB_REF_NAME#v}"
nix develop --command gradle --no-daemon \
"-PreleaseVersion=$version" publishAndReleaseToMavenCentral
env:
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.PGP_SECRET }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.PGP_PASSPHRASE }}

release-cli:
if: ${{ startsWith(github.ref, 'refs/tags/') }}
Expand Down
10 changes: 3 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
result
result-*

# sbt specific
# build tool output
.gradle/
build/
.cache
.history
.lib/
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/
.bloop

_site/
Expand Down Expand Up @@ -79,7 +79,3 @@ scip-snapshots/META-INF/
# writes META-INF/scip/sources/Test.kt.scip relative to the test
# cwd.
scip-kotlinc/META-INF/

# Standard sbt project metadata directories.
project/target/
project/project/
56 changes: 25 additions & 31 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ nix develop .#jdk17 # JDK 17
nix develop .#jdk21 # JDK 21
```

This drops you into a shell with `sbt`, `maven`, `gradle`, `bazelisk`,
`nodejs`, `yarn`, `git`, `jq`, etc. all pinned to the versions used in CI.
This drops you into a shell with `gradle`, `maven`, `bazelisk`, `nodejs`,
`yarn`, `git`, `jq`, etc. all pinned to the versions used in CI.

If you'd rather install tools manually, you'll need at least:

Expand Down Expand Up @@ -43,25 +43,23 @@ These are the main components of the project.
interface.
- `scip-java/src/test`: build-tool integration tests and fixtures for the
`scip-java` command-line interface.
- `build.sbt`: the sbt build definition.
- `project/plugins.sbt`: plugins for the sbt build.
- `settings.gradle.kts`: Gradle project layout.
- `build.gradle.kts`: Gradle build definition.
- `gradle/libs.versions.toml`: dependency and plugin versions.

## Helpful commands

| Command | Where | Description |
| ------------------------------------------------------------------- | -------- | ----------------------------------------------------------------------------------- |
| `sbt` | terminal | Start interactive sbt shell with Java 11 (run from `nix develop`). Takes a while to load on the first run. |
| `unit/test` | sbt | Run fast unit tests. |
| `~unit/test` | sbt | Start watch mode to run tests on file save, good for local edit-and-test workflows. |
| `cli/test` | sbt | Run slow build tool tests (Gradle, Maven). |
| `snapshots/testOnly tests.MinimizedSnapshotScipTest` | sbt | Runs fast snapshot tests. Indexes a small set of files under `tests/minimized`. |
| `snapshots/test` | sbt | Runs all snapshot tests. |
| `snapshots/run` | sbt | Update only the Java snapshot goldens under `tests/snapshots`. |
| `scipKotlincMinimized/kotlincSnapshots` | sbt | Update only the Kotlin snapshot goldens under `scip-kotlinc/minimized`. |
| `regenerateSnapshots` | sbt | Regenerate ALL snapshot goldens (Java + Kotlin). Run after fixing a bug. |
| `cli/run --cwd DIRECTORY` | sbt | Run `scip-java` command-line tool against a given Gradle/Maven build. |
| `google-java-format --replace $(git ls-files '*.java')` | terminal | Format Java sources (from `nix develop`). Enforced by `nix flake check`. |
| `ktfmt --kotlinlang-style $(git ls-files '*.kt')` | terminal | Format Kotlin sources (from `nix develop`). Enforced by `nix flake check`. |
| Command | Where | Description |
| ------------------------------------------------------- | -------- | ----------------------------------------------------------------------- |
| `gradle test --no-daemon` | terminal | Run all Gradle tests. |
| `gradle :scip-java:test --no-daemon` | terminal | Run CLI build-tool integration tests (Gradle, Maven, SCIP config). |
| `gradle :scip-kotlinc:test --no-daemon` | terminal | Run Kotlin compiler-plugin tests. |
| `gradle :scip-snapshots:test --no-daemon` | terminal | Compare Java and Kotlin snapshot goldens. |
| `gradle :scip-snapshots:saveSnapshots --no-daemon` | terminal | Regenerate Java and Kotlin snapshot goldens. |
| `gradle :scip-java:installDist --no-daemon` | terminal | Build a local `scip-java` distribution under `scip-java/build/install/`. |
| `gradle :scip-java:run --args='--cwd DIRECTORY'` | terminal | Run `scip-java` against a given Gradle/Maven build. |
| `google-java-format --replace $(git ls-files '*.java')` | terminal | Format Java sources (from `nix develop`). Enforced by `nix flake check`. |
| `ktfmt --kotlinlang-style $(git ls-files '*.kt')` | terminal | Format Kotlin sources (from `nix develop`). Enforced by `nix flake check`. |

## Import the project into IntelliJ

Expand All @@ -80,20 +78,16 @@ Next, follow
[these instructions](https://github.com/HPI-Information-Systems/Metanome/wiki/Installing-the-google-styleguide-settings-in-intellij-and-eclipse)
here to configure the Google Java formatter.

Finally, run "File > Project From Existing Sources" to import the sbt build into
IntelliJ. Select the "sbt" option if it asks you to choose between
sbt/BSP/Bloop.
Finally, run "File > Project From Existing Sources" to import the Gradle build
into IntelliJ. Select the "Gradle" option if it asks you to choose a build
model.

It's best to run tests from the sbt shell, not from the IntelliJ UI.
It's best to run tests from Gradle, not from the IntelliJ UI.

## Tests are written in Java with JUnit 5

The unit tests (`tests/unit`) and snapshot tests (`tests/snapshots`) are plain
Java using [JUnit 5](https://junit.org/junit5/), wired into sbt via
[sbt-jupiter-interface](https://github.com/sbt/sbt-jupiter-interface). The
snapshot suite is a JUnit `@TestFactory` that emits one dynamic test per
generated document, comparing it against the committed goldens under
`tests/snapshots/src/main/generated`
([snapshot testing](https://jestjs.io/docs/en/snapshot-testing) is heavily used
in this codebase). Build-tool tests (`scip-java/src/test`) are written in
Kotlin.
The Java tests use [JUnit 5](https://junit.org/junit5/) through Gradle's JUnit
Platform support. The snapshot suite is a JUnit `@TestFactory` that emits one
dynamic test per generated document, comparing it against the committed goldens
under `scip-snapshots/expected`. Build-tool tests (`scip-java/src/test`) are
written in Kotlin.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN git config --global --add safe.directory *

COPY . .

RUN sbt cli/pack && mkdir -p /app/scip-java && cp -R scip-java/target/pack/. /app/scip-java/
RUN gradle --no-daemon :scip-java:installDist && mkdir -p /app/scip-java && cp -R scip-java/build/install/scip-java/. /app/scip-java/

COPY ./bin/scip-java-docker-script.sh /usr/bin/scip-java

Expand Down
4 changes: 2 additions & 2 deletions bin/docker-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ set -eux
curl -fLo /usr/local/bin/cs https://github.com/coursier/coursier/releases/download/v2.1.5/coursier
chmod +x /usr/local/bin/cs
ln -sf /usr/local/bin/cs /usr/local/bin/coursier
cs setup --yes --apps cs,coursier,sbt
cs setup --yes --apps cs,coursier

curl -fLo maven.zip https://archive.apache.org/dist/maven/maven-3/3.9.1/binaries/apache-maven-3.9.1-bin.zip
unzip -d /opt/maven maven.zip
rm maven.zip
mv /opt/maven/*/* /opt/maven

curl -fLo gradle.zip https://services.gradle.org/distributions/gradle-7.6.1-bin.zip
curl -fLo gradle.zip https://services.gradle.org/distributions/gradle-8.14.4-bin.zip
unzip -d /opt/gradle gradle.zip
rm gradle.zip
mv /opt/gradle/*/* /opt/gradle
Expand Down
Loading
Loading