Skip to content

Commit

Permalink
Fail a build if it does not meet the checkstyle requirements (#70)
Browse files Browse the repository at this point in the history
This resolves #64, however it proposes a different approach. Instead of
creating a new GitHub Action, it changes the settings of the checkstyle
plugin so that it does not permit any error and warnings.
  • Loading branch information
DawidNiezgodka authored Sep 8, 2022
1 parent ac83d34 commit c41d7df
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 22 deletions.
10 changes: 9 additions & 1 deletion .github/actions/test-source/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ runs:
restore-keys: |
${{ runner.os }}-gradle-
- name: checkstyle main
shell: bash
run: ./gradlew checkstyleMain

- name: checkstyle test
shell: bash
run: ./gradlew checkstyleTest

- name: Run unit tests
shell: bash
run: ./gradlew unitTest

- name: Run integration tests
shell: bash
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,15 @@ class QuickCodeQualityPlugin : Plugin<Project> {
project.plugins.apply(CheckstylePlugin::class)
project.configure<CheckstyleExtension> {
this.toolVersion = CHECKSTYLE_VERSION
this.isIgnoreFailures = false
this.maxErrors = 0
this.maxWarnings = 0

}

tasks.withType(Checkstyle::class) {
group = CODE_QUALITY_GROUP
source = fileTree("src/main/java")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* <h2>Example:</h2>
* <pre>{@code
* type Query {
* findPurchases(purchaseId: [ID]): [Purchase] @topic(name: "purchase-topic", keyArgument: "purchaseId") # <- list argument fetcher
* findPurchases(purchaseId: [ID]): [Purchase] @topic(name: "purchase-topic", keyArgument: "purchaseId")
* }
*
* type Purchase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* <h2>Example:</h2>
* <pre>{@code
* type Query {
* findPurchases(purchaseId: [ID]): [Purchase] @topic(name: "purchase-topic", keyArgument: "purchaseId") # <- query list fetcher
* findPurchases(purchaseId: [ID]): [Purchase] @topic(name: "purchase-topic", keyArgument: "purchaseId")
* }
*
* type Purchase {
Expand Down Expand Up @@ -70,7 +70,6 @@ public ListArgumentFetcher(final String argument,

@Override
@Nullable
@SuppressWarnings("unchecked")
public List<V> get(final DataFetchingEnvironment environment) {
final Object arguments = DeferFetcher.getArgument(this.argument, environment)
.orElseThrow(() -> new RuntimeException("Could not find argument " + this.argument));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@ public class KafkaTopicService implements TopicService {
* Injectable constructor.
*
* @param topicRegistryClient client for interacting with Quick's topic registry
* @param gatewayClient client for interacting with Quick's gateways
* @param graphQLConverter converter from GraphQL schema to Kafka schema
* @param mirrorService service for creating mirrors
* @param gatewayService service for interacting with deployed gateway
* @param topicConfig configuration for Kafka topics
* @param kafkaConfig configuration for Kafka
* @param gatewayClient client for interacting with Quick's gateways
* @param graphQLConverter converter from GraphQL schema to Kafka schema
* @param mirrorService service for creating mirrors
* @param gatewayService service for interacting with deployed gateway
* @param topicConfig configuration for Kafka topics
* @param kafkaConfig configuration for Kafka
*/

public KafkaTopicService(final TopicRegistryClient topicRegistryClient, final GatewayClient gatewayClient,
final GraphQLConverter graphQLConverter, final MirrorService mirrorService,
final GatewayService gatewayService, final QuickTopicConfig topicConfig,
final KafkaConfig kafkaConfig) {
final GraphQLConverter graphQLConverter, final MirrorService mirrorService,
final GatewayService gatewayService, final QuickTopicConfig topicConfig,
final KafkaConfig kafkaConfig) {
this.topicRegistryClient = topicRegistryClient;
this.gatewayClient = gatewayClient;
this.graphQLConverter = graphQLConverter;
Expand All @@ -108,7 +108,7 @@ public Single<TopicData> getTopicData(final String name) {
@SuppressWarnings("RxReturnValueIgnored")
@Override
public Completable createTopic(final String name, final QuickTopicType keyType, final QuickTopicType valueType,
final TopicCreationData topicCreationData) {
final TopicCreationData topicCreationData) {
log.info("Create new topic {} with data {}", name, topicCreationData);
// we don't need the cache, so make sure we get the current information
this.schemaRegistryClient.reset();
Expand Down Expand Up @@ -202,9 +202,9 @@ private Completable createKafkaTopic(final String topicName) {
}

private Completable createMirror(final String topicName,
@Nullable final Duration retentionTime,
final boolean point,
@Nullable final String rangeField) {
@Nullable final Duration retentionTime,
final boolean point,
@Nullable final String rangeField) {
return Completable.defer(() -> {
log.debug("Create mirror for topic {}", topicName);
final MirrorCreationData mirrorCreationData = new MirrorCreationData(topicName,
Expand Down Expand Up @@ -237,10 +237,10 @@ private Completable checkSchemaRegistry(final String subject, final Optional<Qui

private Completable checkKafka(final String name) {
return Single.fromCallable(() -> {
try (final AdminClient adminClient = AdminClient.create(this.kafkaConfig.asProps())) {
return adminClient.listTopics().names();
}
})
try (final AdminClient adminClient = AdminClient.create(this.kafkaConfig.asProps())) {
return adminClient.listTopics().names();
}
})
.flatMap(Single::fromFuture)
.map(topics -> topics.contains(name))
.flatMapCompletable(exists ->
Expand All @@ -261,7 +261,7 @@ private Completable deleteMirror(final String topicName) {
}

private Completable registerSchema(final String topic, final Optional<QuickSchemas> schemas,
final KeyValueEnum keyValue) {
final KeyValueEnum keyValue) {
// if there is no schema, we can just return
if (schemas.isEmpty()) {
return Completable.complete();
Expand Down

0 comments on commit c41d7df

Please sign in to comment.