From 7874be5b087d48fbce792102e91a6edac8666bea Mon Sep 17 00:00:00 2001 From: Greg Turnquist Date: Wed, 12 Dec 2018 13:36:52 -0600 Subject: [PATCH] #764 - Introduce Concourse CI. Introduces pipeline that replaces the Bambook Spring HATEOAS one which builds on master branch and deploys to artifactory. Additionally: * Tests against JDK 8, 11, and 12 before doing the final build and deploy. * Also handles pull requests, running same suite of tests against mutiple JDKs. --- .gitignore | 3 +- .travis.yml | 18 -- ci/README.adoc | 38 ++++ ci/build.sh | 14 ++ ci/build.yml | 20 +++ ci/pipeline-template.yml | 368 +++++++++++++++++++++++++++++++++++++++ ci/test.sh | 11 ++ ci/test.yml | 17 ++ pom.xml | 90 ++++++---- 9 files changed, 526 insertions(+), 53 deletions(-) delete mode 100644 .travis.yml create mode 100644 ci/README.adoc create mode 100755 ci/build.sh create mode 100644 ci/build.yml create mode 100644 ci/pipeline-template.yml create mode 100755 ci/test.sh create mode 100644 ci/test.yml diff --git a/.gitignore b/.gitignore index 89216b36..ac7bd0b5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ target/ *.iml .idea *.orig -.springBeans \ No newline at end of file +.springBeans +credentials.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0ac889fc..00000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: java -jdk: - - oraclejdk8 -env: - matrix: - - PROFILE=non-existant - - PROFILE=spring5-next - - PROFILE=spring51-next -addons: - apt: - packages: - - oracle-java8-installer -cache: - directories: - - $HOME/.m2 -sudo: false -install: true -script: "./mvnw clean dependency:list test -P${PROFILE} -Dsort" diff --git a/ci/README.adoc b/ci/README.adoc new file mode 100644 index 00000000..a8d9d2b8 --- /dev/null +++ b/ci/README.adoc @@ -0,0 +1,38 @@ +== Spring HATEOAS CI + +Spring HATEOAS uses Concourse as it's CI tool of choice. This provides support for: + +* Pipeline against the `master` branch +* Support for pull requests + +=== Creating a pipeline + +Using the `fly` command, you can execute a series of commands to create multiple pipelines to manage everything. But +first, some critical credentials are needed. + +Create a `credentials.yml` file like this: + +[source,yml] +---- +github-access-token: +docker-email: +docker-username: +docker-password: +artifactory-username: +artifactory-password: +---- + +WARNING: Do NOT check this file into source control! If you'll check, `credentials.yml` is listed in `.gitignore` to prevent this. + +With this in place, run the following `fly` commands to create pipelines: + +---- +% fly -t spring-data sp -p spring-hateoas -c ci/pipeline-template.yml -l credentials.yml -v branch=master +---- + +With this pipeline in place, you can now activate and expose it: + +---- +% fly -t spring-data unpause-pipeline -p spring-hateoas +% fly -t spring-data expose-pipeline -p spring-hateoas +---- \ No newline at end of file diff --git a/ci/build.sh b/ci/build.sh new file mode 100755 index 00000000..a40cd2f0 --- /dev/null +++ b/ci/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -euo pipefail + +[[ -d $PWD/maven && ! -d $HOME/.m2 ]] && ln -s $PWD/maven $HOME/.m2 + +spring_hateoas_artifactory=$(pwd)/spring-hateoas-artifactory + +rm -rf $HOME/.m2/repository/org/springframework/hateoas 2> /dev/null || : + +cd spring-hateoas-github + +./mvnw -Pdistribute -Dmaven.test.skip=true clean deploy \ + -DaltDeploymentRepository=distribution::default::file://${spring_hateoas_artifactory} diff --git a/ci/build.yml b/ci/build.yml new file mode 100644 index 00000000..124d2d35 --- /dev/null +++ b/ci/build.yml @@ -0,0 +1,20 @@ +--- +platform: linux + +image_resource: + type: docker-image + source: + repository: openjdk + tag: 8-jdk + +inputs: +- name: spring-hateoas-github + +outputs: +- name: spring-hateoas-artifactory + +caches: +- path: maven + +run: + path: spring-hateoas-github/ci/build.sh diff --git a/ci/pipeline-template.yml b/ci/pipeline-template.yml new file mode 100644 index 00000000..b2742477 --- /dev/null +++ b/ci/pipeline-template.yml @@ -0,0 +1,368 @@ +--- +resource_types: +- name: artifactory-resource + type: docker-image + source: + repository: springio/artifactory-resource + tag: 0.0.6 + +- name: github-status + type: docker-image + source: + repository: dpb587/github-status-resource + tag: master + +- name: pull-request + type: docker-image + source: + repository: jtarchie/pr + tag: latest + +- name: slack-notification + type: docker-image + source: + repository: nebhale/slack-notification-resource + +resources: +- name: openjdk:8-jdk + type: docker-image + source: + repository: openjdk + tag: 8-jdk + +- name: openjdk:11-jdk + type: docker-image + source: + repository: openjdk + tag: 11-jdk + +- name: openjdk:12-jdk + type: docker-image + source: + repository: openjdk + tag: 12-jdk + +- name: spring-hateoas-github + type: git + source: + uri: https://github.com/spring-projects/spring-hateoas.git + branch: ((branch)) + +- name: spring-hateoas-artifactory + type: artifactory-resource + source: + uri: https://repo.spring.io + username: ((artifactory-username)) + password: ((artifactory-password)) + build_name: spring-hateoas + +- name: spring-hateoas-pull-requests + type: pull-request + source: + access_token: ((github-access-token)) + repo: spring-projects/spring-hateoas + base: ((branch)) + +- name: spring-hateoas-status + type: github-status + source: + access_token: ((github-access-token)) + repository: spring-projects/spring-hateoas + branch: ((branch)) + +- name: slack + type: slack-notification + source: + url: ((slack)) + +groups: +- name: spring-hateoas + jobs: + - Test - JDK 8 + - Test - JDK 8 and Spring 5.0 (snapshots) + - Test - JDK 8 and Spring 5.1 (snapshots) + - Test - JDK 11 + - Test - JDK 11 and Spring 5.0 (snapshots) + - Test - JDK 11 and Spring 5.1 (snapshots) + - Test - JDK 12 + - Test - JDK 12 and Spring 5.0 (snapshots) + - Test - JDK 12 and Spring 5.1 (snapshots) + - Build +- name: pull-requests + jobs: + - spring-hateoas-pull-requests + +jobs: +- name: Test - JDK 8 + serial: true + public: true + plan: + - get: spring-hateoas-github + trigger: true + - get: openjdk:8-jdk + trigger: true + - task: test + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "non-existent" } + <<: *slack-failure + +- name: Test - JDK 8 and Spring 5.0 (snapshots) + serial: true + public: true + plan: + - get: spring-hateoas-github + trigger: true + - get: openjdk:8-jdk + trigger: true + - task: test + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "spring5-next" } + <<: *slack-failure + +- name: Test - JDK 8 and Spring 5.1 (snapshots) + serial: true + public: true + plan: + - get: spring-hateoas-github + trigger: true + - get: openjdk:8-jdk + trigger: true + - task: test + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "spring51-next" } + <<: *slack-failure + +- name: Test - JDK 11 + serial: true + public: true + plan: + - get: spring-hateoas-github + trigger: true + - get: openjdk:11-jdk + trigger: true + - task: test + image: openjdk:11-jdk + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "non-existant" } + <<: *slack-failure + +- name: Test - JDK 11 and Spring 5.0 (snapshots) + serial: true + public: true + plan: + - get: spring-hateoas-github + trigger: true + - get: openjdk:11-jdk + trigger: true + - task: test + image: openjdk:11-jdk + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "spring5-next" } + <<: *slack-failure + +- name: Test - JDK 11 and Spring 5.1 (snapshots) + serial: true + public: true + plan: + - get: spring-hateoas-github + trigger: true + - get: openjdk:11-jdk + trigger: true + - task: test + image: openjdk:11-jdk + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "spring51-next" } + <<: *slack-failure + +- name: Test - JDK 12 + serial: true + public: true + plan: + - get: spring-hateoas-github + trigger: true + - get: openjdk:12-jdk + trigger: true + - task: test + image: openjdk:12-jdk + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "non-existant" } + <<: *slack-failure + +- name: Test - JDK 12 and Spring 5.0 (snapshots) + serial: true + public: true + plan: + - get: spring-hateoas-github + trigger: true + - get: openjdk:12-jdk + trigger: true + - task: test + image: openjdk:12-jdk + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "spring5-next" } + <<: *slack-failure + +- name: Test - JDK 12 and Spring 5.1 (snapshots) + serial: true + public: true + plan: + - get: spring-hateoas-github + trigger: true + - get: openjdk:12-jdk + trigger: true + - task: test + image: openjdk:12-jdk + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "spring51-next" } + <<: *slack-failure + +- name: Build + serial: true + public: true + plan: + - get: spring-hateoas-github + trigger: true + passed: [ + Test - JDK 8, + Test - JDK 8 and Spring 5.0 (snapshots), + Test - JDK 8 and Spring 5.1 (snapshots), + Test - JDK 11, + Test - JDK 11 and Spring 5.0 (snapshots), + Test - JDK 11 and Spring 5.1 (snapshots), + Test - JDK 12, + Test - JDK 12 and Spring 5.0 (snapshots), + Test - JDK 12 and Spring 5.1 (snapshots) + ] + - put: spring-hateoas-status + params: + commit: spring-hateoas-github + state: pending + - task: build + file: spring-hateoas-github/ci/build.yml + - put: spring-hateoas-artifactory + params: + build_number: ${BUILD_NAME} + build_uri: ${ATC_EXTERNAL_URL}/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME} + repo: libs-snapshot-local + folder: spring-hateoas-artifactory + artifact_set: + - include: + - "/**" + properties: + archives: '*:*:*:*@zip zip.name:spring-hateoas, zip.displayname:Spring HATEOAS, zip.deployed:false' + on_failure: + aggregate: + - put: spring-hateoas-status + params: + commit: spring-hateoas-github + state: failure + - put: slack + params: + attachments: + - color: danger + fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME " + text: "Build has failed" + title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME" + title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME + on_success: + aggregate: + - put: spring-hateoas-status + params: + commit: spring-hateoas-github + state: success + - put: slack + params: + attachments: + - color: good + fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME " + text: "Build has succeeded!" + title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME" + title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME + +- name: spring-hateoas-pull-requests + public: true + plan: + - get: spring-hateoas-github + resource: spring-hateoas-pull-requests + trigger: true + version: every + - get: openjdk:11-jdk + - put: spring-hateoas-pull-requests + params: + path: spring-hateoas-github + status: pending + - aggregate: + - task: test (JDK 8) + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "non-existent" } + - task: test (JDK 8 and Spring 5.0 snapshots) + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "spring5-next" } + - task: test (JDK 8 and Spring 5.1 snapshots) + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "spring51-next" } + - task: test (JDK 11) + image: openjdk:11-jdk + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "non-existent" } + - task: test (JDK 11 and Spring 5.0 snapshots) + image: openjdk:11-jdk + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "spring5-next" } + - task: test (JDK 11 and Spring 5.1 snapshots) + image: openjdk:11-jdk + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "spring51-next" } + - task: test (JDK 12) + image: openjdk:12-jdk + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "non-existent" } + - task: test (JDK 12 and Spring 5.0 snapshots) + image: openjdk:12-jdk + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "spring5-next" } + - task: test (JDK 12 and Spring 5.1 snapshots) + image: openjdk:12-jdk + file: spring-hateoas-github/ci/test.yml + params: { PROFILE: "spring51-next" } + on_failure: + aggregate: + - put: spring-hateoas-pull-requests + params: + path: spring-hateoas-github + status: failure + - put: slack + params: + attachments: + - color: danger + fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME " + text: "Pull request has failed" + title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME" + title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME + on_success: + aggregate: + - put: spring-hateoas-pull-requests + params: + path: spring-hateoas-github + status: success + - put: slack + params: + attachments: + - color: good + fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME " + text: "Pull request has succeeded!" + title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME" + title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME + +slack-failure: &slack-failure + on_failure: + put: slack + params: + attachments: + - color: danger + fallback: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME " + text: "Test has failed" + title: "$BUILD_PIPELINE_NAME/$BUILD_JOB_NAME #$BUILD_NAME" + title_link: $ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME + + diff --git a/ci/test.sh b/ci/test.sh new file mode 100755 index 00000000..570e22ce --- /dev/null +++ b/ci/test.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -euo pipefail + +[[ -d $PWD/maven && ! -d $HOME/.m2 ]] && ln -s $PWD/maven $HOME/.m2 + +rm -rf $HOME/.m2/repository/org/springframework/hateoas 2> /dev/null || : + +cd spring-hateoas-github + +./mvnw clean dependency:list test -P${PROFILE} -Dsort diff --git a/ci/test.yml b/ci/test.yml new file mode 100644 index 00000000..b465b3a0 --- /dev/null +++ b/ci/test.yml @@ -0,0 +1,17 @@ +--- +platform: linux + +image_resource: + type: docker-image + source: + repository: openjdk + tag: 8-jdk + +inputs: +- name: spring-hateoas-github + +caches: +- path: maven + +run: + path: spring-hateoas-github/ci/test.sh diff --git a/pom.xml b/pom.xml index 82dd085b..a5a777b7 100644 --- a/pom.xml +++ b/pom.xml @@ -351,10 +351,47 @@ + + package-and-attach-docs-zip + package + + run + + + + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.10 + + + attach-zip + + attach-artifact + + + + + ${project.build.directory}/${project.artifactId}-${project.version}.zip + zip + + + + + + + org.apache.maven.plugins maven-assembly-plugin @@ -377,32 +414,6 @@ - - org.codehaus.mojo - wagon-maven-plugin - 1.0 - - ${project.build.directory} - - - - upload-static-resources - deploy - - upload - - - ${project.build.directory}/static-resources - ** - static-dot-s2 - scp://docs.af.pivotal.io - /var/www/domains/spring.io/www/htdocs/autorepo/docs/${project.artifactId}/${project.version} - true - - - - - @@ -582,13 +593,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.6.1 + 3.8.0 ${source.level} ${source.level} - - true - @@ -631,21 +639,35 @@ ${source.level} true -Xdoclint:none - ${shared.resources}/javadoc/spring-javadoc.css + ${basedir}/src/main/javadoc/spring-javadoc.css http://static.springframework.org/spring/docs/4.1.x/javadoc-api http://docs.oracle.com/javase/6/docs/api + + + attach-javadocs + + jar + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 + + false + org.apache.maven.plugins maven-deploy-plugin 2.8.2 - - true -