Skip to content
Draft
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
64 changes: 30 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,47 @@
# BUILDCACHE_USER
# BUILDCACHE_PASS
# - rw access to buildcache.diffplug.com

name: CI ♻️
on:
pull_request:
push:
branches: [main, release]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
sanity-check:
name: SanityCheck
name: SanityCheck 🕊️
runs-on: ubuntu-latest
env:
buildcacheuser: ${{ secrets.BUILDCACHE_USER }}
buildcachepass: ${{ secrets.BUILDCACHE_PASS }}
steps:
- name: Checkout
- name: Checkout 📥
uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-java@v5
- name: Setup Java ☕️
uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: 21
- name: gradle caching
- name: Gradle Caching 💾
uses: gradle/actions/setup-gradle@v5
- name: spotlessCheck
- name: Spotless Check ✨
run: ./gradlew spotlessCheck
- name: rewriteDryRun
- name: Rewrite Dry Run 🌀
run: ./gradlew rewriteDryRun
- name: assemble testClasses
- name: Assemble TestClasses ⚙️
run: ./gradlew assemble testClasses
build:
name: Build 🏗 ${{ matrix.kind }}️, Java ☕️ ${{ matrix.jre }}, OS 💿 ${{ matrix.os }}
needs: sanity-check
strategy:
fail-fast: false
matrix:
kind: [maven, gradle]
# Test on the latest Java version once Gradle & Maven support it.
jre: [17, 21, 24]
jre: [17, 21, 24] # Test on the latest Java version once Gradle & Maven support it.
os: [ubuntu-latest, windows-latest]
include:
# npm on linux only (crazy slow on windows)
include: # npm on linux only (crazy slow on windows)
- kind: npm
jre: 17
os: ubuntu-latest
Expand All @@ -58,36 +54,37 @@ jobs:
os: ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
- name: Checkout 📥
uses: actions/checkout@v6
- uses: actions/setup-java@v5
- name: Setup Java ☕️
uses: actions/setup-java@v5
with:
distribution: "temurin"
java-version: ${{ matrix.jre }}
- name: gradle caching
- name: Gradle Caching 💾
uses: gradle/actions/setup-gradle@v5
- name: build (maven-only)
- name: Build (Maven) 🏗️
if: matrix.kind == 'maven'
run: ./gradlew :plugin-maven:build -x spotlessCheck -x rewriteDryRun
- name: build (everything-but-maven)
- name: Build (Gradle) 🏗️
if: matrix.kind == 'gradle'
run: ./gradlew build -x spotlessCheck -x rewriteDryRun -PSPOTLESS_EXCLUDE_MAVEN=true
- name: test npm
- name: Test NPM 🧪
if: matrix.kind == 'npm'
run: ./gradlew testNpm
- name: Setup go
- name: Setup Go 🦫
if: matrix.kind == 'shfmt'
uses: actions/setup-go@v6
with:
go-version: 'stable'
- name: Install shfmt
- name: Install shfmt 🔧
if: matrix.kind == 'shfmt'
run: |
go install mvdan.cc/sh/v3/cmd/shfmt@${{ matrix.shfmt-version }}
- name: Test shfmt
- name: Test shfmt 🧪
if: matrix.kind == 'shfmt'
run: ./gradlew testShfmt
- name: Test idea
- name: Test IntelliJ IDEA 🧪
if: matrix.kind == 'idea'
run: |
download_link=$(curl https://data.services.jetbrains.com/products/releases\?code\=IIC\&latest\=true\&type\=release | jq -r '.IIC[0].downloads.linux.link')
Expand All @@ -97,27 +94,26 @@ jobs:
export PATH=${PATH}:$(pwd)/bin
cd ..
./gradlew testIdea
- name: junit result
- name: Test Results 📊
uses: mikepenz/action-junit-report@v6
if: always() # always run even if the previous step fails
with:
check_name: JUnit ${{ matrix.kind }} ${{ matrix.jre }} ${{ matrix.os }}
check_name: JUnit (Build 🏗 ${{ matrix.kind }}️, Java ☕️ ${{ matrix.jre }}, OS 💿 ${{ matrix.os }})
report_paths: '*/build/test-results/*/TEST-*.xml'
check_retries: true

# Status check that is required in branch protection rules.
final-status:
final-status: # Status check that is required in branch protection rules.
name: Final Status 🎯
needs:
- sanity-check
- build
runs-on: ubuntu-latest
if: always()
steps:
- name: Check
- name: Check All Jobs ✅
run: |
results=$(tr -d '\n' <<< '${{ toJSON(needs.*.result) }}')
if ! grep -q -v -E '(failure|cancelled)' <<< "$results"; then
echo "One or more required jobs failed"
echo "One or more required jobs failed"
exit 1
fi
echo "All required jobs completed successfully."
echo "All required jobs completed successfully."
14 changes: 7 additions & 7 deletions gradle/spotless.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ spotless {
if (project != rootProject) {
// the rootProject doesn't have any java
java {
ratchetFrom 'origin/main'
bumpThisNumberIfACustomStepChanges(1)
licenseHeaderFile rootProject.file('gradle/spotless.license')
importOrderFile rootProject.file('gradle/spotless.importorder')
eclipse().configFile rootProject.file('gradle/spotless.eclipseformat.xml')
trimTrailingWhitespace()
removeUnusedImports()
formatAnnotations()
forbidWildcardImports()
forbidRegex('ForbidGradleInternal', 'import org\\.gradle\\.api\\.internal\\.(.*)', "Don't use Gradle's internal API")
forbidWildcardImports()
formatAnnotations()
importOrderFile rootProject.file('gradle/spotless.importorder')
licenseHeaderFile rootProject.file('gradle/spotless.license')
ratchetFrom 'origin/main'
removeUnusedImports()
trimTrailingWhitespace()
}
}
groovyGradle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
package com.diffplug.spotless.extra;

import static com.diffplug.spotless.FileSignature.pathNativeToUnix;
import static org.eclipse.jgit.treewalk.TreeWalk.forPath;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
Expand Down Expand Up @@ -45,7 +48,6 @@
import com.diffplug.common.base.Errors;
import com.diffplug.common.collect.HashBasedTable;
import com.diffplug.common.collect.Table;
import com.diffplug.spotless.FileSignature;

/**
* How to use:
Expand All @@ -57,9 +59,7 @@
public abstract class GitRatchet<Project> implements AutoCloseable {

public boolean isClean(Project project, ObjectId treeSha, File file) throws IOException {
Repository repo = repositoryFor(project);
String relativePath = FileSignature.pathNativeToUnix(repo.getWorkTree().toPath().relativize(file.toPath()).toString());
return isClean(project, treeSha, relativePath);
return isClean(project, treeSha, pathNativeToUnix(repositoryFor(project).getWorkTree().toPath().relativize(file.toPath()).toString()));
}

private final Map<Repository, DirCache> dirCaches = new HashMap<>();
Expand Down Expand Up @@ -210,8 +210,7 @@ public synchronized ObjectId subtreeShaOf(Project project, ObjectId rootTreeSha)
if (repo.getWorkTree().equals(directory)) {
subtreeSha = rootTreeSha;
} else {
String subpath = FileSignature.pathNativeToUnix(repo.getWorkTree().toPath().relativize(directory.toPath()).toString());
TreeWalk treeWalk = TreeWalk.forPath(repo, subpath, rootTreeSha);
TreeWalk treeWalk = forPath(repo, pathNativeToUnix(repo.getWorkTree().toPath().relativize(directory.toPath()).toString()), rootTreeSha);
subtreeSha = treeWalk == null ? ObjectId.zeroId() : treeWalk.getObjectId(0);
}
subtreeShaCache.put(project, subtreeSha.copy());
Expand Down
Loading