diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..ad749f53 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,33 @@ +name: CI +on: + push: + branches: + - main + pull_request: +jobs: + docker_test: + runs-on: ubuntu-latest + name: Docker CLI tests + steps: + - uses: actions/checkout@v4 + + - name: Build Dockerised CLI + run: docker build -t sourcegraph/scip-java:latest . + + - name: Test repos + shell: bash + run: | + set -eu + check_repo() { + REPO=$1 + mkdir -p ".repos/$REPO" + git clone "https://github.com/$REPO.git" ".repos/$REPO" && cd ".repos/$REPO" && git submodule update --init + + docker run -v "$PWD/.repos/$REPO:/sources" -w /sources sourcegraph/scip-java:latest scip-java index + file ".repos/$REPO/index.scip" || (echo "$REPO SCIP index doesn't exist!"; exit 1) + } + + sudo apt install parallel + export -f check_repo + + parallel -j4 check_repo ::: circe/circe indeedeng/iwf-java-sdk diff --git a/.github/workflows/nix-flake-check.yml b/.github/workflows/nix-flake-check.yml deleted file mode 100644 index 340a3399..00000000 --- a/.github/workflows/nix-flake-check.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: nix flake check -on: - push: - branches: - - main - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - flake-check: - runs-on: ubuntu-latest - name: nix flake check - steps: - - uses: actions/checkout@v4 - - - uses: DeterminateSystems/nix-installer-action@v22 - with: - summarize: false - - - uses: DeterminateSystems/magic-nix-cache-action@v13 - - - run: nix flake check -L diff --git a/.github/workflows/ci.yml b/.github/workflows/nix.yaml similarity index 51% rename from .github/workflows/ci.yml rename to .github/workflows/nix.yaml index 640bfdb7..67dcc2f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/nix.yaml @@ -1,17 +1,25 @@ -name: CI +name: Nix on: push: branches: - main pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +env: + NIX_DEVELOP: ${{ github.workspace }} + +defaults: + run: + shell: bash --noprofile --norc -eo pipefail -c "nix develop $NIX_DEVELOP --command bash --noprofile --norc -eo pipefail $1" -- {0} + jobs: - test: + flake-check: runs-on: ubuntu-latest - name: Tests - strategy: - fail-fast: false - matrix: - java: [11, 17, 21] + name: nix flake check steps: - uses: actions/checkout@v4 @@ -21,38 +29,44 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@v13 - - name: Main project tests - run: nix develop .#jdk${{ matrix.java }} --command gradle test --no-daemon + - run: nix flake check -L - docker_test: + test: runs-on: ubuntu-latest - name: Docker CLI tests + name: Tests (JDK ${{ matrix.java }}) + env: + NIX_DEVELOP: ${{ github.workspace }}#jdk${{ matrix.java }} + strategy: + fail-fast: false + matrix: + java: [11, 17, 21] steps: - uses: actions/checkout@v4 - - name: Build Dockerised CLI - run: docker build -t sourcegraph/scip-java:latest . - - - name: Test repos - shell: bash - run: | - set -eu - check_repo() { - REPO=$1 - mkdir -p ".repos/$REPO" - git clone "https://github.com/$REPO.git" ".repos/$REPO" && cd ".repos/$REPO" && git submodule update --init - - docker run -v "$PWD/.repos/$REPO:/sources" -w /sources sourcegraph/scip-java:latest scip-java index - file ".repos/$REPO/index.scip" || (echo "$REPO SCIP index doesn't exist!"; exit 1) - } + - uses: DeterminateSystems/nix-installer-action@v22 + with: + summarize: false - sudo apt install parallel - export -f check_repo + - uses: DeterminateSystems/magic-nix-cache-action@v13 - parallel -j4 check_repo ::: circe/circe indeedeng/iwf-java-sdk + - name: Main project tests + run: gradle test --no-daemon bazel: runs-on: ubuntu-latest + name: Bazel (${{ matrix.name }}) + strategy: + fail-fast: false + matrix: + include: + - name: scip-java + directory: . + javac_option: "--//scip-javac:enabled=true" + aggregator_target: "scip-aggregator:bazel" + - name: bazel-example + directory: examples/bazel-example + javac_option: "--@scip_java//scip-javac:enabled=true" + aggregator_target: "@scip_java//scip-aggregator:bazel" steps: - uses: actions/checkout@v4 @@ -62,15 +76,12 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@v13 - - run: nix develop --command bazelisk build //... --//scip-javac:enabled=true - - run: nix develop --command bazelisk run scip-aggregator:bazel -- --sourceroot "$PWD" + - run: bazelisk build //... ${{ matrix.javac_option }} + working-directory: ${{ matrix.directory }} + - run: bazelisk run ${{ matrix.aggregator_target }} -- --sourceroot "$PWD" + working-directory: ${{ matrix.directory }} - run: du -h index.scip - - run: nix develop "$GITHUB_WORKSPACE" --command bazelisk build //... --@scip_java//scip-javac:enabled=true - working-directory: examples/bazel-example - - run: nix develop "$GITHUB_WORKSPACE" --command bazelisk run @scip_java//scip-aggregator:bazel -- --sourceroot "$PWD" - working-directory: examples/bazel-example - - run: du -h index.scip - working-directory: examples/bazel-example + working-directory: ${{ matrix.directory }} bazel_aspect: runs-on: ubuntu-latest @@ -83,19 +94,15 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@v13 - - run: nix develop --command gradle :scip-java:installDist --no-daemon - - run: echo "$PWD/scip-java/build/install/scip-java/bin" >> "$GITHUB_PATH" + - run: gradle :scip-java:installDist --no-daemon + - run: printf 'SCIP_JAVA_CLI=%s\n' "$PWD/scip-java/build/install/scip-java/bin/scip-java" >> "$GITHUB_ENV" - name: Auto-index scip-java codebase run: | - # shellcheck disable=SC2016 - nix develop --command bash -c \ - 'scip-java index --build-tool=bazel --bazel-scip-java-binary=$(which scip-java)' + "$SCIP_JAVA_CLI" index --build-tool=bazel --bazel-scip-java-binary="$SCIP_JAVA_CLI" - run: du -h index.scip - name: Auto-index example/bazel-workspace run: | - # shellcheck disable=SC2016 - nix develop "$GITHUB_WORKSPACE" --command bash -c \ - 'scip-java index --build-tool=bazel --bazel-scip-java-binary=$(which scip-java)' + "$SCIP_JAVA_CLI" index --build-tool=bazel --bazel-scip-java-binary="$SCIP_JAVA_CLI" working-directory: examples/bazel-example - run: du -h index.scip working-directory: examples/bazel-example @@ -113,10 +120,22 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@v13 - name: scip-kotlinc tests - run: nix develop --command gradle :scip-kotlinc:test --no-daemon + run: gradle :scip-kotlinc:test --no-daemon + + snapshots: + runs-on: ubuntu-latest + name: Snapshots + steps: + - uses: actions/checkout@v4 + + - uses: DeterminateSystems/nix-installer-action@v22 + with: + summarize: false + + - uses: DeterminateSystems/magic-nix-cache-action@v13 - name: Regenerate snapshots - run: nix develop --command gradle :scip-snapshots:saveSnapshots --no-daemon + run: gradle :scip-snapshots:saveSnapshots --no-daemon - name: Check snapshot drift run: | @@ -125,7 +144,9 @@ jobs: maven: runs-on: ubuntu-latest - name: Maven tests + name: Maven tests (JDK ${{ matrix.java }}) + env: + NIX_DEVELOP: ${{ github.workspace }}#jdk${{ matrix.java }} strategy: fail-fast: false matrix: @@ -140,8 +161,7 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@v13 - run: | - nix develop .#jdk${{ matrix.java }} --command \ - gradle --no-daemon :scip-java:installDist publishToMavenLocal + gradle --no-daemon :scip-java:installDist publishToMavenLocal SCIP_JAVA_VERSION="$( sed -n 's/^version:=//p' scip-java/build/install/scip-java/VERSION )" @@ -149,16 +169,14 @@ jobs: printf 'SCIP_JAVA_VERSION=%s\n' "$SCIP_JAVA_VERSION" >> "$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 \ - mvn clean verify -DskipTests "-Dscip-java.version=$SCIP_JAVA_VERSION" sourcegraph:sourcegraphDependencies + - run: mvn clean verify -DskipTests "-Dscip-java.version=$SCIP_JAVA_VERSION" sourcegraph:sourcegraphDependencies working-directory: examples/maven-example - - run: nix develop "$GITHUB_WORKSPACE#jdk${{ matrix.java }}" --command "$SCIP_JAVA_CLI" aggregate target/scip-targetroot + - run: | + "$SCIP_JAVA_CLI" aggregate target/scip-targetroot working-directory: examples/maven-example - run: | - set -e grep org.hamcrest target/scip-targetroot/*dependencies.txt grep "$PWD/src/main/java" target/scip-targetroot/*dependencies.txt working-directory: examples/maven-example diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yaml similarity index 100% rename from .github/workflows/release-cli.yml rename to .github/workflows/release-cli.yaml diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yaml similarity index 100% rename from .github/workflows/release-docker.yml rename to .github/workflows/release-docker.yaml diff --git a/.github/workflows/release-maven.yml b/.github/workflows/release-maven.yaml similarity index 97% rename from .github/workflows/release-maven.yml rename to .github/workflows/release-maven.yaml index 78659fb0..b3763d59 100644 --- a/.github/workflows/release-maven.yml +++ b/.github/workflows/release-maven.yaml @@ -38,6 +38,6 @@ jobs: needs: publish permissions: contents: write - uses: ./.github/workflows/release-cli.yml + uses: ./.github/workflows/release-cli.yaml with: tag: ${{ github.ref_name }} diff --git a/flake.nix b/flake.nix index 53b054dc..da4285a0 100644 --- a/flake.nix +++ b/flake.nix @@ -45,7 +45,7 @@ { checks = { actionlint = pkgs.runCommand "check-actionlint" { } '' - ${pkgs.actionlint}/bin/actionlint ${./.github/workflows}/*.yml + ${pkgs.actionlint}/bin/actionlint ${./.github/workflows}/*.yaml touch $out ''; javafmt = pkgs.runCommand "check-javafmt" { } ''