Skip to content

Commit

Permalink
Merge pull request #603 from reactioncommerce/release-v2.8.0
Browse files Browse the repository at this point in the history
release v2.8.0
  • Loading branch information
machikoyasuda authored Oct 30, 2019
2 parents 6acad71 + 5d993c8 commit 5c67fb6
Show file tree
Hide file tree
Showing 13 changed files with 128 additions and 275 deletions.
244 changes: 78 additions & 166 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,93 +10,83 @@ version: 2
# typing. See http://yaml.org/type/merge.html for details.
defaults: &defaults
environment:
- DOCKER_REPOSITORY: "reactioncommerce/reaction-next-starterkit"
- DOCKER_NAMESPACE: "reactioncommerce"
- DOCKER_NAME: "reaction-next-starterkit"
- GLOBAL_CACHE_VERSION: “v3”
- KUSTOMIZE_VERSION: "3.2.1"
- HUB_VERSION: "2.12.8"
- GH_USERNAME: "rc-circleci"
- GH_EMAIL: "circleci@reactioncommerce.com"
- REACTION_GITOPS_REVIEWERS: "griggheo"

CI_SCRIPTS: 'npx --quiet --package @reactioncommerce/ci-scripts@1.6.2'
DOCKER_REPOSITORY: "reactioncommerce/example-storefront"
DOCKER_NAMESPACE: "reactioncommerce"
DOCKER_NAME: "example-storefront"
GLOBAL_CACHE_VERSION: "v3"
KUSTOMIZE_VERSION: "3.2.1"
HUB_VERSION: "2.12.8"
GH_USERNAME: "rc-circleci"
GH_EMAIL: "circleci@reactioncommerce.com"
REACTION_GITOPS_REVIEWERS: "griggheo"
docker:
- image: circleci/node:10-stretch
- image: circleci/node:12.11.1-stretch

jobs:
docker-build:
install-dependencies:
<<: *defaults
steps:
- checkout
- setup_remote_docker
- run:
name: Discover Docker Tags
command: |
(cd /tmp && npm install --no-progress @reactioncommerce/ci-scripts@1.4.0 >/dev/null)
mkdir -p docker-cache
/tmp/node_modules/.bin/docker-tags "$CIRCLE_SHA1" "$CIRCLE_BRANCH" \
| tee docker-cache/docker-tags.txt
- restore_cache:
keys:
- reaction-v3-node-modules-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- reaction-v3-node-modules-{{ .Branch }}
- run:
name: Docker Build
command: |
(cd /tmp && npm install --no-progress @reactioncommerce/ci-scripts@1.4.0 >/dev/null)
/tmp/node_modules/.bin/docker-labels >> Dockerfile
docker build --tag "$DOCKER_REPOSITORY:$CIRCLE_SHA1" .
mkdir -p docker-cache
docker save \
-o docker-cache/docker-image.tar \
"$DOCKER_REPOSITORY:$CIRCLE_SHA1"
- persist_to_workspace:
root: docker-cache
name: Install NPM dependencies
command: yarn install --production=false --frozen-lockfile --non-interactive
- save_cache:
key: reaction-v3-node-modules-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
paths:
- docker-image.tar
- docker-tags.txt
docker-push:
- node_modules
- save_cache:
key: reaction-v3-node-modules-{{ .Branch }}
paths:
- node_modules

dockerfile-lint:
<<: *defaults
steps:
- setup_remote_docker
- attach_workspace:
at: docker-cache
- checkout
- setup_remote_docker:
docker_layer_caching: true
- run:
name: Load and Tag Docker Image
command: |
docker load < docker-cache/docker-image.tar
cat docker-cache/docker-tags.txt \
| xargs -t -I % \
docker tag \
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" \
"$DOCKER_REPOSITORY:%"
name: Lint Dockerfiles
command: ${CI_SCRIPTS} lint-dockerfiles

eslint:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- reaction-v3-node-modules-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- reaction-v3-node-modules-{{ .Branch }}
- run:
# Creates a new Docker repository. This is not strictly required if
# the Docker Hub defaults are set appropriately.
name: Create Private Docker Hub Repository
command: |
# Fetch a login token from environment credentials.
TOKEN=$(curl \
-H "Content-Type: application/json" \
-X POST \
-d "{\"username\":\"$DOCKER_USER\",\"password\":\"$DOCKER_PASS\"}" \
-s \
https://hub.docker.com/v2/users/login/ \
| jq -r .token)
# Try to create the private repo. It exits with success on fail.
curl \
-H "Authorization: JWT $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"namespace\":\"$DOCKER_NAMESPACE\",
\"name\":\"$DOCKER_NAME\",
\"description\":\"$DESCRIPTION\",
\"full_description\":\"\",
\"is_private\":true}" \
https://hub.docker.com/v2/repositories/
name: Lint JavaScript
command: yarn run lint

test-unit:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- reaction-v3-node-modules-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
- reaction-v3-node-modules-{{ .Branch }}
- run:
name: Docker Push
command: |
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
docker push "$DOCKER_REPOSITORY:$CIRCLE_SHA1"
cat docker-cache/docker-tags.txt \
| xargs -t -I % \
docker push "$DOCKER_REPOSITORY:%"
name: Run Unit Tests
command: yarn run test:ci

docker-build-push:
<<: *defaults
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: true
- run:
name: Build and push production Docker image
command: ${CI_SCRIPTS} docker-build-tag-push . ${DOCKER_REPOSITORY}

create-gitops-pull-request:
<<: *defaults
Expand Down Expand Up @@ -133,107 +123,29 @@ jobs:
# Create PR
/usr/local/bin/hub pull-request --no-edit -r ${REACTION_GITOPS_REVIEWERS}
lint-javascript:
<<: *defaults
steps:
- checkout
- run:
name: Lint JavaScript
command: |
yarn install
yarn lint
test:
<<: *defaults
steps:
- checkout
- setup_remote_docker
- attach_workspace:
at: docker-cache
- run:
name: Load and Tag Docker Image
command: |
docker load < docker-cache/docker-image.tar
cat docker-cache/docker-tags.txt \
| xargs -t -I % \
docker tag \
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" \
"$DOCKER_REPOSITORY:%"
- run:
name: Test
command: |
docker run \
--env-file .env.example \
--env NODE_ENV=test \
--name reactionapp_next_starterkit \
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" \
yarn test:ci
- run:
name: Copy test artifacts from Remote Docker
command: |
docker cp \
reactionapp_next_starterkit:/usr/local/src/reaction-app/reports \
reports
- store_test_results:
path: reports/junit
- store_artifacts:
path: reports

snyk-security:
<<: *defaults
steps:
- checkout
- setup_remote_docker
- attach_workspace:
at: docker-cache
- run:
name: Load Docker Image
command: |
docker load < docker-cache/docker-image.tar
- run:
name: Snyk Security
# Snyk doesn't look up the directory tree for node_modules as
# NodeJS does so we have to take some extra measures to test in the
# Docker image. Copy package.json up a directory so that it is a
# sibling to node_modules, then run snyk test.
command: |
answer=$(./.circleci/bin/should-run-snyk.sh)
if [[ "${answer}" =~ "^YES" ]] ; then
docker run \
--env-file .env.example \
--env "SNYK_TOKEN" \
--name reactionapp_next_starterkit \
--workdir /usr/local/src \
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" \
sh -c "cp reaction-app/package.json ./ && cp reaction-app/.snyk ./ && snyk test"
else
echo "Skipping snyk: ${answer}"
fi
workflows:
version: 2
build_and_test:
jobs:
- lint-javascript:
context: reaction-build-read
- docker-build:
context: reaction-build-read
- install-dependencies
- dockerfile-lint:
requires:
- lint-javascript
- docker-push:
context: reaction-publish-docker
- install-dependencies
- eslint:
requires:
- docker-build
- test:
context: reaction-validation
- install-dependencies
- test-unit:
requires:
- docker-build
- snyk-security:
context: reaction-validation
- install-dependencies
- docker-build-push:
context: reaction-publish-docker
requires:
- docker-build
- dockerfile-lint
- eslint
- test-unit
- create-gitops-pull-request:
requires:
- docker-push
- docker-build-push
filters:
branches:
only: master
only: /^master$/
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ CANONICAL_URL=http://localhost:4000
ENABLE_SPA_ROUTING=true
EXTERNAL_GRAPHQL_URL=http://localhost:3000/graphql-beta
INTERNAL_GRAPHQL_URL=http://reaction.api.reaction.localhost:3000/graphql-beta
NODE_ENV=development
OAUTH2_ADMIN_PORT=4445
OAUTH2_AUTH_URL=http://localhost:4444/oauth2/auth
OAUTH2_CLIENT_ID=example-storefront
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10.16.3
26 changes: 0 additions & 26 deletions .reaction/entrypoint.sh

This file was deleted.

34 changes: 0 additions & 34 deletions .reaction/fix-volumes.sh

This file was deleted.

15 changes: 0 additions & 15 deletions .reaction/yarnrc-docker.template

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v2.8.0

Example Storefront v2.8.0 is a minor update to keep this project in sync with [Reaction v2.8.0](https://github.com/reactioncommerce/reaction) and [reaction-hydra v2.8.0](https://github.com/reactioncommerce/reaction-hydra)

# v2.7.0

Example Storefront v2.7.0 is a minor update to keep this project in sync with [Reaction v2.7.0](https://github.com/reactioncommerce/reaction) and [reaction-hydra v2.7.0](https://github.com/reactioncommerce/reaction-hydra)
Expand Down
Loading

0 comments on commit 5c67fb6

Please sign in to comment.