From 34e3e5fd86f09652e36de0957876ea00ef8a5a7a Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Wed, 29 Aug 2018 03:25:53 +0300 Subject: [PATCH 1/5] feat(release): replace semantic-release dep with Travis build stages This change moves semantic-release out of dev-dependencies, but keeps its functionality by calling semantic-release as usual in a `release` TravisCI build stage. There are several advantages to this method: 1.) semantic-release is run only after all builds succeed. Our previous approach could have theoretically run semantic-release when some Node.js versions failed with the current code 2.) semantic-release (and it's many dependencies) are removed from `node_modules`. This increases the speed of `npm install` in all cases, and reduces the size of our Docker images by 20MB (from 284MB to 264MB)! Since the only time semantic-release is needed is on TravisCI anyway, it seems pointless that every installation of Pelias should include it. 3.) Because semantic-release is not in `package.json`, Greenkeeper will not attempt to update it. Semantic release updates _very_ frequently, and each update attempt seems to have a decent chance of experiencing a random TravisCI failure, causing unwanted notifications. There are probably downsides to this approach. For example, we should consider pinning the major version of semantic release during install. Additionally, and for obvious reasons, we can't fully test this change until it's merged to the `production` branch. We should consider testing it first on a lower priority repository. If this change _does_ work well, we should consider adopting it everywhere. --- .travis.yml | 7 +++++-- package.json | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5aec4536..e83588fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,11 @@ matrix: script: npm run travis before_install: - npm i -g npm -after_success: - - npx semantic-release branches: except: - /^v\d+\.\d+\.\d+$/ +jobs: + include: + - stage: release + node_js: 10 + script: npx semantic-release diff --git a/package.json b/package.json index 6f2ecf8d..80521db8 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,6 @@ "pelias-mock-logger": "^1.3.0", "precommit-hook": "^3.0.0", "proxyquire": "^2.0.0", - "semantic-release": "^15.1.4", "source-map": "^0.7.0", "tap-dot": "^2.0.0", "tape": "^4.5.1", From 2de274954f122b042488b385053f8a37e72e9b89 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 30 Aug 2018 23:08:43 +0300 Subject: [PATCH 2/5] Use ci-tools script for semantic-release --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e83588fb..5ab053b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,4 +18,4 @@ jobs: include: - stage: release node_js: 10 - script: npx semantic-release + script: curl "https://raw.githubusercontent.com/pelias/ci-tools/master/semantic-release.sh" | bash - From b5ed14011158937a140fbd40fc3fcd6403ab5298 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 30 Aug 2018 23:09:51 +0300 Subject: [PATCH 3/5] Use docker image build script from ci-tools repo --- .circleci/config.yml | 2 +- .circleci/docker.sh | 32 -------------------------------- 2 files changed, 1 insertion(+), 33 deletions(-) delete mode 100644 .circleci/docker.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 8aeea9df..d8fa41df 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,4 +9,4 @@ jobs: - setup_remote_docker - run: name: Build and push image to Docker Hub - command: sh .circleci/docker.sh + command: apk --no-cache add curl && curl "https://raw.githubusercontent.com/pelias/ci-tools/master/build-docker-images.sh" | sh - diff --git a/.circleci/docker.sh b/.circleci/docker.sh deleted file mode 100644 index 0dfa433c..00000000 --- a/.circleci/docker.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -set -u - -# collect params from ENV vars -DATE=`date +%Y-%m-%d` -DOCKER_REPOSITORY="pelias" -DOCKER_PROJECT="${DOCKER_REPOSITORY}/${CIRCLE_PROJECT_REPONAME}" - -BRANCH="$(echo $CIRCLE_BRANCH | tr '/' '-')" #slashes are not valid in docker tags. replace with dashes - -# the name of the image that represents the "branch", that is an image that will be updated over time with the git branch -# the production branch is changed to "latest", otherwise the git branch becomes the name of the version -if [[ "${BRANCH}" == "production" ]]; then - DOCKER_BRANCH_IMAGE_VERSION="latest" -else - DOCKER_BRANCH_IMAGE_VERSION="$BRANCH" -fi -DOCKER_BRANCH_IMAGE_NAME="${DOCKER_PROJECT}:${DOCKER_BRANCH_IMAGE_VERSION}" - -# the name of the image that represents the "tag", that is an image that is named with the date and git commit and will never be changed -DOCKER_TAG_IMAGE_VERSION="${BRANCH}-${DATE}-${CIRCLE_SHA1}" -DOCKER_TAG_IMAGE_NAME="${DOCKER_PROJECT}:${DOCKER_TAG_IMAGE_VERSION}" - -# build image and login to docker hub -docker build -t $DOCKER_PROJECT . -docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" - -# copy the image to each of the two tags, and push -docker tag $DOCKER_PROJECT $DOCKER_BRANCH_IMAGE_NAME -docker tag $DOCKER_PROJECT $DOCKER_TAG_IMAGE_NAME -docker push $DOCKER_BRANCH_IMAGE_NAME -docker push $DOCKER_TAG_IMAGE_NAME From 3360640c434879a19c873010ec2e8022288c38e7 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 30 Aug 2018 23:12:36 +0300 Subject: [PATCH 4/5] Only run semantic-release on production branch --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5ab053b3..3dd2c224 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,3 +19,4 @@ jobs: - stage: release node_js: 10 script: curl "https://raw.githubusercontent.com/pelias/ci-tools/master/semantic-release.sh" | bash - + if: branch = production From fe69061c0c9ad39929adeb60938be29808692a41 Mon Sep 17 00:00:00 2001 From: Julian Simioni Date: Thu, 30 Aug 2018 23:50:07 +0300 Subject: [PATCH 5/5] Update Docker version This fixes an issue with the version of Alpine we're using: --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d8fa41df..3ed292fe 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ jobs: build: working_directory: /app docker: - - image: docker:17.05.0-ce-git + - image: docker:18.06.1-ce-git steps: - checkout - setup_remote_docker