Skip to content

Commit 7cc87da

Browse files
authored
Fixup our CI (#988)
2 parents f52f7fd + 8f5f0aa commit 7cc87da

File tree

11 files changed

+50
-19
lines changed

11 files changed

+50
-19
lines changed

.circleci/config.yml

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ anchors:
4444
path: plugin-gradle/build/test-results/test
4545
jobs:
4646
# gradlew spotlessCheck assemble testClasses
47-
assemble_testClasses:
47+
assemble_testClasses:
4848
<<: *env_gradle_large
4949
steps:
5050
- checkout
@@ -102,23 +102,37 @@ jobs:
102102
name: gradlew npmTest
103103
command: ./gradlew npmTest --build-cache
104104
- store_test_results:
105-
path: testlib/build/test-results/npm
105+
path: testlib/build/test-results/NpmTest
106106
- store_test_results:
107-
path: plugin-maven/build/test-results/npm
107+
path: plugin-maven/build/test-results/NpmTest
108108
- store_test_results:
109-
path: plugin-gradle/build/test-results/npm
109+
path: plugin-gradle/build/test-results/NpmTest
110+
- run:
111+
name: gradlew check
112+
command: export SPOTLESS_EXCLUDE_MAVEN=true && ./gradlew check --build-cache
113+
- store_test_results:
114+
path: testlib/build/test-results/test
115+
- store_test_results:
116+
path: lib-extra/build/test-results/test
117+
- store_test_results:
118+
path: plugin-gradle/build/test-results/test
119+
- store_artifacts:
120+
path: lib/build/spotbugs
121+
- store_artifacts:
122+
path: lib-extra/build/spotbugs
123+
- store_artifacts:
124+
path: testlib/build/spotbugs
125+
- store_artifacts:
126+
path: plugin-gradle/build/spotbugs
110127
test_windows:
111128
executor:
112129
name: win/default
113130
shell: cmd.exe
114131
steps:
115132
- checkout
116133
- run:
117-
name: install
118-
command: choco install ojdkbuild8
119-
- run:
120-
name: gradlew check
121-
command: gradlew check --build-cache -PSPOTLESS_EXCLUDE_MAVEN=true
134+
name: gradlew test
135+
command: gradlew test --build-cache -PSPOTLESS_EXCLUDE_MAVEN=true
122136
- store_test_results:
123137
path: testlib/build/test-results/test
124138
- store_test_results:
@@ -129,9 +143,9 @@ jobs:
129143
name: gradlew npmTest
130144
command: gradlew npmTest --build-cache -PSPOTLESS_EXCLUDE_MAVEN=true
131145
- store_test_results:
132-
path: testlib/build/test-results/npm
146+
path: testlib/build/test-results/NpmTest
133147
- store_test_results:
134-
path: plugin-gradle/build/test-results/npm
148+
path: plugin-gradle/build/test-results/NpmTest
135149
changelog_print:
136150
<< : *env_gradle
137151
steps:

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1212
## [Unreleased]
1313
### Added
1414
* `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)).
15+
### Fixed
16+
* Fix CI and various spotbugs nits ([#988](https://github.com/diffplug/spotless/pull/988)).
1517

1618
## [2.19.2] - 2021-10-26
1719
### Changed

gradle/special-tests.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1+
apply plugin: 'org.gradle.test-retry'
2+
13
def special = [
24
'Npm',
35
'Black',
46
'Clang'
57
]
68

9+
boolean isCiServer = System.getenv().containsKey("CI")
710
tasks.named('test') {
811
// See com.diffplug.spotless.tag package for available JUnit 5 @Tag annotations
912
useJUnitPlatform {
1013
excludeTags special as String[]
1114
}
15+
if (isCiServer) {
16+
retry {
17+
maxRetries = 1
18+
maxFailures = 2
19+
}
20+
}
1221
}
1322

1423
special.forEach { tag ->

lib-extra/src/main/java/com/diffplug/spotless/extra/integration/DiffMessageFormatter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ public Charset getEncoding() {
102102

103103
@Override
104104
public String getFormatted(File file, String rawUnix) {
105-
Path relative = rootDir.relativize(file.toPath());
106105
Path clean = cleanDir.resolve(rootDir.relativize(file.toPath()));
107106
byte[] content = Errors.rethrow().get(() -> Files.readAllBytes(clean));
108107
return new String(content, encoding);

lib/src/main/java/com/diffplug/spotless/Jvm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public int compare(V version0, V version1) {
242242

243243
private static <V> int[] convert(V versionObject) {
244244
try {
245-
return Arrays.asList(versionObject.toString().split("\\.")).stream().mapToInt(s -> Integer.valueOf(s)).toArray();
245+
return Arrays.asList(versionObject.toString().split("\\.")).stream().mapToInt(Integer::parseInt).toArray();
246246
} catch (Exception e) {
247247
throw new IllegalArgumentException(String.format("Not a semantic version: %s", versionObject), e);
248248
}

lib/src/main/java/com/diffplug/spotless/java/ImportSorterImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.diffplug.spotless.java;
1717

18+
import java.io.Serializable;
1819
import java.util.*;
1920

2021
import javax.annotation.Nullable;
@@ -256,7 +257,9 @@ private List<String> getResult(String lineFormat) {
256257
return null;
257258
}
258259

259-
private static class OrderingComparator implements Comparator<String> {
260+
private static class OrderingComparator implements Comparator<String>, Serializable {
261+
private static final long serialVersionUID = 1;
262+
260263
private final boolean wildcardsLast;
261264

262265
private OrderingComparator(boolean wildcardsLast) {

lib/src/main/java/com/diffplug/spotless/npm/PrettierFormatterStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public FormatterFunc createFormatterFunc() {
8585
PrettierRestService restService = new PrettierRestService(prettierRestServer.getBaseUrl());
8686
String prettierConfigOptions = restService.resolveConfig(this.prettierConfig.getPrettierConfigPath(), this.prettierConfig.getOptions());
8787
return Closeable.ofDangerous(() -> endServer(restService, prettierRestServer), new PrettierFilePathPassingFormatterFunc(prettierConfigOptions, restService));
88-
} catch (Exception e) {
88+
} catch (IOException e) {
8989
throw ThrowingEx.asRuntime(e);
9090
}
9191
}

lib/src/main/java/com/diffplug/spotless/npm/TsFmtFormatterStep.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2020 DiffPlug
2+
* Copyright 2016-2021 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -92,7 +92,7 @@ public FormatterFunc createFormatterFunc() {
9292
ServerProcessInfo tsfmtRestServer = npmRunServer();
9393
TsFmtRestService restService = new TsFmtRestService(tsfmtRestServer.getBaseUrl());
9494
return Closeable.ofDangerous(() -> endServer(restService, tsfmtRestServer), input -> restService.format(input, tsFmtOptions));
95-
} catch (Exception e) {
95+
} catch (IOException e) {
9696
throw ThrowingEx.asRuntime(e);
9797
}
9898
}

lib/src/main/java/com/diffplug/spotless/pom/SortPomStep.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ public class SortPomStep {
3030

3131
private SortPomStep() {}
3232

33-
private SortPomCfg cfg;
34-
3533
public static FormatterStep create(SortPomCfg cfg, Provisioner provisioner) {
3634
return FormatterStep.createLazy(NAME, () -> new State(cfg, provisioner), State::createFormat);
3735
}
3836

3937
static class State implements Serializable {
38+
private static final long serialVersionUID = 1;
39+
4040
SortPomCfg cfg;
4141
JarState jarState;
4242

settings.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pluginManagement {
1111
id 'com.diffplug.spotless-changelog' version '2.2.0'
1212
// https://github.com/diffplug/goomph/blob/main/CHANGES.md
1313
id 'com.diffplug.p2.asmaven' version '3.33.2'
14+
// https://github.com/gradle/test-retry-gradle-plugin/releases
15+
id 'org.gradle.test-retry' version '1.3.1'
1416
}
1517
}
1618
plugins {
@@ -20,6 +22,7 @@ plugins {
2022
id 'com.github.spotbugs' apply false
2123
id 'com.diffplug.spotless-changelog' apply false
2224
id 'com.diffplug.p2.asmaven' apply false
25+
id 'org.gradle.test-retry' apply false
2326
}
2427
if (System.env['CI'] != null) {
2528
// use the remote buildcache on all CI builds

0 commit comments

Comments
 (0)