Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(refactor): Update circleci config to circleci workflowsv2 #3618

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 107 additions & 31 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
version: 2

jobs:
build:
working_directory: /home/reaction
# run automated tests
tests:
working_directory: ~/reaction
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed from /home/reaction to ~/reaction. The 8.9.3-browsers image throws permission denied error on root folder. Any better way?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @impactmass. This is a minor suggestion because I'm sure that this will work as-is. ~ is expanded to home by the shell when it's not prefixed. But ~ is a typing convenience for the command line. In scripts it's generally preferred to use the $HOME var.

See:


That said, you did the right thing. The old path didn't work on that image because the user reaction doesn't exist in circleci/node:8.9.3-browsers and therefore the /home/reaction directory doesn't exist either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I changed to $HOME. With that circleci fails on the checkout step.
Unable to create directory '$HOME/reaction. Not sure why yet.

Also, I did not get this part The old path didn't work on that image because the user reaction doesn't exist ... and therefore the /home/reaction. Were we creating a reaction user in the previous setup?

Copy link
Contributor

@jshimko jshimko Jan 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was never a reaction user. The previous container ran as root. That was just the directory I picked to checkout the code within the image. And ~/ definitely was a problem previously, so that's why I explicitly set it to /home/.


docker:
- image: node:8
- image: circleci/node:8.9.3-browsers
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this per comment made here


environment:
- DOCKER_VERSION: 17.05.0-ce
Expand All @@ -14,62 +15,137 @@ jobs:
- TOOL_NODE_FLAGS: "--max-old-space-size=4096"

steps:
- setup_remote_docker
- checkout

# install OS dependencies
- restore_cache:
name: Restoring Meteor cache
key: meteor
key: meteor-{{ .Branch }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added branch name to the keys for the cache primarily because the old cache that was generated on previous node:8 image is to be linked/restored to root locations on the new 8.9.3 (which also resulted in permission denied errors).


- run: .circleci/install.sh
# Install Meteor
- run: .circleci/install_meteor.sh

- save_cache:
name: Saving Meteor to cache
key: meteor
paths:
- ~/.meteor
# install OS dependencies
- run: sudo apt-get update
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added sudo here (and a couple other places) because the new node image throws permission denied errors on those commands. If there's a better way to this please point me to it...

- run: sudo apt-get install -y locales

# fix Meteor/Mongo locale issue on Debian
# https://github.com/meteor/meteor/issues/4019
- run: sudo locale-gen en_US.UTF-8
- run: sudo localedef -i en_GB -f UTF-8 en_US.UTF-8

# install app dependencies
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}-{{ .Branch }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-{{ .Branch }}

# Install dependencies
- run: meteor npm install

# run tests
- restore_cache:
name: Restoring Meteor dev_bundle cache
key: dev_bundle
key: dev_bundle-{{ .Branch }}

# install Reaction CLI
- run: sudo npm install -g reaction-cli
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done previously with yarn. I switched to npm here (for consistency), but I'll like to know if there's reason why yarn is preferred.


# run reaction tests
- run: .circleci/tests.sh

- save_cache:
name: Saving Meteor dev_bundle to cache
key: dev_bundle
key: dev_bundle-{{ .Branch }}
paths:
- ~/reaction/.meteor/local

- save_cache:
paths:
- /home/reaction/.meteor/local
- ~/reaction/node_modules
key: v1-dependencies-{{ checksum "package.json" }}

- save_cache:
name: Saving Meteor to cache
key: meteor-{{ .Branch }}
paths:
- ~/.meteor


# build a Reaction image and publish to DockerHub
publish:
working_directory: ~/reaction

docker:
- image: node:8.9.3

environment:
- DOCKER_VERSION: 17.05.0-ce
- DOCKER_COMPOSE_VERSION: 1.15.0
- METEOR_ALLOW_SUPERUSER: true
- TOOL_NODE_FLAGS: "--max-old-space-size=4096"

steps:
- setup_remote_docker
- checkout

# Install Docker client & compose
- run: .circleci/install.sh

- run:
command: .circleci/build.sh
no_output_timeout: 30m

- run: .circleci/deploy.sh


# deploy reaction docs
deployDocs:
working_directory: ~/reaction

docker:
- image: node:8.9.3

environment:
- DOCKER_VERSION: 17.05.0-ce
- DOCKER_COMPOSE_VERSION: 1.15.0
- METEOR_ALLOW_SUPERUSER: true
- TOOL_NODE_FLAGS: "--max-old-space-size=4096"

steps:
- checkout

# install OS dependencies
- run: apt-get update
- run: apt-get install -y locales
- run:
command: .reaction/jsdoc/build.sh
no_output_timeout: 2m

# deploy the docs if on master branch
- deploy:
name: Deploy to S3 if tests pass and branch is Master
# deploy the docs if on master branch (based on workflow filter)
- run:
command: |
if [ "${CIRCLE_BRANCH}" == "master" ]; then
if [[ "${API_DOC_BUCKET}" && "${API_DOC_BUCKET_REGION}" ]]; then
aws s3 sync /tmp/reaction-docs ${API_DOC_BUCKET} --delete --region ${API_DOC_BUCKET_REGION}
else
echo "S3 bucket configuration not found for jsdocs"
echo "Set API_DOC_BUCKET and API_DOC_BUCKET_REGION to build and deploy jsdocs to S3"
fi
if [[ "${API_DOC_BUCKET}" && "${API_DOC_BUCKET_REGION}" ]]; then
aws s3 sync /tmp/reaction-docs ${API_DOC_BUCKET} --delete --region ${API_DOC_BUCKET_REGION}
else
echo "Not master branch so not deploying"
echo "S3 bucket configuration not found for jsdocs"
echo "Set API_DOC_BUCKET and API_DOC_BUCKET_REGION to build and deploy jsdocs to S3"
fi
- deploy:
name: Docker Image Deploment
command: .circleci/deploy.sh

workflows:
version: 2

test_publish_deploy:
jobs:
- tests

- publish:
requires:
- tests

- deployDocs:
requires:
- tests
filters:
branches:
only:
- master
25 changes: 0 additions & 25 deletions .circleci/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@

set -x

# install OS dependencies
apt-get update
apt-get install -y locales


# fix Meteor/Mongo locale issue on Debian
# https://github.com/meteor/meteor/issues/4019
locale-gen en_US.UTF-8
localedef -i en_GB -f UTF-8 en_US.UTF-8


# install Docker client
curl -L -o /tmp/docker-$DOCKER_VERSION.tgz https://get.docker.com/builds/Linux/x86_64/docker-$DOCKER_VERSION.tgz
tar -xz -C /tmp -f /tmp/docker-$DOCKER_VERSION.tgz
Expand All @@ -23,17 +12,3 @@ docker -v
# install Docker Compose
curl -L https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose


# install Meteor if it's not already
if [[ -f ~/.meteor/meteor ]]; then
printf "\nMeteor already installed. Creating symlink.\n"
ln -s ~/.meteor/meteor /usr/local/bin/meteor;
else
printf "\Installing Meteor\n"
curl https://install.meteor.com | /bin/sh
fi


# install Reaction CLI
yarn global add reaction-cli
12 changes: 12 additions & 0 deletions .circleci/install_meteor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -x

# install Meteor if it's not already
if [[ -f ~/.meteor/meteor ]]; then
printf "\nMeteor already installed. Creating symlink.\n"
sudo ln -s ~/.meteor/meteor /usr/local/bin/meteor;
else
printf "\Installing Meteor\n"
curl https://install.meteor.com | /bin/sh
fi