Skip to content

Commit

Permalink
Fixup our CI (#988)
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg authored Nov 9, 2021
2 parents f52f7fd + 8f5f0aa commit 7cc87da
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 19 deletions.
36 changes: 25 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ anchors:
path: plugin-gradle/build/test-results/test
jobs:
# gradlew spotlessCheck assemble testClasses
assemble_testClasses:
assemble_testClasses:
<<: *env_gradle_large
steps:
- checkout
Expand Down Expand Up @@ -102,23 +102,37 @@ jobs:
name: gradlew npmTest
command: ./gradlew npmTest --build-cache
- store_test_results:
path: testlib/build/test-results/npm
path: testlib/build/test-results/NpmTest
- store_test_results:
path: plugin-maven/build/test-results/npm
path: plugin-maven/build/test-results/NpmTest
- store_test_results:
path: plugin-gradle/build/test-results/npm
path: plugin-gradle/build/test-results/NpmTest
- run:
name: gradlew check
command: export SPOTLESS_EXCLUDE_MAVEN=true && ./gradlew check --build-cache
- store_test_results:
path: testlib/build/test-results/test
- store_test_results:
path: lib-extra/build/test-results/test
- store_test_results:
path: plugin-gradle/build/test-results/test
- store_artifacts:
path: lib/build/spotbugs
- store_artifacts:
path: lib-extra/build/spotbugs
- store_artifacts:
path: testlib/build/spotbugs
- store_artifacts:
path: plugin-gradle/build/spotbugs
test_windows:
executor:
name: win/default
shell: cmd.exe
steps:
- checkout
- run:
name: install
command: choco install ojdkbuild8
- run:
name: gradlew check
command: gradlew check --build-cache -PSPOTLESS_EXCLUDE_MAVEN=true
name: gradlew test
command: gradlew test --build-cache -PSPOTLESS_EXCLUDE_MAVEN=true
- store_test_results:
path: testlib/build/test-results/test
- store_test_results:
Expand All @@ -129,9 +143,9 @@ jobs:
name: gradlew npmTest
command: gradlew npmTest --build-cache -PSPOTLESS_EXCLUDE_MAVEN=true
- store_test_results:
path: testlib/build/test-results/npm
path: testlib/build/test-results/NpmTest
- store_test_results:
path: plugin-gradle/build/test-results/npm
path: plugin-gradle/build/test-results/NpmTest
changelog_print:
<< : *env_gradle
steps:
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
## [Unreleased]
### Added
* `DiffMessageFormatter` can now generate messages based on a folder of cleaned files, as an alternative to a `Formatter` ([#982](https://github.com/diffplug/spotless/pull/982)).
### Fixed
* Fix CI and various spotbugs nits ([#988](https://github.com/diffplug/spotless/pull/988)).

## [2.19.2] - 2021-10-26
### Changed
Expand Down
9 changes: 9 additions & 0 deletions gradle/special-tests.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
apply plugin: 'org.gradle.test-retry'

def special = [
'Npm',
'Black',
'Clang'
]

boolean isCiServer = System.getenv().containsKey("CI")
tasks.named('test') {
// See com.diffplug.spotless.tag package for available JUnit 5 @Tag annotations
useJUnitPlatform {
excludeTags special as String[]
}
if (isCiServer) {
retry {
maxRetries = 1
maxFailures = 2
}
}
}

special.forEach { tag ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public Charset getEncoding() {

@Override
public String getFormatted(File file, String rawUnix) {
Path relative = rootDir.relativize(file.toPath());
Path clean = cleanDir.resolve(rootDir.relativize(file.toPath()));
byte[] content = Errors.rethrow().get(() -> Files.readAllBytes(clean));
return new String(content, encoding);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/java/com/diffplug/spotless/Jvm.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public int compare(V version0, V version1) {

private static <V> int[] convert(V versionObject) {
try {
return Arrays.asList(versionObject.toString().split("\\.")).stream().mapToInt(s -> Integer.valueOf(s)).toArray();
return Arrays.asList(versionObject.toString().split("\\.")).stream().mapToInt(Integer::parseInt).toArray();
} catch (Exception e) {
throw new IllegalArgumentException(String.format("Not a semantic version: %s", versionObject), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.diffplug.spotless.java;

import java.io.Serializable;
import java.util.*;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -256,7 +257,9 @@ private List<String> getResult(String lineFormat) {
return null;
}

private static class OrderingComparator implements Comparator<String> {
private static class OrderingComparator implements Comparator<String>, Serializable {
private static final long serialVersionUID = 1;

private final boolean wildcardsLast;

private OrderingComparator(boolean wildcardsLast) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public FormatterFunc createFormatterFunc() {
PrettierRestService restService = new PrettierRestService(prettierRestServer.getBaseUrl());
String prettierConfigOptions = restService.resolveConfig(this.prettierConfig.getPrettierConfigPath(), this.prettierConfig.getOptions());
return Closeable.ofDangerous(() -> endServer(restService, prettierRestServer), new PrettierFilePathPassingFormatterFunc(prettierConfigOptions, restService));
} catch (Exception e) {
} catch (IOException e) {
throw ThrowingEx.asRuntime(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 DiffPlug
* Copyright 2016-2021 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -92,7 +92,7 @@ public FormatterFunc createFormatterFunc() {
ServerProcessInfo tsfmtRestServer = npmRunServer();
TsFmtRestService restService = new TsFmtRestService(tsfmtRestServer.getBaseUrl());
return Closeable.ofDangerous(() -> endServer(restService, tsfmtRestServer), input -> restService.format(input, tsFmtOptions));
} catch (Exception e) {
} catch (IOException e) {
throw ThrowingEx.asRuntime(e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/main/java/com/diffplug/spotless/pom/SortPomStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public class SortPomStep {

private SortPomStep() {}

private SortPomCfg cfg;

public static FormatterStep create(SortPomCfg cfg, Provisioner provisioner) {
return FormatterStep.createLazy(NAME, () -> new State(cfg, provisioner), State::createFormat);
}

static class State implements Serializable {
private static final long serialVersionUID = 1;

SortPomCfg cfg;
JarState jarState;

Expand Down
3 changes: 3 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ pluginManagement {
id 'com.diffplug.spotless-changelog' version '2.2.0'
// https://github.com/diffplug/goomph/blob/main/CHANGES.md
id 'com.diffplug.p2.asmaven' version '3.33.2'
// https://github.com/gradle/test-retry-gradle-plugin/releases
id 'org.gradle.test-retry' version '1.3.1'
}
}
plugins {
Expand All @@ -20,6 +22,7 @@ plugins {
id 'com.github.spotbugs' apply false
id 'com.diffplug.spotless-changelog' apply false
id 'com.diffplug.p2.asmaven' apply false
id 'org.gradle.test-retry' apply false
}
if (System.env['CI'] != null) {
// use the remote buildcache on all CI builds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ protected FormatterStep create() {
}

@Test
@EnabledForJreRange(min = JAVA_11) // google-java-format requires JRE 11+
void equalityGroupArtifact() throws Exception {
new SerializableEqualityTester() {
String groupArtifact = GoogleJavaFormatStep.defaultGroupArtifact();
Expand Down

0 comments on commit 7cc87da

Please sign in to comment.