Compare commits
1 Commits
0.0.1
...
72d86051f6
Author | SHA1 | Date | |
---|---|---|---|
72d86051f6
|
@@ -5,8 +5,6 @@ on:
|
|||||||
- '*'
|
- '*'
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
env:
|
|
||||||
RUNNER_TOOL_CACHE: /toolcache
|
|
||||||
runs-on: hostinger
|
runs-on: hostinger
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout sources
|
- name: Checkout sources
|
||||||
@@ -21,11 +19,7 @@ jobs:
|
|||||||
- name: Execute Gradle build
|
- name: Execute Gradle build
|
||||||
env:
|
env:
|
||||||
PUBLISHER_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
|
PUBLISHER_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
|
||||||
run: ./gradlew build
|
run: ./gradlew build publish
|
||||||
- name: Publish artifacts
|
|
||||||
env:
|
|
||||||
PUBLISHER_TOKEN: ${{ secrets.PUBLISHER_TOKEN }}
|
|
||||||
run: ./gradlew publish
|
|
||||||
build-docker:
|
build-docker:
|
||||||
name: "Build Docker images"
|
name: "Build Docker images"
|
||||||
runs-on: hostinger
|
runs-on: hostinger
|
||||||
|
15
build.gradle
15
build.gradle
@@ -10,15 +10,15 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
|
|
||||||
|
|
||||||
allprojects { subproject ->
|
allprojects {
|
||||||
group = 'net.woggioni'
|
group = 'net.woggioni'
|
||||||
|
|
||||||
if(project.currentTag.isPresent()) {
|
if(project.currentTag.isPresent()) {
|
||||||
version = project.currentTag.map { it[0] }.get()
|
version = project.currentTag
|
||||||
} else {
|
} else {
|
||||||
version = project.gitRevision.map { gitRevision ->
|
version = project.gitRevision.map { gitRevision ->
|
||||||
"${getProperty('gbcs.version')}.${gitRevision[0..10]}"
|
"${getProperty('gbcs.version')}.${gitRevision[0..10]}"
|
||||||
}.get()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -36,7 +36,7 @@ allprojects { subproject ->
|
|||||||
pluginManager.withPlugin('java-library') {
|
pluginManager.withPlugin('java-library') {
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
jpmsModuleName = subproject.group + '.' + subproject.name.replace('-', '.')
|
jpmsModuleName = project.group + '.' + project.name.replace('-', '.')
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
@@ -61,13 +61,14 @@ allprojects { subproject ->
|
|||||||
options.compilerArgumentProviders << new CommandLineArgumentProvider() {
|
options.compilerArgumentProviders << new CommandLineArgumentProvider() {
|
||||||
@Override
|
@Override
|
||||||
Iterable<String> asArguments() {
|
Iterable<String> asArguments() {
|
||||||
return ['--patch-module', subproject.jpmsModuleName + '=' + subproject.sourceSets.main.output.asPath]
|
return ['--patch-module', project.jpmsModuleName + '=' + project.sourceSets.main.output.asPath]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
options.javaModuleVersion = version
|
options.javaModuleVersion = version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pluginManager.withPlugin(catalog.plugins.kotlin.jvm.get().pluginId) {
|
pluginManager.withPlugin(catalog.plugins.kotlin.jvm.get().pluginId) {
|
||||||
tasks.withType(KotlinCompile.class) {
|
tasks.withType(KotlinCompile.class) {
|
||||||
compilerOptions.jvmTarget = JvmTarget.JVM_21
|
compilerOptions.jvmTarget = JvmTarget.JVM_21
|
||||||
@@ -100,6 +101,10 @@ allprojects { subproject ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType(AbstractArchiveTask.class) {
|
||||||
|
archiveVersion = project.version
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@@ -7,6 +7,10 @@ plugins {
|
|||||||
dependencies {
|
dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME, JavaCompile) {
|
||||||
|
options.javaModuleVersion = version
|
||||||
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
maven(MavenPublication) {
|
maven(MavenPublication) {
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
package net.woggioni.gbcs.api;
|
package net.woggioni.gbcs.api;
|
||||||
|
|
||||||
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -24,18 +23,25 @@ public class Configuration {
|
|||||||
|
|
||||||
@Value
|
@Value
|
||||||
public static class Group {
|
public static class Group {
|
||||||
@EqualsAndHashCode.Include
|
|
||||||
String name;
|
String name;
|
||||||
Set<Role> roles;
|
Set<Role> roles;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return name.hashCode();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Value
|
@Value
|
||||||
public static class User {
|
public static class User {
|
||||||
@EqualsAndHashCode.Include
|
|
||||||
String name;
|
String name;
|
||||||
String password;
|
String password;
|
||||||
Set<Group> groups;
|
Set<Group> groups;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return name.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
public Set<Role> getRoles() {
|
public Set<Role> getRoles() {
|
||||||
return groups.stream()
|
return groups.stream()
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
@@ -10,6 +12,15 @@ dependencies {
|
|||||||
compileOnly catalog.slf4j.api
|
compileOnly catalog.slf4j.api
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME, JavaCompile) {
|
||||||
|
options.compilerArgs << '--patch-module' << 'net.woggioni.gbcs.base=' + project.sourceSets.main.output.asPath
|
||||||
|
options.javaModuleVersion = version
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named("compileKotlin", KotlinCompile.class) {
|
||||||
|
compilerOptions.jvmTarget = JvmTarget.JVM_21
|
||||||
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
maven(MavenPublication) {
|
maven(MavenPublication) {
|
||||||
|
@@ -18,6 +18,8 @@ Property<String> mainClassName = objects.property(String.class)
|
|||||||
mainClassName.set('net.woggioni.gbcs.cli.GradleBuildCacheServerCli')
|
mainClassName.set('net.woggioni.gbcs.cli.GradleBuildCacheServerCli')
|
||||||
|
|
||||||
tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME, JavaCompile) {
|
tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME, JavaCompile) {
|
||||||
|
options.compilerArgs << '--patch-module' << 'net.woggioni.gbcs.cli=' + project.sourceSets.main.output.asPath
|
||||||
|
options.javaModuleVersion = version
|
||||||
options.javaModuleMainClass = mainClassName
|
options.javaModuleMainClass = mainClassName
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,6 +36,8 @@ dependencies {
|
|||||||
implementation catalog.netty.codec.http
|
implementation catalog.netty.codec.http
|
||||||
implementation catalog.picocli
|
implementation catalog.picocli
|
||||||
|
|
||||||
|
// implementation project(':gbcs-base')
|
||||||
|
// implementation project(':gbcs-api')
|
||||||
implementation rootProject
|
implementation rootProject
|
||||||
|
|
||||||
// runtimeOnly catalog.slf4j.jdk14
|
// runtimeOnly catalog.slf4j.jdk14
|
||||||
@@ -46,6 +50,11 @@ Provider<EnvelopeJarTask> envelopeJarTaskProvider = tasks.named('envelopeJar', E
|
|||||||
systemProperties['logback.configurationFile'] = 'classpath:net/woggioni/gbcs/cli/logback.xml'
|
systemProperties['logback.configurationFile'] = 'classpath:net/woggioni/gbcs/cli/logback.xml'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def envelopeJarArtifact = artifacts.add('archives', envelopeJarTaskProvider.get().archiveFile.get().asFile) {
|
||||||
|
type = 'jar'
|
||||||
|
builtBy envelopeJarTaskProvider
|
||||||
|
}
|
||||||
|
|
||||||
tasks.named(NativeImagePlugin.CONFIGURE_NATIVE_IMAGE_TASK_NAME, NativeImageConfigurationTask) {
|
tasks.named(NativeImagePlugin.CONFIGURE_NATIVE_IMAGE_TASK_NAME, NativeImageConfigurationTask) {
|
||||||
mainClass = 'net.woggioni.gbcs.GraalNativeImageConfiguration'
|
mainClass = 'net.woggioni.gbcs.GraalNativeImageConfiguration'
|
||||||
}
|
}
|
||||||
@@ -59,7 +68,7 @@ tasks.named(NativeImagePlugin.NATIVE_IMAGE_TASK_NAME, NativeImageTask) {
|
|||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
maven(MavenPublication) {
|
maven(MavenPublication) {
|
||||||
artifact envelopeJar
|
artifact envelopeJarArtifact
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,15 @@ dependencies {
|
|||||||
implementation catalog.xmemcached
|
implementation catalog.xmemcached
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME, JavaCompile) {
|
||||||
|
options.compilerArgs << '--patch-module' << 'net.woggioni.gbcs.memcached=' + project.sourceSets.main.output.asPath
|
||||||
|
options.javaModuleVersion = version
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named("compileKotlin", KotlinCompile.class) {
|
||||||
|
compilerOptions.jvmTarget = JvmTarget.JVM_21
|
||||||
|
}
|
||||||
|
|
||||||
Provider<Tar> bundleTask = tasks.register("bundle", Tar) {
|
Provider<Tar> bundleTask = tasks.register("bundle", Tar) {
|
||||||
from(tasks.named(JavaPlugin.JAR_TASK_NAME))
|
from(tasks.named(JavaPlugin.JAR_TASK_NAME))
|
||||||
from(configurations.bundle)
|
from(configurations.bundle)
|
||||||
@@ -40,10 +49,16 @@ tasks.named(BasePlugin.ASSEMBLE_TASK_NAME) {
|
|||||||
dependsOn(bundleTask)
|
dependsOn(bundleTask)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def bundleArtifact = artifacts.add('archives', bundleTask.get().archiveFile.get().asFile) {
|
||||||
|
type = 'tar'
|
||||||
|
builtBy bundleTask
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
maven(MavenPublication) {
|
maven(MavenPublication) {
|
||||||
artifact bundleTask
|
artifact bundleArtifact
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -34,6 +34,8 @@ import io.netty.handler.codec.http.HttpServerCodec
|
|||||||
import io.netty.handler.codec.http.HttpUtil
|
import io.netty.handler.codec.http.HttpUtil
|
||||||
import io.netty.handler.codec.http.HttpVersion
|
import io.netty.handler.codec.http.HttpVersion
|
||||||
import io.netty.handler.codec.http.LastHttpContent
|
import io.netty.handler.codec.http.LastHttpContent
|
||||||
|
import io.netty.handler.ssl.ApplicationProtocolNames
|
||||||
|
import io.netty.handler.ssl.ApplicationProtocolNegotiationHandler
|
||||||
import io.netty.handler.ssl.ClientAuth
|
import io.netty.handler.ssl.ClientAuth
|
||||||
import io.netty.handler.ssl.SslContext
|
import io.netty.handler.ssl.SslContext
|
||||||
import io.netty.handler.ssl.SslContextBuilder
|
import io.netty.handler.ssl.SslContextBuilder
|
||||||
@@ -445,16 +447,15 @@ class GradleBuildCacheServer(private val cfg: Configuration) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ServerHandle(
|
class ServerHandle(
|
||||||
httpChannelFuture: ChannelFuture,
|
private val httpChannel: ChannelFuture,
|
||||||
private val bossGroup: EventLoopGroup,
|
private val bossGroup: EventLoopGroup,
|
||||||
private val workerGroup: EventLoopGroup
|
private val workerGroup: EventLoopGroup
|
||||||
) : AutoCloseable {
|
) : AutoCloseable {
|
||||||
private val httpChannel: Channel = httpChannelFuture.channel()
|
|
||||||
|
|
||||||
private val closeFuture: ChannelFuture = httpChannel.closeFuture()
|
private val closeFuture: ChannelFuture = httpChannel.channel().closeFuture()
|
||||||
|
|
||||||
fun shutdown(): ChannelFuture {
|
fun shutdown(): ChannelFuture {
|
||||||
return httpChannel.close()
|
return httpChannel.channel().close()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun close() {
|
override fun close() {
|
||||||
@@ -473,12 +474,12 @@ class GradleBuildCacheServer(private val cfg: Configuration) {
|
|||||||
|
|
||||||
fun run(): ServerHandle {
|
fun run(): ServerHandle {
|
||||||
// Create the multithreaded event loops for the server
|
// Create the multithreaded event loops for the server
|
||||||
val bossGroup = NioEventLoopGroup(0, Executors.defaultThreadFactory())
|
val bossGroup = NioEventLoopGroup()
|
||||||
val serverSocketChannel = NioServerSocketChannel::class.java
|
val serverSocketChannel = NioServerSocketChannel::class.java
|
||||||
val workerGroup = if (cfg.isUseVirtualThread) {
|
val workerGroup = if (cfg.isUseVirtualThread) {
|
||||||
NioEventLoopGroup(0, Executors.newVirtualThreadPerTaskExecutor())
|
NioEventLoopGroup(0, Executors.newVirtualThreadPerTaskExecutor())
|
||||||
} else {
|
} else {
|
||||||
bossGroup
|
NioEventLoopGroup(0, Executors.newWorkStealingPool())
|
||||||
}
|
}
|
||||||
// A helper class that simplifies server configuration
|
// A helper class that simplifies server configuration
|
||||||
val bootstrap = ServerBootstrap().apply {
|
val bootstrap = ServerBootstrap().apply {
|
||||||
|
@@ -1,30 +1,19 @@
|
|||||||
package net.woggioni.gbcs.utils;
|
package net.woggioni.gbcs.utils;
|
||||||
|
|
||||||
import net.woggioni.jwo.JWO;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
|
|
||||||
public class NetworkUtils {
|
public class NetworkUtils {
|
||||||
|
|
||||||
private static final int MAX_ATTEMPTS = 50;
|
|
||||||
|
|
||||||
public static int getFreePort() {
|
public static int getFreePort() {
|
||||||
int count = 0;
|
while(true) {
|
||||||
while(count < MAX_ATTEMPTS) {
|
try (ServerSocket serverSocket = new ServerSocket(0)) {
|
||||||
try (ServerSocket serverSocket = new ServerSocket(0, 50, InetAddress.getLocalHost())) {
|
|
||||||
final var candidate = serverSocket.getLocalPort();
|
final var candidate = serverSocket.getLocalPort();
|
||||||
if (candidate > 0) {
|
if (serverSocket.getLocalPort() > 0) {
|
||||||
return candidate;
|
return candidate;
|
||||||
} else {
|
|
||||||
JWO.newThrowable(RuntimeException.class, "Got invalid port number: %d", candidate);
|
|
||||||
throw new RuntimeException("Error trying to find an open port");
|
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
++count;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new RuntimeException("Error trying to find an open port");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -228,6 +228,7 @@ class TlsServerTest : AbstractServerTest() {
|
|||||||
@Test
|
@Test
|
||||||
@Order(3)
|
@Order(3)
|
||||||
fun getAsAWriterUser() {
|
fun getAsAWriterUser() {
|
||||||
|
|
||||||
val (key, _) = keyValuePair
|
val (key, _) = keyValuePair
|
||||||
val user = cfg.users.values.find {
|
val user = cfg.users.values.find {
|
||||||
Role.Writer in it.roles
|
Role.Writer in it.roles
|
||||||
@@ -245,6 +246,7 @@ class TlsServerTest : AbstractServerTest() {
|
|||||||
@Test
|
@Test
|
||||||
@Order(4)
|
@Order(4)
|
||||||
fun putAsAWriterUser() {
|
fun putAsAWriterUser() {
|
||||||
|
|
||||||
val (key, value) = keyValuePair
|
val (key, value) = keyValuePair
|
||||||
val user = cfg.users.values.find {
|
val user = cfg.users.values.find {
|
||||||
Role.Writer in it.roles
|
Role.Writer in it.roles
|
||||||
|
Reference in New Issue
Block a user