Skip to content

Commit 14ccca6

Browse files
Updating to github actions (#155)
* Updating to github actions - testing the PR build - testing and releasing an exp version of the jar via Java 15 - making a stable release Also updated the plugin version nd the min GoCD version to 20.9.0 * Adding jobs for testing the plugin on various docker versions * Remove 17.03.2-ce based job as the same has reached EOL
1 parent 25e1e3d commit 14ccca6

5 files changed

Lines changed: 251 additions & 2 deletions

File tree

.github/workflows/pr_workflow.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# This workflow will build a Java project with Gradle
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3+
4+
name: Testing For PRs
5+
6+
on: [ pull_request ]
7+
8+
jobs:
9+
test-on-17_06_2-ce:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- name: Set up JDK
14+
uses: actions/setup-java@v1
15+
with:
16+
java-version: 15
17+
- name: Set up docker 17.06.2-ce
18+
run: |
19+
curl -sL https://howtowhale.github.io/dvm/downloads/latest/install.sh | sh
20+
source ~/.dvm/dvm.sh; dvm install 17.06.2-ce
21+
source ~/.dvm/dvm.sh; dvm use 17.06.2-ce && docker swarm init && docker version
22+
- name: Build with Gradle
23+
run: ./gradlew assemble check
24+
test-on-17_09_1-ce:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v2
28+
- name: Set up JDK
29+
uses: actions/setup-java@v1
30+
with:
31+
java-version: 15
32+
- name: Set up docker 17.09.1-ce
33+
run: |
34+
curl -sL https://howtowhale.github.io/dvm/downloads/latest/install.sh | sh
35+
source ~/.dvm/dvm.sh; dvm install 17.09.1-ce
36+
source ~/.dvm/dvm.sh; dvm use 17.09.1-ce && docker swarm init && docker version
37+
- name: Build with Gradle
38+
run: ./gradlew assemble check
39+
test-on-17_12_1-ce:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v2
43+
- name: Set up JDK
44+
uses: actions/setup-java@v1
45+
with:
46+
java-version: 15
47+
- name: Set up docker 17.12.1-ce
48+
run: |
49+
curl -sL https://howtowhale.github.io/dvm/downloads/latest/install.sh | sh
50+
source ~/.dvm/dvm.sh; dvm install 17.12.1-ce
51+
source ~/.dvm/dvm.sh; dvm use 17.12.1-ce && docker swarm init && docker version
52+
- name: Build with Gradle
53+
run: ./gradlew assemble check
54+
test-on-18_03_1-ce:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v2
58+
- name: Set up JDK
59+
uses: actions/setup-java@v1
60+
with:
61+
java-version: 15
62+
- name: Set up docker 18.03.1-ce
63+
run: |
64+
curl -sL https://howtowhale.github.io/dvm/downloads/latest/install.sh | sh
65+
source ~/.dvm/dvm.sh; dvm install 18.03.1-ce
66+
source ~/.dvm/dvm.sh; dvm use 18.03.1-ce && docker swarm init && docker version
67+
- name: Build with Gradle
68+
run: ./gradlew assemble check
69+
test-on-18_06_3-ce:
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@v2
73+
- name: Set up JDK
74+
uses: actions/setup-java@v1
75+
with:
76+
java-version: 15
77+
- name: Set up docker 18.06.3-ce
78+
run: |
79+
curl -sL https://howtowhale.github.io/dvm/downloads/latest/install.sh | sh
80+
source ~/.dvm/dvm.sh; dvm install 18.06.3-ce
81+
source ~/.dvm/dvm.sh; dvm use 18.06.3-ce && docker swarm init && docker version
82+
- name: Build with Gradle
83+
run: ./gradlew assemble check
84+
test-on-18_09_6:
85+
runs-on: ubuntu-latest
86+
steps:
87+
- uses: actions/checkout@v2
88+
- name: Set up JDK
89+
uses: actions/setup-java@v1
90+
with:
91+
java-version: 15
92+
- name: Set up docker 18.09.6
93+
run: |
94+
curl -sL https://howtowhale.github.io/dvm/downloads/latest/install.sh | sh
95+
source ~/.dvm/dvm.sh; dvm install 18.09.6
96+
source ~/.dvm/dvm.sh; dvm use 18.09.6 && docker swarm init && docker version
97+
- name: Build with Gradle
98+
run: ./gradlew assemble check

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
name: Create Stable Release
3+
4+
# Controls when the action will run. Workflow runs when manually triggered using the UI
5+
# or API.
6+
on:
7+
workflow_dispatch:
8+
# Inputs the workflow accepts.
9+
inputs:
10+
prerelease:
11+
description: 'The release should be an experimental release'
12+
default: 'NO'
13+
required: true
14+
15+
jobs:
16+
build_and_release:
17+
runs-on: ubuntu-latest
18+
env:
19+
GITHUB_USER: "gocd-contrib"
20+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
21+
PRERELEASE: "${{ github.event.inputs.prerelease }}"
22+
steps:
23+
- uses: actions/checkout@v2
24+
with:
25+
fetch-depth: 0
26+
- name: Set up JDK
27+
uses: actions/setup-java@v1
28+
with:
29+
java-version: 15
30+
- name: Release
31+
run: ./gradlew githubRelease
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# This workflow will build a Java project with Gradle
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
3+
4+
name: Test and Build
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
10+
jobs:
11+
test-on-17_06_2-ce:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Set up JDK
16+
uses: actions/setup-java@v1
17+
with:
18+
java-version: 15
19+
- name: Set up docker 17.06.2-ce
20+
run: |
21+
curl -sL https://howtowhale.github.io/dvm/downloads/latest/install.sh | sh
22+
source ~/.dvm/dvm.sh; dvm install 17.06.2-ce
23+
source ~/.dvm/dvm.sh; dvm use 17.06.2-ce && docker swarm init && docker version
24+
- name: Build with Gradle
25+
run: ./gradlew assemble check
26+
test-on-17_09_1-ce:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v2
30+
- name: Set up JDK
31+
uses: actions/setup-java@v1
32+
with:
33+
java-version: 15
34+
- name: Set up docker 17.09.1-ce
35+
run: |
36+
curl -sL https://howtowhale.github.io/dvm/downloads/latest/install.sh | sh
37+
source ~/.dvm/dvm.sh; dvm install 17.09.1-ce
38+
source ~/.dvm/dvm.sh; dvm use 17.09.1-ce && docker swarm init && docker version
39+
- name: Build with Gradle
40+
run: ./gradlew assemble check
41+
test-on-17_12_1-ce:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v2
45+
- name: Set up JDK
46+
uses: actions/setup-java@v1
47+
with:
48+
java-version: 15
49+
- name: Set up docker 17.12.1-ce
50+
run: |
51+
curl -sL https://howtowhale.github.io/dvm/downloads/latest/install.sh | sh
52+
source ~/.dvm/dvm.sh; dvm install 17.12.1-ce
53+
source ~/.dvm/dvm.sh; dvm use 17.12.1-ce && docker swarm init && docker version
54+
- name: Build with Gradle
55+
run: ./gradlew assemble check
56+
test-on-18_03_1-ce:
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v2
60+
- name: Set up JDK
61+
uses: actions/setup-java@v1
62+
with:
63+
java-version: 15
64+
- name: Set up docker 18.03.1-ce
65+
run: |
66+
curl -sL https://howtowhale.github.io/dvm/downloads/latest/install.sh | sh
67+
source ~/.dvm/dvm.sh; dvm install 18.03.1-ce
68+
source ~/.dvm/dvm.sh; dvm use 18.03.1-ce && docker swarm init && docker version
69+
- name: Build with Gradle
70+
run: ./gradlew assemble check
71+
test-on-18_06_3-ce:
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@v2
75+
- name: Set up JDK
76+
uses: actions/setup-java@v1
77+
with:
78+
java-version: 15
79+
- name: Set up docker 18.06.3-ce
80+
run: |
81+
curl -sL https://howtowhale.github.io/dvm/downloads/latest/install.sh | sh
82+
source ~/.dvm/dvm.sh; dvm install 18.06.3-ce
83+
source ~/.dvm/dvm.sh; dvm use 18.06.3-ce && docker swarm init && docker version
84+
- name: Build with Gradle
85+
run: ./gradlew assemble check
86+
test-on-18_09_6:
87+
runs-on: ubuntu-latest
88+
steps:
89+
- uses: actions/checkout@v2
90+
- name: Set up JDK
91+
uses: actions/setup-java@v1
92+
with:
93+
java-version: 15
94+
- name: Set up docker 18.09.6
95+
run: |
96+
curl -sL https://howtowhale.github.io/dvm/downloads/latest/install.sh | sh
97+
source ~/.dvm/dvm.sh; dvm install 18.09.6
98+
source ~/.dvm/dvm.sh; dvm use 18.09.6 && docker swarm init && docker version
99+
- name: Build with Gradle
100+
run: ./gradlew assemble check
101+
previewGithubRelease:
102+
needs: [test-on-17_06_2-ce, test-on-17_09_1-ce, test-on-17_12_1-ce, test-on-18_03_1-ce, test-on-18_06_3-ce, test-on-18_09_6]
103+
runs-on: ubuntu-latest
104+
env:
105+
GITHUB_USER: "gocd-contrib"
106+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
107+
steps:
108+
- uses: actions/checkout@v2
109+
with:
110+
fetch-depth: 0
111+
- name: Set up JDK
112+
uses: actions/setup-java@v1
113+
with:
114+
java-version: 15
115+
- name: Test with Gradle
116+
run: ./gradlew githubRelease

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ apply plugin: 'java'
1818
apply from: "https://raw.githubusercontent.com/gocd/gocd-plugin-gradle-task-helpers/master/helper.gradle?_=${(int) (new Date().toInstant().epochSecond / 60)}"
1919
gocdPlugin {
2020
id = 'cd.go.contrib.elastic-agent.docker-swarm'
21-
pluginVersion = '5.1.0'
22-
goCdVersion = '19.3.0'
21+
pluginVersion = '5.2.0'
22+
goCdVersion = '20.9.0'
2323
name = 'GoCD Docker Swarm Elastic Agents'
2424
description = 'Docker Swarm Based Elastic Agent Plugins for GoCD'
2525
vendorName = 'ThoughtWorks, Inc.'

src/main/java/cd/go/contrib/elasticagents/dockerswarm/elasticagent/utils/Size.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import static com.google.common.base.Preconditions.checkArgument;
2929
import static java.util.Objects.requireNonNull;
30+
import static org.apache.commons.lang.StringUtils.isBlank;
3031

3132
public class Size implements Comparable<Size> {
3233
private static final Pattern SIZE_PATTERN = Pattern.compile("(\\d+)\\s*(\\S+)");
@@ -79,6 +80,9 @@ public static Size terabytes(long count) {
7980

8081
@JsonCreator
8182
public static Size parse(String size) {
83+
if (isBlank(size)) {
84+
throw new IllegalArgumentException();
85+
}
8286
final Matcher matcher = SIZE_PATTERN.matcher(size);
8387
checkArgument(matcher.matches(), "Invalid size: " + size);
8488

0 commit comments

Comments
 (0)