Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/gradle/pl.allegro.tech.build.axio…
Browse files Browse the repository at this point in the history
…n-release-1.16.0
  • Loading branch information
big-andy-coates authored Dec 21, 2023
2 parents ae75008 + 703ca81 commit 3ee4d61
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 110 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ permissions:
contents: read

jobs:
build:
build_linux:
permissions:
packages: write
runs-on: ubuntu-latest
Expand All @@ -34,12 +34,12 @@ jobs:
if: (!startsWith(github.ref, 'refs/tags/'))
run: git fetch --tag --unshallow
- name: Set up JDK
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
java-version: '17'
distribution: 'adopt'
- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0
with:
gradle-home-cache-cleanup: true
- name: Build
Expand Down Expand Up @@ -67,9 +67,27 @@ jobs:
run: |
./gradlew -Dgradle.publish.key="$GRADLE_PUBLISH_KEY" -Dgradle.publish.secret="$GRADLE_PUBLISH_SECRET" publishPlugins
# Until Creek fully supports Windows, minimal check:
build_windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # v1.1.0
- name: Set up JDK
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
with:
java-version: '17'
distribution: 'adopt'
- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
with:
gradle-home-cache-cleanup: true
- name: Build
run: ./gradlew.bat build -PexcludeContainerised

create-gh-release:
if: startsWith(github.ref, 'refs/tags/') && !endsWith(github.ref, '-alpha')
needs: build
needs: [build_linux, build_windows]
runs-on: ubuntu-latest
permissions:
contents: write
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Initialize CodeQL
uses: github/codeql-action/init@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
uses: github/codeql-action/init@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8
with:
languages: ${{ matrix.language }}

- name: Set up JDK
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
java-version: '17'
distribution: 'adopt'

- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0
with:
gradle-home-cache-cleanup: true

- name: Build
run: ./gradlew test

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
uses: github/codeql-action/analyze@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8
4 changes: 2 additions & 2 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: gradle/wrapper-validation-action@56b90f209b02bf6d1deae490e9ef18b21a389cd4 # v1.1.0
- name: Set up JDK
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
java-version: '17'
distribution: 'adopt'
- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0
with:
dependency-graph: generate-and-submit
gradle-home-cache-cleanup: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ jobs:
- name: Fetch version history
run: git fetch --tags --unshallow
- name: Set up JDK
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
java-version: '17'
distribution: 'adopt'

- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0
with:
gradle-home-cache-cleanup: true
- name: Ensure build is green
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5
uses: github/codeql-action/upload-sarif@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8
with:
sarif_file: results.sarif
4 changes: 2 additions & 2 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ jobs:
- name: Fetch version history
run: git fetch --tags --unshallow
- name: Set up JDK
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0
with:
java-version: '17'
distribution: 'adopt'

- name: Setup Gradle
uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a # v2.9.0
uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0
with:
gradle-home-cache-cleanup: true
- name: Increment version
Expand Down
10 changes: 8 additions & 2 deletions buildSrc/src/main/kotlin/creek-common-convention.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
*
* <p>Apply to all java modules, usually excluding the root project in multi-module sets.
*
* <p>Version: 1.9
* <p>Versions:
* - 1.10: Add ability to exclude containerised tests
* - 1.9: Add `allDeps` task.
* - 1.8: Tweak test config to reduce build speed.
* - 1.7: Switch to setting Java version via toolchain
Expand Down Expand Up @@ -70,7 +71,12 @@ tasks.withType<JavaCompile> {
}

tasks.test {
useJUnitPlatform()
useJUnitPlatform() {
if (project.hasProperty("excludeContainerised")) {
excludeTags("ContainerisedTest")
}
}

setForkEvery(5)
maxParallelForks = Runtime.getRuntime().availableProcessors()
testLogging {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ publishing {
name.set("${project.group}:${artifactId}")

if (prependRootName) {
description.set("${rootProject.name.capitalize()} ${project.name} library".replace("-", " "))
description.set("${rootProject.name} ${project.name} library".replace("-", " "))
} else {
description.set("${project.name.capitalize()} library".replace("-", " "))
description.set("${project.name} library".replace("-", " "))
}

url.set("https://www.creekservice.org")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ publishing {
name.set("${project.group}:${artifactId}")

if (prependRootName) {
description.set("${rootProject.name.capitalize()} ${project.name} library".replace("-", " "))
description.set("${rootProject.name} ${project.name} library".replace("-", " "))
} else {
description.set("${project.name.capitalize()} library".replace("-", " "))
description.set("${project.name} library".replace("-", " "))
}

url.set("https://www.creekservice.org")
Expand Down
6 changes: 6 additions & 0 deletions config/spotbugs/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@
<!-- Exclude generated sources -->
<Source name="~.*[\\/]build[\\/]generated[\\/]source.*" />
</Match>

<Match>
<!-- Disable this check as it leads to longer names and harder to read code -->
<!-- Discussion: https://github.com/spotbugs/spotbugs/issues/2627 -->
<Bug pattern="PI_DO_NOT_REUSE_PUBLIC_IDENTIFIERS_CLASS_NAMES"/>
</Match>
</FindBugsFilter>

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import org.creekservice.api.observability.logging.structured.StructuredLogger;
import org.creekservice.api.observability.logging.structured.StructuredLoggerFactory;
import org.creekservice.api.platform.metadata.ComponentDescriptor;
import org.creekservice.api.platform.metadata.OwnedResource;
import org.creekservice.api.platform.metadata.ResourceDescriptor;
import org.creekservice.api.platform.metadata.ResourceHandler;
import org.creekservice.internal.platform.resource.ComponentValidator;

/**
Expand All @@ -58,38 +58,42 @@ public final class ResourceInitializer {
private static final StructuredLogger LOGGER =
StructuredLoggerFactory.internalLogger(ResourceInitializer.class);

private final ResourceHandlers handlers;
private final ResourceCreator resourceCreator;
private final ComponentValidator componentValidator;

/** Type for retrieving resource handlers */
/** Type for ensuring external resources exist */
@FunctionalInterface
public interface ResourceHandlers {
public interface ResourceCreator {

/**
* Get the handler for a specific type
* Get the handler for a specific type.
*
* @param type the type
* @param <T> the type
* @return the handler
* <p>All {@code creatableResources} will be of the same type.
*
* @param creatableResources the resource instances to ensure exists and are initialized.
* Resources passed will be {@link ResourceDescriptor#isCreatable creatable}.
* @param <T> the creatable resource descriptor type
* @throws RuntimeException on unknown resource type
*/
<T extends ResourceDescriptor> ResourceHandler<T> get(Class<T> type);
<T extends ResourceDescriptor & OwnedResource> void ensure(
Collection<T> creatableResources);
}

/**
* Create an initializer instance.
*
* @param handlers accessor to resource handlers, as exposed by Creek extensions.
* @param resourceCreator callback used to ensure external resources exist, as exposed by Creek
* extensions.
* @return an initializer instance.
*/
public static ResourceInitializer resourceInitializer(final ResourceHandlers handlers) {
return new ResourceInitializer(handlers, new ComponentValidator());
public static ResourceInitializer resourceInitializer(final ResourceCreator resourceCreator) {
return new ResourceInitializer(resourceCreator, new ComponentValidator());
}

@VisibleForTesting
ResourceInitializer(
final ResourceHandlers handlers, final ComponentValidator componentValidator) {
this.handlers = requireNonNull(handlers, "handlers");
final ResourceCreator resourceCreator, final ComponentValidator componentValidator) {
this.resourceCreator = requireNonNull(resourceCreator, "resourceCreator");
this.componentValidator = requireNonNull(componentValidator, "componentValidator");
}

Expand Down Expand Up @@ -173,12 +177,14 @@ public void test(
ensureResources(stream);
}

@SuppressWarnings({"unchecked", "rawtypes"})
private void ensureResources(final Stream<List<ResourceDescriptor>> resGroups) {
resGroups
.peek(this::validateResourceGroup)
.map(this::creatableDescriptor)
.collect(groupingBy(this::resourceHandler))
.forEach(ResourceHandler::ensure);
.collect(groupingBy(Object::getClass))
.values()
.forEach(creatableResources -> resourceCreator.ensure((List) creatableResources));
}

private ResourceDescriptor creatableDescriptor(final List<ResourceDescriptor> resGroup) {
Expand Down Expand Up @@ -237,11 +243,6 @@ private <T extends ResourceDescriptor> void validateResourceGroup(final List<T>
}
}

@SuppressWarnings("unchecked")
private <T extends ResourceDescriptor> ResourceHandler<T> resourceHandler(final T resource) {
return handlers.get((Class<T>) resource.getClass());
}

private static String formatResource(final List<? extends ResourceDescriptor> descriptors) {
return descriptors.stream()
.map(ResourceInitializer::formatResource)
Expand Down
Loading

0 comments on commit 3ee4d61

Please sign in to comment.