Skip to content

Commit

Permalink
Merge 5308ad3 into ffdc0cd
Browse files Browse the repository at this point in the history
  • Loading branch information
mizosoft committed Feb 10, 2024
2 parents ffdc0cd + 5308ad3 commit 61df5ba
Show file tree
Hide file tree
Showing 33 changed files with 346 additions and 327 deletions.
36 changes: 36 additions & 0 deletions .github/actions/gradle/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Setup & run Gradle

description: Setup Java & Gradle & optionally run a Gradle command

inputs:
java:
default: '21'
description: Java version
gradle-args:
required: false
description: Arguments to Gradle command (optional)

runs:
using: composite
steps:
- name: Setup Java ${{ inputs.java }}
id: setup-java
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.java }}
distribution: temurin

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

- name: Make gradlew executable
if: inputs.gradle-args != '' && (runner.os == 'linux' || runner.os == 'macOS')
shell: bash
run: chmod +x gradlew

- name: Run Gradle command
if: ${{ inputs.gradle-args }} != ''
env:
JAVA_HOME: ${{ steps.setup-gradle-jdk.outputs.path }}
shell: bash
run: ./gradlew ${{ inputs.gradle-args }}
100 changes: 100 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Build

on: [ push, pull_request, workflow_dispatch ]

env:
BASE_JAVA: 11

jobs:
tests:
name: Test on ${{ matrix.os }} with Java ${{ matrix.java }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
java: [ 11, 21 ]
steps:
- uses: actions/checkout@v4

- name: Setup Redis
shell: bash
# It seems there's no straightforward way to install a recent redis version on Windows, so
# let's only consider macOS & Ubuntu for RedisStore tests.
run: |
if [[ "${{ matrix.os }}" == macos* ]]
then
brew install redis
elif [[ "${{ matrix.os }}" == ubuntu* ]]
then
chmod +x install-redis-ubuntu.sh
./install-redis-ubuntu.sh
fi
- name: Run tests
uses: ./.github/actions/gradle
if: "!startsWith(matrix.os, 'macos')"
with:
java: ${{ matrix.java }}
gradle-args: check

# Brotli is not currently supported on macOS so related tests are excluded there.
- name: Run tests
uses: ./.github/actions/gradle
if: startsWith(matrix.os, 'macos')
with:
java: ${{ matrix.java }}
gradle-args: check -x :methanol-brotli:test

- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.os }}-java-${{ matrix.java }}-test-results
path: |
**/build/test-results/
**/build/**/*.exec
coverage:
name: Upload coverage report
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Download test results
uses: actions/download-artifact@v4
with:
name: ubuntu-latest-java-${{ env.BASE_JAVA }}-test-results

- name: Generate coverage report
uses: ./.github/actions/gradle
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
with:
java: ${{ env.BASE_JAVA }}
gradle-args: coveralls

snapshot-release:
name: Release snapshot
if: |
github.event_name == 'push'
&& github.ref_name == github.event.repository.default_branch
needs: tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Publish snapshot release artifacts
uses: ./github/actions/gradle
env:
ORG_GRADLE_PROJECT_nexusUsername: ${{ secrets.NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_nexusPassword: ${{ secrets.NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
with:
java: ${{ env.BASE_JAVA }}
gradle-args: publishToSonatype
128 changes: 0 additions & 128 deletions .github/workflows/main.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/publish-site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish site

on:
push:
branches: [ master ]

env:
BASE_JAVA: 11

jobs:
publish-site:
name: Publish site
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# MkDocs needs python to run.
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11.1

- name: Setup Gradle
uses: ./.github/actions/gradle
with:
java: 21 # Javadoc generation needs Java >= 12.

- name: Generate docs
run: chmod +x ./generate-docs.sh && ./generate-docs.sh

- name: Deploy site
uses: JamesIves/github-pages-deploy-action@4.1.1
with:
branch: gh-pages
folder: site
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release

on:
release:
types: [ created ]

env:
BASE_JAVA: 11

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Publish release artifacts
uses: ./github/actions/gradle
env:
ORG_GRADLE_PROJECT_nexusUsername: ${{ secrets.NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_nexusPassword: ${{ secrets.NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
with:
java: ${{ env.BASE_JAVA }}
gradle-args: publishToSonatype closeAndReleaseSonatypeStagingRepository -PfinalRelease
18 changes: 13 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
import extensions.Version

plugins {
id("conventions.aggregate-coverage")
id("conventions.aggregate-javadoc")
id("conventions.aggregate-testing")
alias(libs.plugins.nexus.publish)
alias(libs.plugins.versions)
}

allprojects {
description = "Lightweight HTTP extensions for Java"
group = "com.github.mizosoft.methanol"
version = "1.8.0-SNAPSHOT"
version = Version(
major = 1,
minor = 8,
patch = 0,
release = if (project.hasProperty("finalRelease")) Version.Release.FINAL else Version.Release.SNAPSHOT
)

repositories {
mavenCentral()
}
}

nexusPublishing {
this.repositories {
repositories {
sonatype {
username.set(project.findProperty("nexusUsername")?.toString())
password.set(project.findProperty("nexusPassword")?.toString())
}
}
}

//tasks.register("clean") {
// delete(rootProject.buildDir)
//}
tasks.register("clean") {
delete(rootProject.layout.buildDirectory)
}
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ dependencies {
// See https://github.com/gradle/gradle/issues/15383.
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))

implementation(libs.javaparser)
implementation(libs.checkerframework.plugin)
implementation(libs.errorprone.plugin)
implementation(libs.nullaway.plugin)
implementation(libs.javaparser)
implementation(libs.coveralls)
implementation(libs.coveralls.plugin)
}

0 comments on commit 61df5ba

Please sign in to comment.