From 54476bab9fc98c3ae0994d77844819fcdb395bda Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Tue, 19 Dec 2017 17:03:55 -0800 Subject: [PATCH] Refactoring a bit of code out of the one big build-plugins script Basically trying to get to a place where we can run scripts semi-independently for testing or overriding of behavior --- Makefile | 9 ++++++--- plugins.txt | 7 ------- plugins.yml | 16 ++++++++++++++++ scripts/build-plugin | 29 +++++++++++++++++++++++++++++ scripts/build-plugins | 14 ++++---------- scripts/plugins-from-yaml | 13 +++++++++++++ scripts/ruby | 8 +++++++- 7 files changed, 75 insertions(+), 21 deletions(-) delete mode 100644 plugins.txt create mode 100644 plugins.yml create mode 100755 scripts/build-plugin create mode 100755 scripts/plugins-from-yaml diff --git a/Makefile b/Makefile index dedf78c..51b20e0 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,11 @@ -IMAGE_PREFIX="rtyler/codevalet" +IMAGE_PREFIX=rtyler/codevalet all: check plugins master -check: agent-templates +check: agent-templates validate-plugins + +validate-plugins: plugins.yml + ./scripts/ruby ./scripts/plugins-from-yaml plugins.yml > /dev/null clean: rm -rf build/ @@ -18,7 +21,7 @@ master: Dockerfile build/git-refs.txt agent-templates plugins: ./scripts/build-plugins plugins.txt builder ./scripts/build-plugins -build/git-refs.txt: +build/git-refs.txt: plugins ./scripts/record-sha1sums ############################################################### diff --git a/plugins.txt b/plugins.txt deleted file mode 100644 index e6d9d43..0000000 --- a/plugins.txt +++ /dev/null @@ -1,7 +0,0 @@ -workflow-aggregator-plugin -blueocean-plugin -github-oauth-plugin -azure-vm-agents-plugin -matrix-auth-plugin -embeddable-build-status-plugin -sentry-plugin diff --git a/plugins.yml b/plugins.yml new file mode 100644 index 0000000..98df159 --- /dev/null +++ b/plugins.yml @@ -0,0 +1,16 @@ +--- +plugins: + - repo: 'workflow-aggregator-plugin' + ref: 'master' + - repo: 'blueocean-plugin' + ref: 'master' + - repo: 'github-oauth-plugin' + ref: 'master' + - repo: 'azure-vm-agents-plugin' + ref: 'master' + - repo: 'matrix-auth-plugin' + ref: 'master' + - repo: 'embeddable-build-status-plugin' + ref: 'master' + - repo: 'sentry-plugin' + ref: 'master' diff --git a/scripts/build-plugin b/scripts/build-plugin new file mode 100755 index 0000000..018bbfa --- /dev/null +++ b/scripts/build-plugin @@ -0,0 +1,29 @@ +#!/bin/sh + +BUILDER_CONTAINER="rtyler/codevalet-builder" + +if [ "${1}" = "" ]; then + echo "The path to a plugin must be passed as the first argument"; + exit 1; +fi; + +if [ ! -d $1 ]; then + echo "The path \`${1}\` is not a directory"; + exit 1; +fi; + +tty --quiet +if [ $? -eq 0 ]; then + TTY="-ti" +fi; + +pushd $1 + if [ -f pom.xml ]; then + echo ">> Building ${1}" + exec docker run --rm ${TTY} \ + -v $HOME/.m2:/root/.m2 \ + -v $PWD:/data \ + -w /data \ + ${BUILDER_CONTAINER} mvn install -e -B -DskipTests + fi; +popd diff --git a/scripts/build-plugins b/scripts/build-plugins index 28b3d1d..f892e5a 100755 --- a/scripts/build-plugins +++ b/scripts/build-plugins @@ -53,7 +53,7 @@ pushd $REPOS_DIR (cd js-libs-plugin && find . -maxdepth 1 -type d -exec mkdir -p {}/src/main/webapp/jsmodules \;) - for plugin in $(cat $SCRIPTS_DIR/../plugins.txt); do + for plugin in $(${SCRIPTS_DIR}/plugins-from-yaml $SCRIPTS_DIR/../plugins.yml); do cloneWithDependencies $plugin done; @@ -61,17 +61,11 @@ pushd $REPOS_DIR rm -rf blueocean-pipeline-editor-plugin set -e - for d in *-plugin; do - pushd $d - if [ -f pom.xml ]; then - echo ">> Building $d" - git pull --rebase - docker run --rm ${TTY_ARGS} -v $HOME/.m2:/root/.m2 \ - -v $PWD:/data -w /data ${BUILDER_CONTAINER} mvn install -e -B -DskipTests - fi; - popd + for d in *-plugin; do + ./scripts/build-plugin $d done; + set +e # Handle an old tombstoned dependency which will not build from source diff --git a/scripts/plugins-from-yaml b/scripts/plugins-from-yaml new file mode 100755 index 0000000..dbf4336 --- /dev/null +++ b/scripts/plugins-from-yaml @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby + +require 'yaml' + +raise 'A file must be given as the first argument' if ARGV.size != 1 + +data = YAML.load(File.read(ARGV.first)) + +# By default we'll just output the names so we can easily loop over this in the +# shell +data['plugins'].each do |plugin| + puts plugin['repo'] +end diff --git a/scripts/ruby b/scripts/ruby index 4c268f9..21efa27 100755 --- a/scripts/ruby +++ b/scripts/ruby @@ -1,6 +1,12 @@ #!/bin/sh -exec docker run --rm \ +tty --quiet + +if [ $? -eq 0 ]; then + TTY="-ti" +fi; + +exec docker run --rm ${TTY} \ -v ${PWD}:${PWD} \ -w ${PWD} \ ruby:2-alpine $@