Skip to content

Commit

Permalink
(chore) test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-pelykh committed Jun 20, 2024
1 parent c88cc9e commit 9e1189c
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 81 deletions.
58 changes: 40 additions & 18 deletions .github/workflows/push.yaml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
name: Push
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:

compatibility:
strategy:
matrix:
os: [ ubuntu-latest ]
Expand All @@ -21,19 +25,19 @@ jobs:
- semeru
- oracle
- dragonwell
fail-fast: false
java-version: [ 21 ]

runs-on: ${{ matrix.os }}

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

- name: Set up "${{ matrix.java-distribution }}" JDK 21
- name: Set up ${{ matrix.java-distribution }}-jdk-${{ matrix.java-version }}
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.java-distribution }}
java-version: 21
java-version: ${{ matrix.java-version }}

- name: Cache Gradle packages
uses: actions/cache@v4
Expand All @@ -44,41 +48,59 @@ jobs:
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: gradle-${{ runner.os }}

- name: Install PCRE (Ubuntu)
- name: Install PCRE
if: ${{ matrix.os == 'ubuntu-latest' }}
run: sudo apt-get install -y libpcre2-8-0

- name: Build with Gradle (Ubuntu)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: ./gradlew build -Dpcre2.library.path=/usr/lib/x86_64-linux-gnu

- name: Run tests (Ubuntu)
- name: Test
if: ${{ matrix.os == 'ubuntu-latest' }}
run: ./gradlew test -Dpcre2.library.path=/usr/lib/x86_64-linux-gnu
run: ./gradlew ffm:test jna:test -Dpcre2.library.path=/usr/lib/x86_64-linux-gnu

publish:
package:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

needs:
- build
- compatibility

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

- name: Set up JDK 21
- name: Set up temurin-jdk-21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21

- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: gradle-${{ runner.os }}

- name: Install PCRE
run: sudo apt-get install -y libpcre2-8-0

- name: Build
run: ./gradlew build jacocoAggregatedTestReport -Dpcre2.library.path=/usr/lib/x86_64-linux-gnu

- name: Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: build/reports/jacoco/jacocoAggregatedTestReport/jacoco.xml

- name: Publish
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew publishAllPublicationsToGitHubPackagesRepository -Ppcre4j.version=main-SNAPSHOT
run: ./gradlew publishAllPublicationsToGitHubPackagesRepository -Ppcre4j.version=${{ github.ref_name }}-SNAPSHOT
57 changes: 0 additions & 57 deletions .github/workflows/pull-request.yaml

This file was deleted.

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

![GitHub License](https://img.shields.io/github/license/alexey-pelykh/pcre4j)
![GitHub branch check runs](https://img.shields.io/github/check-runs/alexey-pelykh/pcre4j/main)
[![codecov](https://codecov.io/gh/alexey-pelykh/pcre4j/graph/badge.svg?token=7UJZ501GWT)](https://codecov.io/gh/alexey-pelykh/pcre4j)
![Maven Central Version](https://img.shields.io/maven-central/v/org.pcre4j/lib)

The PCRE4J project's goal is to bring the power of the [PCRE](https://www.pcre.org) library to Java.
Expand All @@ -12,9 +13,10 @@ library author [Philip Hazel](https://github.com/PhilipHazel) and its contributo
## Usage

The PCRE4J library provides several APIs to interact with the PCRE library:
- `java.util.regex`-alike API via `org.pcre4j.regex.Pattern` and `org.pcre4j.regex.Matcher`
- The PCRE4J API via `org.pcre4j.Pcre2Code` and related classes
- The `libpcre2` direct API via backends that implement `org.pcre4j.api.IPcre2`

- `java.util.regex`-alike API via `org.pcre4j.regex.Pattern` and `org.pcre4j.regex.Matcher`
- The PCRE4J API via `org.pcre4j.Pcre2Code` and related classes
- The `libpcre2` direct API via backends that implement `org.pcre4j.api.IPcre2`

### Quick Start with `java.util.regex`-alike API

Expand Down
13 changes: 12 additions & 1 deletion api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ plugins {
`java-library`
`maven-publish`
signing
jacoco
}

repositories {
Expand Down Expand Up @@ -51,8 +52,18 @@ java {
withJavadocJar()
}

tasks.withType<Test> {
tasks.test {
useJUnitPlatform()
finalizedBy(tasks.jacocoTestReport)
}

tasks.jacocoTestReport {
dependsOn(tasks.test)

reports {
xml.required = true
html.required = true
}
}

tasks.named<Jar>("sourcesJar") {
Expand Down
24 changes: 24 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
plugins {
`jacoco-report-aggregation`
}

repositories {
mavenCentral()
}

dependencies {
jacocoAggregation(project(":api"))
jacocoAggregation(project(":lib"))
jacocoAggregation(project(":test"))
jacocoAggregation(project(":jna"))
jacocoAggregation(project(":ffm"))
jacocoAggregation(project(":regex"))
}

reporting {
reports {
register<JacocoCoverageReport>("jacocoAggregatedTestReport") {
testType = TestSuiteType.UNIT_TEST
}
}
}
11 changes: 11 additions & 0 deletions ffm/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ plugins {
`java-library`
`maven-publish`
signing
jacoco
}

repositories {
Expand Down Expand Up @@ -67,6 +68,16 @@ tasks.withType<Test> {
System.getProperty("java.library.path")
).joinToString(":")
)
finalizedBy(tasks.jacocoTestReport)
}

tasks.jacocoTestReport {
dependsOn(tasks.test)

reports {
xml.required = true
html.required = true
}
}

tasks.named<Jar>("sourcesJar") {
Expand Down
11 changes: 11 additions & 0 deletions jna/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ plugins {
`java-library`
`maven-publish`
signing
jacoco
}

repositories {
Expand Down Expand Up @@ -57,6 +58,16 @@ java {

tasks.withType<Test> {
useJUnitPlatform()
finalizedBy(tasks.jacocoTestReport)
}

tasks.jacocoTestReport {
dependsOn(tasks.test)

reports {
xml.required = true
html.required = true
}
}

tasks.named<Jar>("sourcesJar") {
Expand Down
13 changes: 12 additions & 1 deletion lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ plugins {
`java-library`
`maven-publish`
signing
jacoco
}

repositories {
Expand Down Expand Up @@ -52,8 +53,18 @@ java {
withJavadocJar()
}

tasks.withType<Test> {
tasks.test {
useJUnitPlatform()
finalizedBy(tasks.jacocoTestReport)
}

tasks.jacocoTestReport {
dependsOn(tasks.test)

reports {
xml.required = true
html.required = true
}
}

tasks.named<Jar>("sourcesJar") {
Expand Down
13 changes: 12 additions & 1 deletion regex/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ plugins {
`java-library`
`maven-publish`
signing
jacoco
}

repositories {
Expand Down Expand Up @@ -54,8 +55,18 @@ java {
withJavadocJar()
}

tasks.withType<Test> {
tasks.test {
useJUnitPlatform()
finalizedBy(tasks.jacocoTestReport)
}

tasks.jacocoTestReport {
dependsOn(tasks.test)

reports {
xml.required = true
html.required = true
}
}

tasks.named<Jar>("sourcesJar") {
Expand Down
11 changes: 11 additions & 0 deletions test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
plugins {
`java-library`
jacoco
}

repositories {
Expand Down Expand Up @@ -50,4 +51,14 @@ java {

tasks.withType<Test> {
useJUnitPlatform()
finalizedBy(tasks.jacocoTestReport)
}

tasks.jacocoTestReport {
dependsOn(tasks.test)

reports {
xml.required = true
html.required = true
}
}

0 comments on commit 9e1189c

Please sign in to comment.