Skip to content

Commit

Permalink
Build update and improvements to CI (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
Doc94 authored Jul 23, 2024
1 parent 69dc003 commit 14fd452
Show file tree
Hide file tree
Showing 21 changed files with 407 additions and 289 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/check_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Check Pull Request

on:
pull_request_target:
types: [ opened ]

jobs:
run:
if: |
github.repository != github.event.pull_request.head.repo.full_name &&
(
(github.head_ref == 'master' || github.head_ref == '3.1.x') ||
github.event.pull_request.head.repo.owner.type != 'User'
)
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
id: "master_branch"
with:
comment: "This Pull Request is created from a restricted branch name. This can cause issues in the maintenance of the Pull Request; please create a new branch instead."
140 changes: 77 additions & 63 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,69 +1,83 @@
name: Java CI

on:
push:
paths:
- '**.gradle'
- '**.properties'
- '**/src/**'
branches:
- 'master'
- '3.1.x'
tags-ignore:
- '*.*'
pull_request:
paths:
- '**.gradle'
- '**.properties'
- '**/src/**'
types: [opened, synchronize, reopened]
workflow_dispatch:
push:
paths:
- '**.gradle'
- '**.properties'
- '**/src/**'
- '.github/workflows/**'
branches:
- 'master'
- '3.1.x'
tags-ignore:
- '*.*'
pull_request:
paths:
- '**.gradle'
- '**.properties'
- '**/src/**'
types: [ opened, synchronize, reopened ]

jobs:
build:
name: Build for JDK ${{ matrix.java }}
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11 ]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Build with Gradle
run: ./gradlew build
if: |
!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.pull_request.title, '[ci skip]')
release:
name: Publish artifacts
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
needs: build
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 8
- name: Publish with Gradle
run: ./gradlew -x test publish
build:
name: Build for JDK ${{ matrix.java }}
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11, 17, 21 ]
steps:
- name: PR Check (PR Blocked by Dependency)
if: ${{ contains(toJson(github.event.pull_request.labels.*.name), 'PR depends on PR') }}
run: echo "::warning::This PR was marked with the label 'PR depends on PR' this can cause issues in building"
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- name: Build with Gradle
run: ./gradlew build
release:
name: Publish artifacts
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' && ( (vars.runReleaseOnPush || 'true') == 'true' || contains(github.event.head_commit.message, '[release]') ) }}
needs: build
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.signingKey }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.signingPassword }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.sonatypeUsername }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.sonatypePassword }}
HAS_CREDENTIALS: ${{ secrets.signingKey != '' && secrets.signingPassword != '' && secrets.sonatypeUsername != '' && secrets.sonatypePassword != '' }}
steps:
- name: Validate repository secrets for publish
if: ${{ env.HAS_CREDENTIALS != 'true' }}
run: |
echo '### Release Failed ❌' >> $GITHUB_STEP_SUMMARY
echo 'This repository does not have all required secrets: signingKey, signingPassword, sonatypeUsername or sonatypePassword).' >> $GITHUB_STEP_SUMMARY
echo "::error::This repository does not have all required secrets: signingKey, signingPassword, sonatypeUsername or sonatypePassword)."
exit -1
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 11
distribution: 'temurin'
- name: Publish with Gradle
run: ./gradlew -x test publish
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.signingKey }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.signingPassword }}
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.sonatypeUsername }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.sonatypePassword }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
[![Support Server Invite](https://img.shields.io/discord/208023865127862272.svg?color=7289da&label=Discord4J&logo=discord&style=flat-square)](https://discord.gg/NxGAeCY)
[![Maven Central](https://img.shields.io/maven-central/v/com.discord4j/stores-api.svg?style=flat-square)](https://search.maven.org/artifact/com.discord4j/stores-api)
[![Javadocs](https://www.javadoc.io/badge/com.discord4j/stores-api.svg?color=blue&style=flat-square)](https://www.javadoc.io/doc/com.discord4j/stores-api)
[![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/Discord4J/Stores/Java%20CI/master?logo=github&style=flat-square)](https://github.com/Discord4J/Stores/actions)
[![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/Discord4J/Stores/gradle.yml?branch=master&logo=github&style=flat-square)](https://github.com/Discord4J/Stores/actions)


A set of pre-made store implementations for Discord4J v3.0 and higher
A set of pre-made store implementations for Discord4J v3.2 and higher

Dependencies:

Expand Down
4 changes: 2 additions & 2 deletions api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ dependencies {
api "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
annotationProcessor "com.austinv11.servicer:Servicer:$servicer_version"

testImplementation "junit:junit:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version"
testAnnotationProcessor "com.austinv11.servicer:Servicer:$servicer_version"
}

jar {
manifest {
attributes 'Implementation-Title': archivesBaseName,
attributes 'Implementation-Title': base.archivesName.get(),
'Implementation-Version': archiveVersion,
'Automatic-Module-Name': 'discord4j.store.api'
}
Expand Down
11 changes: 5 additions & 6 deletions api/src/test/java/discord4j/store/api/service/StoreTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@
import discord4j.store.api.Store;
import discord4j.store.api.noop.NoOpStoreService;
import discord4j.store.api.primitive.ForwardingStoreService;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.util.function.Tuple2;
import reactor.util.function.Tuples;

import java.util.*;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;

public class StoreTests {

Expand All @@ -41,15 +40,15 @@ private Store<String, String> newStore() {
@Test
public void testServiceDiscovery() {
assertTrue(provider.getStoreService() instanceof ForwardingStoreService);
Assert.assertEquals(TestService.class,
assertEquals(TestService.class,
((ForwardingStoreService) provider.getStoreService()).getOriginal().getClass());
}

@Test
public void testGenericFallback() {
assertTrue(provider.getStoreService() instanceof ForwardingStoreService);
assertTrue(provider.getStoreService().hasLongObjStores());
Assert.assertEquals(TestService.class,
assertEquals(TestService.class,
((ForwardingStoreService) provider.getStoreService()).getOriginal().getClass());
}

Expand All @@ -59,7 +58,7 @@ public void testOrder() {
override.put(TestService.class, Integer.MAX_VALUE);
override.put(NoOpStoreService.class, Integer.MIN_VALUE);
StoreServiceLoader overridden = new StoreServiceLoader(override);
Assert.assertEquals(TestService.class,
assertEquals(TestService.class,
((ForwardingStoreService) provider.getStoreService()).getOriginal().getClass());
assertEquals(NoOpStoreService.class, overridden.getStoreService().getClass());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
*/
package discord4j.store.api.util;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import reactor.util.function.Tuple2;
import reactor.util.function.Tuples;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class LongObjTuple2Test {

Expand All @@ -36,9 +37,9 @@ public void testConstruction() {
assertEquals(obj, tuple.getT2());
}

@Test(expected = NullPointerException.class)
@Test
public void testNullObj() {
LongObjTuple2.of(key, null);
assertThrows(NullPointerException.class, () -> LongObjTuple2.of(key, null));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
package discord4j.store.api.util;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.Arrays;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class MappingIterableTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
*/
package discord4j.store.api.util;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class WithinRangePredicateTest {

Expand Down
Loading

0 comments on commit 14fd452

Please sign in to comment.