Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "weekly"
52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Java 25
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 25

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Compile
run: ./gradlew clean assemble

- name: Test
run: ./gradlew -PtestMode=slow test

- name: Checkstyle
if: success() || failure()
run: ./gradlew checkstyleMain

- name: Jacoco Coverage Verification
if: success() || failure()
run: ./gradlew jacocoTestCoverageVerification

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: build/reports/tests/xml/

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: jars
path: build/libs/*.jar
50 changes: 11 additions & 39 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
# ******** NOTE ********

name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '45 16 * * 2'
Expand All @@ -30,39 +17,24 @@ jobs:
fail-fast: false
matrix:
language: [ 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Java 25
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 25

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
- name: Build
run: ./gradlew clean assemble

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v3
179 changes: 164 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,38 +1,123 @@
apply from: 'build.shared'
apply plugin: 'checkstyle'
apply plugin: 'jacoco'
plugins {
id 'java'
id 'checkstyle'
id 'jacoco'
id 'maven-publish'
id 'signing'
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}

plugins.withType(JavaPlugin) {
checkstyle.sourceSets = [sourceSets.main]
repositories {
mavenCentral()
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:6.0.3'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:6.0.3'
implementation "org.threadly:threadly:$threadlyVersion"
}

compileJava {
options.compilerArgs << '-Xlint:all' << '-Xlint:-deprecation' << '-Xlint:-this-escape' << '-Werror'
}

compileTestJava {
options.compilerArgs << '-Xlint:all'
}

checkstyle {
sourceSets = [sourceSets.main]
}

def testMode = project.findProperty('testMode') ?: 'default'

test {
maxParallelForks = Math.min(8, Math.max(1, (int)(Runtime.getRuntime().availableProcessors() / 4)))
useJUnitPlatform()

switch (testMode) {
case 'slow':
maxParallelForks = 1
systemProperty 'systemSpeed', 'slow'
break
case 'stress':
systemProperty 'systemSpeed', 'slow'
systemProperty 'testProfile', 'stress'
maxParallelForks = Math.min(8, Math.max(1, (int)(Runtime.getRuntime().availableProcessors() / 2)))
break
default:
maxParallelForks = Math.min(8, Math.max(1, (int)(Runtime.getRuntime().availableProcessors() / 4)))
break
}

reports {
junitXml.outputLocation = layout.buildDirectory.dir('reports/tests/xml')
html.outputLocation = layout.buildDirectory.dir('reports/tests/html')
}
binaryResultsDirectory = layout.buildDirectory.dir('reports/tests/bin')

jacoco {
excludes = ['**/package-info**','**/*Test']
destinationFile = file("$buildDir/reports/jacoco/test.exec")
excludes = ['**/package-info**', '**/*Test']
destinationFile = layout.buildDirectory.file('reports/jacoco/test.exec').get().asFile
}
}

test.dependsOn("jar")
test.dependsOn('jar')

jar {
manifest {
attributes(
'Implementation-Title': 'Threadly Test Utilities',
'Implementation-Version': archiveVersion.get()
)
}
}

javadoc {
source = sourceSets.main.allJava
excludes = ['**/ThreadlyInternalAccessor**', '**/ArgumentVerifier**']
options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PUBLIC
}

tasks.register('javadocJar', Jar) {
dependsOn javadoc
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}

tasks.register('sourcesJar', Jar) {
from sourceSets.main.allSource
archiveClassifier.set('sources')
}

tasks.register('copyLibs', Copy) {
into layout.buildDirectory.dir('dependencies')
from configurations.runtimeClasspath
}

build.finalizedBy('copyLibs')

jacocoTestReport {
reports {
csv.required = false
xml.required = true
xml.destination = file("$buildDir/reports/jacoco/jacoco.xml")
xml.outputLocation = layout.buildDirectory.file('reports/jacoco/jacoco.xml')
html.required = true
html.destination = file("$buildDir/reports/jacoco/html")
html.outputLocation = layout.buildDirectory.dir('reports/jacoco/html')
}
doLast {
println "Test results available at:"
println "html - $buildDir/reports/tests/html/index.html"
println "html - ${layout.buildDirectory.dir('reports/tests/html').get().asFile}/index.html"
println "Test coverage reports available at:"
println "html - $buildDir/reports/jacoco/html/index.html"
println "html - ${layout.buildDirectory.dir('reports/jacoco/html').get().asFile}/index.html"
}
}

test.finalizedBy("jacocoTestReport")
test.finalizedBy('jacocoTestReport')

jacocoTestCoverageVerification {
violationRules {
Expand Down Expand Up @@ -63,4 +148,68 @@ jacocoTestCoverageVerification {
}
}

jacocoTestReport.finalizedBy("jacocoTestCoverageVerification")
jacocoTestReport.finalizedBy('jacocoTestCoverageVerification')

publishing {
publications {
mavenJava(MavenPublication) {
from components.java

artifact(tasks.named('sourcesJar'))
artifact(tasks.named('javadocJar'))

pom {
name = 'Threadly Test Utilities'
description = 'A library of tools to assist with testing concurrent java applications.'
url = 'https://threadly.org/'

scm {
url = 'scm:git@github.com:threadly/threadly-test.git'
connection = 'scm:git@github.com:threadly/threadly-test.git'
developerConnection = 'scm:git@github.com:threadly/threadly-test.git'
}

issueManagement {
system = 'GitHub'
url = 'https://github.com/threadly/threadly-test/issues'
}

licenses {
license {
name = 'Mozilla Public License Version 2.0'
url = 'https://www.mozilla.org/MPL/2.0/'
distribution = 'repo'
}
}

developers {
developer {
id = 'jent'
name = 'Mike Jensen'
email = 'jent@threadly.org'
}
}
}
}
}
repositories {
maven {
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = findProperty('sonatypeUsername') ?: ''
password = findProperty('sonatypePassword') ?: ''
}
}
}
}

tasks.withType(GenerateMavenPom).configureEach {
destination = layout.buildDirectory.file('generated-pom.xml').get().asFile
}

signing {
required = { !version.toString().contains('SNAPSHOT') && gradle.taskGraph.hasTask('publish') }
sign publishing.publications.mavenJava
}
Loading
Loading