diff --git a/.circleci/config.yml b/.circleci/config.yml index 6492ce2..20a8cc6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ defaults: &defaults environment: JVM_OPTS: -Xmx3200m TERM: dumb - CI: true + CI_NAME: "CircleCI" defaults_gradle: &defaults_gradle steps: diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..82c3591 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,26 @@ +name: Java CI with Gradle + +on: + push + pull_request + workflow_dispatch + + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - name: Set environment variables + env: + CI_NAME: "GitHub CI" + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Test with Gradle + run: ./gradlew check diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..1e06d44 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,32 @@ +image: openjdk:11-jdk-slim + +variables: + GRADLE_OPTS: "-Dorg.gradle.daemon=false" + CI_NAME: "GitLab CI" + +before_script: + - export GRADLE_USER_HOME=`pwd`/.gradle + +stages: + - build + - test + +build: + stage: build + script: ./gradlew --build-cache assemble + cache: + key: "$CI_COMMIT_REF_NAME" + policy: push + paths: + - build + - .gradle + +test: + stage: test + script: ./gradlew check + cache: + key: "$CI_COMMIT_REF_NAME" + policy: pull + paths: + - build + - .gradle diff --git a/.travis.yml b/.travis.yml index dd5e66d..991c643 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ dist: trusty env: global: - - CI=true + - CI_NAME: "Travis CI" install: - git fetch --unshallow --tags diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml new file mode 100644 index 0000000..219c29f --- /dev/null +++ b/bitbucket-pipelines.yml @@ -0,0 +1,9 @@ +image: openjdk:11 + +pipelines: + default: + - step: + caches: + - gradle + script: + - bash ./gradlew check diff --git a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java index 7f1bb5d..1289405 100644 --- a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java +++ b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java @@ -188,12 +188,12 @@ public class Mobibot extends PircBot { setVerbose(true); setAutoNickChange(true); setLogin(p.getProperty("login", getName())); - setVersion(p.getProperty("weblog", "")); + setVersion(ReleaseInfo.PROJECT + ' ' + ReleaseInfo.VERSION); // setMessageDelay(1000); setIdentity(p.getProperty("ident", ""), p.getProperty("ident-nick", ""), p.getProperty("ident-msg", "")); // Set the URLs - setWeblogUrl(getVersion()); + setWeblogUrl(p.getProperty("weblog", "")); setBacklogsUrl(Utils.ensureDir(p.getProperty("backlogs", weblogUrl), true)); // Set the pinboard authentication @@ -404,7 +404,6 @@ public class Mobibot extends PircBot { } } } - setVersion(ReleaseInfo.PROJECT + ' ' + ReleaseInfo.VERSION); identify(); joinChannel(); } diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/ChannelFeed.kt b/src/main/java/net/thauvin/erik/mobibot/commands/ChannelFeed.kt index 1211fcb..f371422 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/ChannelFeed.kt +++ b/src/main/java/net/thauvin/erik/mobibot/commands/ChannelFeed.kt @@ -62,7 +62,7 @@ class ChannelFeed(bot: Mobibot, channel: String) : AbstractCommand(bot) { isPrivate: Boolean ) { with(getProperty(FEED_PROP)) { - if (!this.isNullOrBlank()) { + if (!isNullOrBlank()) { Thread(FeedReader(bot, sender, this)).start() } else { bot.send(sender, "There is no feed setup for this channel.", false) diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Info.java b/src/main/java/net/thauvin/erik/mobibot/commands/Info.java index 2beab74..aed639c 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Info.java +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Info.java @@ -44,8 +44,8 @@ import java.util.List; public class Info extends AbstractCommand { private final List version = List.of( - StringUtils.capitalize(ReleaseInfo.PROJECT) + " " + ReleaseInfo.VERSION + " (" - + Utils.green(ReleaseInfo.WEBSITE) + ')', + StringUtils.capitalize(ReleaseInfo.PROJECT) + " " + ReleaseInfo.VERSION + + " (" + Utils.green(ReleaseInfo.WEBSITE) + ')', "Written by " + ReleaseInfo.AUTHOR + " (" + Utils.green(ReleaseInfo.AUTHOR_URL) + ')'); public Info(@NotNull final Mobibot bot) { diff --git a/src/main/java/net/thauvin/erik/mobibot/commands/Versions.java b/src/main/java/net/thauvin/erik/mobibot/commands/Versions.java index 37491da..4b08631 100644 --- a/src/main/java/net/thauvin/erik/mobibot/commands/Versions.java +++ b/src/main/java/net/thauvin/erik/mobibot/commands/Versions.java @@ -42,13 +42,10 @@ import java.util.List; public class Versions extends AbstractCommand { private final List verList = List.of("Version: " + ReleaseInfo.VERSION + " (" + Utils.isoLocalDate(ReleaseInfo.BUILDDATE) + ')', - "Platform: " + System.getProperty("os.name") + " (" + System.getProperty("os.version") + ", " - + System.getProperty("os.arch") + ", " + System.getProperty("user.country") + ')', - "Runtime: " + System.getProperty("java.runtime.name") + " (build " + System.getProperty( - "java.runtime.version") + ')', - "VM: " + System.getProperty("java.vm.name") + " (build " + System.getProperty("java.vm.version") - + ", " - + System.getProperty("java.vm.info") + ')'); + "Platform: " + System.getProperty("os.name") + ' ' + System.getProperty("os.version") + + " (" + System.getProperty("os.arch") + ')', + "Runtime: " + System.getProperty("java.runtime.name") + + ' ' + System.getProperty("java.runtime.version")); public Versions(@NotNull final Mobibot bot) { super(bot); diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/TwitterTest.java b/src/test/java/net/thauvin/erik/mobibot/modules/TwitterTest.java index 88782ad..2c14d2b 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/TwitterTest.java +++ b/src/test/java/net/thauvin/erik/mobibot/modules/TwitterTest.java @@ -51,10 +51,9 @@ import static org.assertj.core.api.Assertions.assertThat; public class TwitterTest extends LocalProperties { @SuppressFBWarnings("MDM") private String getCi() { - if ("true".equals(System.getenv("CIRCLECI"))) { - return "CircleCI"; - } else if ("true".equals(System.getenv("TRAVIS"))) { - return "Travis CI"; + final String ciName = System.getenv("CI_NAME"); + if (ciName != null) { + return ciName; } else { try { return InetAddress.getLocalHost().getHostName();