Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#515: Implement auto dependency update #522

Merged
merged 88 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 87 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
37ceb72
Upgrade GitHub actions
kaklakariada Jan 25, 2024
156dc87
Remove unnecessary dependency override
kaklakariada Jan 25, 2024
99a3d02
Increment version
kaklakariada Jan 25, 2024
cfcb144
#515: Requirements & design
kaklakariada Jan 25, 2024
180eb1f
Upgrade dependencies
kaklakariada Jan 25, 2024
cd7fd11
Fix eclipse config file
kaklakariada Jan 25, 2024
8a55880
Mark other eclipse config file as generated
kaklakariada Jan 26, 2024
3d891e3
Fix tracing
kaklakariada Jan 26, 2024
c6afdf9
#515 Add design
kaklakariada Jan 26, 2024
221b083
Add diagrams
kaklakariada Jan 26, 2024
22606f2
Fix typos
kaklakariada Jan 26, 2024
8123673
Add diagrams to design document
kaklakariada Jan 26, 2024
8a7c408
Update diagrams
kaklakariada Jan 26, 2024
3a7b47c
Add requirements for customizing workflows
kaklakariada Jan 29, 2024
78de957
Implement review findings for diagrams
kaklakariada Jan 29, 2024
8a8dbfa
Customize release artifacts
kaklakariada Jan 29, 2024
71e4b2d
Disable tracing into sources for unimplemented requirements
kaklakariada Jan 29, 2024
6029d61
Fail on compiler warnings
kaklakariada Jan 29, 2024
92f7943
#515: Increment version
kaklakariada Jan 29, 2024
cb8b942
Fix logging in Maven Mojo test
kaklakariada Jan 30, 2024
30590fc
Fix javadoc
kaklakariada Jan 30, 2024
d75ade4
Fix error code crawler
kaklakariada Jan 30, 2024
094c120
Add missing javadoc comments
kaklakariada Jan 30, 2024
8a997e9
Adapt unit test to new error message
kaklakariada Jan 30, 2024
b45c1d2
Fix integration tests
kaklakariada Jan 30, 2024
b214f0b
Add test for updating dependencies via CLI
kaklakariada Jan 30, 2024
27fd6fd
Configure versions plugin
kaklakariada Jan 30, 2024
9d19744
Allow updating dependencies in parent pom
kaklakariada Jan 30, 2024
82fc68b
Exclude slf4j from upgrading
kaklakariada Jan 30, 2024
5a57463
Add user guide entries
kaklakariada Jan 30, 2024
40c174e
Remove debug code
kaklakariada Jan 30, 2024
4880363
Simplify test
kaklakariada Jan 30, 2024
45201b6
Extract Maven process builder
kaklakariada Jan 30, 2024
5fc7c70
Add integration test for updating dependencies
kaklakariada Jan 30, 2024
30b07e5
Configure versions plugin
kaklakariada Jan 30, 2024
e66ea89
Fix jgit version
kaklakariada Jan 30, 2024
34e8592
Run dependency update & PK fix
kaklakariada Jan 30, 2024
0addf51
Move ChangesFileName to separate file
kaklakariada Jan 30, 2024
435d6b9
Remove unused methods
kaklakariada Jan 30, 2024
00fd12a
Generate first line separately
kaklakariada Jan 30, 2024
022a555
Allow specifying code name, summary & dependency changes for ChangesFile
kaklakariada Jan 31, 2024
1f01a2b
Fix javadoc & error codes
kaklakariada Jan 31, 2024
678ab31
Remove unwanted import
kaklakariada Jan 31, 2024
e144e11
Refactor project crawler runner
kaklakariada Jan 31, 2024
a62cee9
Update references after incrementing the version
kaklakariada Jan 31, 2024
5f6cd41
Fix error message
kaklakariada Jan 31, 2024
5e30b36
Fix javadoc
kaklakariada Jan 31, 2024
eff0e29
Use \n as line separator for changes file
kaklakariada Jan 31, 2024
f262f4e
Copy codename when fixing changes file
kaklakariada Jan 31, 2024
562db8c
Fix failing tests
kaklakariada Jan 31, 2024
7e5c139
Fix windows tests
kaklakariada Jan 31, 2024
ef6c30b
Adapt error message to windows
kaklakariada Jan 31, 2024
a69afaf
Fix integration test for windows
kaklakariada Feb 1, 2024
56ad0d2
Remove unused code
kaklakariada Feb 1, 2024
912573b
Dependency upgrade process
kaklakariada Feb 1, 2024
440f754
Merge remote-tracking branch 'origin/main' into feature/#515-dependen…
kaklakariada Feb 1, 2024
9f86d24
Increase timeout
kaklakariada Feb 1, 2024
b3c51f1
Remove duplicate files
kaklakariada Feb 7, 2024
db954a6
Upgrade dependencies
kaklakariada Feb 7, 2024
d354a61
#515: Refactoring
kaklakariada Feb 7, 2024
9543d51
Fix compiler warnings
kaklakariada Feb 7, 2024
4151a47
Merge branch 'step1' into #515-step2-refactoring
kaklakariada Feb 7, 2024
346ddec
Merge remote-tracking branch 'origin/main' into #515-step2-refactoring
kaklakariada Feb 8, 2024
2045a90
Fix compile errors
kaklakariada Feb 8, 2024
33480d1
Add trailing newline
kaklakariada Feb 8, 2024
d8f8d30
Merge branch '#515-step2-refactoring' into feature/#515-dependency-up…
kaklakariada Feb 8, 2024
0ad2a27
Fix compile errors
kaklakariada Feb 8, 2024
8628d0f
Parse changesfile
kaklakariada Feb 8, 2024
c846632
Merge branch '#515-parse-changes-file' into feature/#515-dependency-u…
kaklakariada Feb 8, 2024
3957554
Fix sonar warning
kaklakariada Feb 8, 2024
90196d8
Add unit tests for version incrementor
kaklakariada Feb 8, 2024
e470666
Use command executor
kaklakariada Feb 8, 2024
8e7d22b
Add assertion for maven command
kaklakariada Feb 8, 2024
59560c9
Merge remote-tracking branch 'origin/main' into #515-parse-changes-file
kaklakariada Feb 8, 2024
9319f9f
Merge remote-tracking branch 'origin/#515-parse-changes-file' into fe…
kaklakariada Feb 8, 2024
8d24d1b
Merge remote-tracking branch 'origin/main' into feature/#515-dependen…
kaklakariada Feb 8, 2024
aa9f7f3
Fix test for windows
kaklakariada Feb 8, 2024
e5e4a4d
Refactor command executor
kaklakariada Feb 8, 2024
d348f15
Add unit tests
kaklakariada Feb 8, 2024
029b56b
Add comments
kaklakariada Feb 8, 2024
8208046
Code cleanup
kaklakariada Feb 8, 2024
84b1492
Merge branch '#515-refactor-process-execution' into feature/#515-depe…
kaklakariada Feb 8, 2024
83701de
Add unit tests
kaklakariada Feb 9, 2024
757ed2a
Merge branch 'main' into feature/#515-dependency-upgrade
kaklakariada Feb 9, 2024
a25e355
Improve test coverage
kaklakariada Feb 9, 2024
24b62bd
Run PK fix
kaklakariada Feb 9, 2024
340dad5
Implement review findings
kaklakariada Feb 22, 2024
6f7f870
Fix error code
kaklakariada Feb 22, 2024
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
66 changes: 34 additions & 32 deletions dependencies.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions doc/changes/changes_4.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Code name: Automatic Security Updates

* Updated `com.exasol:project-keeper-shared-test-setup:3.0.1` to `4.0.0`
* Updated `nl.jqno.equalsverifier:equalsverifier:3.15.4` to `3.15.6`
* Added `org.junit-pioneer:junit-pioneer:2.2.0`
* Updated `org.junit.jupiter:junit-jupiter-engine:5.10.1` to `5.10.2`
* Updated `org.junit.jupiter:junit-jupiter-params:5.10.1` to `5.10.2`
* Updated `org.mockito:mockito-junit-jupiter:5.8.0` to `5.10.0`
Expand Down
14 changes: 14 additions & 0 deletions doc/user_guide/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,12 @@ In addition this plugin can also fix the project structure. For that use:
mvn project-keeper:fix
```

Run the following commands to update dependencies:

```sh
mvn project-keeper:update-dependencies
```

For multi-module projects these commands may fail with the following error:

```
Expand All @@ -279,6 +285,7 @@ In this case add command line option `--projects .`:
```sh
mvn project-keeper:verify --projects .
mvn project-keeper:fix --projects .
mvn project-keeper:update-dependencies --projects .
```

You can skip the execution of project-keeper by adding `-Dproject-keeper.skip=true` to your maven command.
Expand All @@ -301,6 +308,13 @@ cd path/to/project
java -jar path/to/project-keeper-cli-2.7.1.jar fix
```

Run the following commands to update dependencies:

```sh
cd path/to/project
java -jar path/to/project-keeper-cli-2.7.1.jar update-dependencies
```

### Project Version

PK needs to know about the overall version of the project. For example for validating it in the changes file. For single source projects, PK simply takes the version from the project. For other projects you can:
Expand Down
6 changes: 6 additions & 0 deletions parent-pom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@
<version>1.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit-pioneer</groupId>
<artifactId>junit-pioneer</artifactId>
<version>2.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.InputStream;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Map;
import java.util.logging.*;

import com.exasol.errorreporting.ExaError;
Expand All @@ -19,6 +20,12 @@ public class ProjectKeeperLauncher {
private static final Logger LOGGER = Logger.getLogger(ProjectKeeperLauncher.class.getName());
private static final String GOAL_VERIFY = "verify";
private static final String GOAL_FIX = "fix";
private static final String GOAL_UPDATE_DEPENDENCIES = "update-dependencies";
private static final Map<String, ProjectKeeperGoal> ACCEPT_GOALS = Map.of( //
GOAL_VERIFY, ProjectKeeper::verify, //
GOAL_FIX, ProjectKeeper::fix, //
GOAL_UPDATE_DEPENDENCIES, ProjectKeeper::updateDependencies //
);

private final Path currentWorkingDir;

Expand Down Expand Up @@ -60,23 +67,36 @@ void start(final String[] args) {

private void runProjectKeeper(final String goal) {
final ProjectKeeper projectKeeper = createProjectKeeper();
final boolean success = goal.equals(GOAL_FIX) ? projectKeeper.fix() : projectKeeper.verify();
final ProjectKeeperGoal method = getProjectKeeperGoal(goal);
final boolean success = method.execute(projectKeeper);
if (!success) {
throw new IllegalStateException(
ExaError.messageBuilder("E-PK-CLI-1").message("Failed to run project keeper {{goal}}", goal)
.mitigation("See log messages above for details.").toString());
}
}

private ProjectKeeperGoal getProjectKeeperGoal(final String goal) {
final ProjectKeeperGoal failure = pk -> {
LOGGER.warning(() -> ExaError.messageBuilder("goal").message("Goal {{goal}} not supported.", goal)
.mitigation("Use one of the supported goals: {{supported goals}}", ACCEPT_GOALS.keySet())
.toString());
return false;
};
return ACCEPT_GOALS.getOrDefault(goal, failure);
}

private ProjectKeeper createProjectKeeper() {
return ProjectKeeper.createProjectKeeper(new JULLogger(), this.currentWorkingDir, null);
}

private void verifyCommandLineArguments(final String[] args) {
if ((args == null) || (args.length != 1) || !(GOAL_FIX.equals(args[0]) || GOAL_VERIFY.equals(args[0]))) {
if ((args == null) || (args.length != 1) || !(GOAL_FIX.equals(args[0]) || GOAL_VERIFY.equals(args[0])
|| GOAL_UPDATE_DEPENDENCIES.equals(args[0]))) {
throw new IllegalArgumentException(ExaError.messageBuilder("E-PK-CLI-2")
.message("Got no or invalid command line argument {{arguments}}.", Arrays.toString(args))
.mitigation("Please only specify arguments '" + GOAL_VERIFY + "' or '" + GOAL_FIX + "'.")
.mitigation("Please only specify arguments '" + GOAL_VERIFY + "', '" + GOAL_FIX + "' or '"
+ GOAL_UPDATE_DEPENDENCIES + "'.")
.toString());
}
}
Expand All @@ -97,4 +117,9 @@ public void error(final String message) {
LOGGER.severe(message);
}
}

@FunctionalInterface
private interface ProjectKeeperGoal {
boolean execute(ProjectKeeper projectKeeper);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ static Stream<Arguments> invalidArguments() {
@MethodSource("invalidArguments")
void failsForWrongArguments(final String... args) throws IOException, InterruptedException {
assertProcessFails(args, "E-PK-CLI-2: Got no or invalid command line argument '" + Arrays.toString(args)
+ "'. Please only specify arguments 'verify' or 'fix'.");
+ "'. Please only specify arguments 'verify', 'fix' or 'update-dependencies'.");
}

@Test
void runMainMethodWithNullArgumentFails() throws IOException, InterruptedException {
final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class,
() -> ProjectKeeperLauncher.main(null));
assertThat(exception.getMessage(), equalTo(
"E-PK-CLI-2: Got no or invalid command line argument 'null'. Please only specify arguments 'verify' or 'fix'."));
"E-PK-CLI-2: Got no or invalid command line argument 'null'. Please only specify arguments 'verify', 'fix' or 'update-dependencies'."));
}

@Test
Expand All @@ -68,6 +68,13 @@ void fixingJavaProjectSucceeds() throws InterruptedException, IOException {
assertProcessSucceeds("verify");
}

@Test
void updateDependenciesJavaProjectSucceeds() throws InterruptedException, IOException {
prepareMavenProject();
assertProcessSucceeds("fix");
assertProcessSucceeds("update-dependencies");
}

@Test
void fixingGolangProjectSucceeds() throws InterruptedException, IOException {
prepareGolangProject();
Expand Down
Loading
Loading