Skip to content

Commit

Permalink
feat(v2.1.0): Kafka SSL and additional config options, plus tweaks an…
Browse files Browse the repository at this point in the history
…d fixes (#65)

* fix(rate-limiting): Fix two configuration properties being val instead of var
- Bumped version to 2.0.1

* feat(kafka-ssl): SSL tested and works
  • Loading branch information
Flaxoos authored Nov 11, 2024
1 parent 0cbba2e commit a7ad3b5
Show file tree
Hide file tree
Showing 503 changed files with 4,633 additions and 4,504 deletions.
13 changes: 8 additions & 5 deletions .github/actions/detect-modified-projects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ This GitHub Action allows you to run gradle tasks on projects within your reposi

### Inputs

- `projects` (required): Projects to run the tasks on, comma-separated.
- `tasks` (required): Tasks to run on the projects, comma-separated.
- `parent_project_task` (optional): Task to run on the parent project.
- `execute_on_root_anyway` (optional): Execute on root regardless of if any projects have been provided. Accepted values: 'true' or 'false'.
- `projects` (required): Projects to run the tasks on, comma-separated.
- `tasks` (required): Tasks to run on the projects, comma-separated.
- `parent_project_task` (optional): Task to run on the parent project.
- `execute_on_root_anyway` (optional): Execute on root regardless of if any projects have been provided. Accepted
values: 'true' or 'false'.

### Outputs

- `gradle_output` : Output from Gradle.
- `gradle_output` : Output from Gradle.

### Example Usage

name: Execute gradle tasks on projects
description: Run gradle tasks on projects

```yaml
on:
push:
Expand Down
41 changes: 22 additions & 19 deletions .github/actions/detect-modified-projects/dist/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
desc = {
enumerable: true, get: function () {
return m[k];
}
};
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
}) : (function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) {
Object.defineProperty(o, "default", {enumerable: true, value: v});
}) : function (o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
Expand All @@ -22,41 +26,41 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
Object.defineProperty(exports, "__esModule", {value: true});
const child_process_1 = require("child_process");
const core = __importStar(require("@actions/core"));

function run() {
var _a, _b, _c, _d;
try {
const subprojectPrefixes = (_b = (_a = core.getInput('project_prefixes')) === null || _a === void 0 ? void 0 : _a.split(",")) !== null && _b !== void 0 ? _b : [];
const requiredProjects = (_d = (_c = core.getInput('required_projects')) === null || _c === void 0 ? void 0 : _c.split(",")) !== null && _d !== void 0 ? _d : [];
core.debug("executing git fetch");
(0, child_process_1.execSync)('git fetch --unshallow', { encoding: 'utf-8' });
(0, child_process_1.execSync)('git fetch --unshallow', {encoding: 'utf-8'});
const githubSha = process.env.GITHUB_SHA;
if (!githubSha) {
core.setFailed('GITHUB_SHA not set');
}
const diffCmd = `git diff --name-only HEAD~1..${githubSha}`;
core.debug(`Executing: ${diffCmd}`);
core.debug(`Git Status: ${(0, child_process_1.execSync)(`git status`, { encoding: 'utf-8' }).trim()}`);
core.debug(`SHA Exists: ${(0, child_process_1.execSync)(`git cat-file -e ${githubSha}`, { encoding: 'utf-8' }).trim()}`);
let modifiedProjects = (0, child_process_1.execSync)(diffCmd, { encoding: 'utf8' });
core.debug(`Git Status: ${(0, child_process_1.execSync)(`git status`, {encoding: 'utf-8'}).trim()}`);
core.debug(`SHA Exists: ${(0, child_process_1.execSync)(`git cat-file -e ${githubSha}`, {encoding: 'utf-8'}).trim()}`);
let modifiedProjects = (0, child_process_1.execSync)(diffCmd, {encoding: 'utf8'});
core.debug("Modified Projects:" + modifiedProjects);
core.debug("Required Projects:" + requiredProjects);
if (modifiedProjects.includes('buildSrc/') && !modifiedProjects.includes('ktor-')) {
core.debug("only buildSrc has modified");
modifiedProjects = "buildSrc";
}
else {
} else {
const subprojectPrefixesPattern = subprojectPrefixes.join("|");
core.debug("subprojectPrefixesPattern: " + subprojectPrefixesPattern);
const regex = subprojectPrefixes.length > 0
? new RegExp(`^(${subprojectPrefixesPattern})`)
: null;
let modifiedProjectsArray = modifiedProjects.split('\n')
.filter(line => {
return regex ? regex.test(line) : true;
})
return regex ? regex.test(line) : true;
})
.map(line => line.split('/', 1)[0])
.sort()
.filter((value, index, self) => self.indexOf(value) === index);
Expand All @@ -65,13 +69,12 @@ function run() {
if (modifiedProjects) {
core.info(`Modified subprojects including required projects: ${modifiedProjects}`);
core.setOutput('modified_projects', modifiedProjects);
}
else {
} else {
core.info("No modified subprojects");
}
}
catch (error) {
} catch (error) {
core.setFailed(`Action failed with error: ${error}`);
}
}

run();
4 changes: 3 additions & 1 deletion .github/actions/detect-modified-projects/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
"exclude": [
"node_modules"
],
"include": ["./src/**/*.ts"],
"include": [
"./src/**/*.ts"
]
}
14 changes: 8 additions & 6 deletions .github/actions/execute-gradle-tasks-on-projects/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ This GitHub Action allows you to run gradle tasks on projects within your reposi

### Inputs

- `projects` (required): Projects to run the tasks on, comma-separated.
- `tasks` (required): Tasks to run on the projects, comma-separated.
- `parent_project_task` (optional): Task to run on the parent project.
- `execute_on_root_anyway` (optional): Execute on root regardless of if any projects have been provided. Accepted values: 'true' or 'false'.
- `projects` (required): Projects to run the tasks on, comma-separated.
- `tasks` (required): Tasks to run on the projects, comma-separated.
- `parent_project_task` (optional): Task to run on the parent project.
- `execute_on_root_anyway` (optional): Execute on root regardless of if any projects have been provided. Accepted
values: 'true' or 'false'.

### Outputs

- `gradle_output` : Output from Gradle.
- `gradle_output` : Output from Gradle.

### Example Usage

```yaml
name: Execute gradle tasks on projects
description: Run gradle tasks on projects
Expand All @@ -37,4 +39,4 @@ jobs:
tasks: 'build,test'
parent_project_task: 'clean'
execute_on_root_anyway: 'false'
```
```
35 changes: 20 additions & 15 deletions .github/actions/execute-gradle-tasks-on-projects/dist/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
var __createBinding = (this && this.__createBinding) || (Object.create ? (function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
desc = {
enumerable: true, get: function () {
return m[k];
}
};
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
}) : (function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function (o, v) {
Object.defineProperty(o, "default", {enumerable: true, value: v});
}) : function (o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
Expand All @@ -22,20 +26,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
Object.defineProperty(exports, "__esModule", {value: true});
const core = __importStar(require("@actions/core"));
const child_process_1 = require("child_process");

class StringBuilder {
constructor() {
this._parts = [];
}

append(value) {
this._parts.push(value);
}

toString() {
return this._parts.join("");
}
}

async function run() {
var _a, _b;
try {
Expand All @@ -56,8 +64,7 @@ async function run() {
if (projects === 'buildSrc') {
core.debug(`only buildSrc has changed, setting gradleProjectsTasks to ${tasks.replace(",", " ")}`);
gradleProjectsTasks = `${tasks.replace(",", " ")} `;
}
else {
} else {
const projArr = projects.split(',').filter((p) => p.trim() !== '');
core.debug(`building gradleProjectsTasks with projects: ${projArr} and tasks: ${taskArr}`);
if (taskArr.length === 0 && !rootProjectTask) {
Expand All @@ -74,8 +81,7 @@ async function run() {
return acc2 + `:${proj}:${task} `;
}, '');
}, '');
}
else {
} else {
gradleProjectsTasks = taskArr.reduce((acc1, task) => {
return acc1 + `${task} `;
}, '');
Expand All @@ -101,16 +107,15 @@ async function run() {
gradleChild.on('exit', (code, signal) => {
if (code !== 0) {
reject(new Error(`Gradle exited with code ${code} due to signal ${signal}`));
}
else {
} else {
resolve(gradleOutputBuilder.toString());
}
});
});
core.setOutput('gradle_output', await processPromise);
}
catch (error) {
} catch (error) {
core.setFailed(error.message);
}
}

run();
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class StringBuilder {
return this._parts.join("");
}
}

async function run() {
try {
let projects = core.getInput('projects');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
"exclude": [
"node_modules"
],
"include": ["./src/**/*.ts"],
"include": [
"./src/**/*.ts"
]
}
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[![Docs](https://custom-icon-badges.demolab.com/badge/Pages-blue.svg?label=Docs&logo=github&logoColor=white?icon=githubpages&style=for-the-badge)](https://github.com/Flaxoos/extra-ktor-plugins/actions/workflows/pages/pages-build-deployment)
[![Awesome Kotlin Badge](https://custom-icon-badges.demolab.com/badge/awesome-kotlin-orange.svg?labelColor=blue&style=for-the-badge)](https://github.com/KotlinBy/awesome-kotlin)
---

### Feature-rich, efficient, and highly customizable plugins for your Multiplatform Ktor Server or Client

---
Expand All @@ -19,24 +20,24 @@
| **[Task Scheduling](ktor-server-task-scheduling)** | **JVM / Native^** | Task scheduling for distributed servers with various and extendable task management strategies |
| **[Rate Limiting](ktor-server-rate-limiting)** | **JVM / Native** | Highly configurable rate limiter with offering different startegies, request weighting, blacklisting and whitelisting of requests based on authentication, host and user agents |


### **Client Plugins**

| Plugin | Supported Platforms | Description |
|----------------------------------------------------|----------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Plugin | Supported Platforms | Description |
|----------------------------------------------------|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **[Circuit Breaker](ktor-client-circuit-breaker)** | **JVM / Native / JS** | Enhances system resilience by halting requests to failing services once a defined error threshold is reached. Automatically switches between open and closed states based on the health of the targeted service. |

Note that `^` means issues with native binary dependencies, feel free to pull the project and publish locally

---


## Usage

Pleas see [Documentation](https://flaxoos.github.io/extra-ktor-plugins/)

## Installation

The libraries are published to maven central, see above for the latest version

```kotlin
dependencies {
implementation("io.github.flaxoos:ktor-server-kafka:$ktor_plugins_version")
Expand All @@ -47,11 +48,13 @@ dependencies {
```

## Examples:

See [examples repository](https://github.com/Flaxoos/flax-ktor-plugins-examples)

## Contributing

Contributions are always welcome! If you have an idea for a plugin or want to improve an existing one, feel free to fork this repository and submit a pull request.
Contributions are always welcome! If you have an idea for a plugin or want to improve an existing one, feel free to fork
this repository and submit a pull request.

## Sponsership

Expand Down
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import ru.vyarus.gradle.plugin.python.PythonExtension

plugins {
alias(libs.plugins.nexusPublish)
id(libs.plugins.dokka.get().pluginId)
id(
libs.plugins.dokka
.get()
.pluginId,
)
id("ru.vyarus.mkdocs-build") version "3.0.0"
}

Expand Down
22 changes: 13 additions & 9 deletions buildSrc/src/main/kotlin/io/github/flaxoos/ktor/Conventions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import org.gradle.plugins.ide.idea.model.IdeaModel
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.utils.named
import org.jlleitschuh.gradle.ktlint.KtlintExtension
import org.jlleitschuh.gradle.ktlint.tasks.KtLintCheckTask
import org.jlleitschuh.gradle.ktlint.tasks.KtLintFormatTask

open class Conventions : Plugin<Project> {
open fun KotlinMultiplatformExtension.conventionSpecifics(project: Project) {}
Expand Down Expand Up @@ -107,11 +109,17 @@ open class Conventions : Plugin<Project> {
buildUponDefaultConfig = true
}

tasks.named("build").configure {
dependsOn("ktlintFormat")
dependsOn(tasks.matching { it.name.matches(Regex("detekt(?!.*Baseline).*\\b(Main|Test)\\b\n")) })
the<KtlintExtension>().apply {
version.set(versionOf("ktlint"))
}

tasks.withType<KtLintCheckTask> {
dependsOn(tasks.withType<KtLintFormatTask>())
}

tasks.named("build") {
dependsOn(tasks.matching { it.name.matches(Regex("detekt(?!.*Baseline).*\\b(Main|Test)\\b\n")) })
}
tasks.withType(Test::class) {
useJUnitPlatform()
}
Expand All @@ -126,7 +134,7 @@ open class Conventions : Plugin<Project> {
verify {
rule {
isEnabled = true
minBound(60)
minBound(55)
}
onCheck = true
}
Expand Down Expand Up @@ -242,7 +250,3 @@ fun NamedDomainObjectCollection<KotlinSourceSet>.nativeTestDependencies(configur
private fun Project.ktorVersion() = versionOf("ktor")

fun Project.projectDependencies(configuration: DependencyHandlerScope.() -> Unit) = DependencyHandlerScope.of(dependencies).configuration()

@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER)
@Retention(AnnotationRetention.RUNTIME)
annotation class KoverIgnore
Loading

0 comments on commit a7ad3b5

Please sign in to comment.