Skip to content

Commit 4006ee1

Browse files
committed
Merge branch 'develop' into release-v3.0.0
2 parents 3cf3be1 + 4127a55 commit 4006ee1

File tree

12 files changed

+128
-274
lines changed

12 files changed

+128
-274
lines changed

.circleci/config.yml

Lines changed: 78 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -10,93 +10,83 @@ version: 2
1010
# typing. See http://yaml.org/type/merge.html for details.
1111
defaults: &defaults
1212
environment:
13-
- DOCKER_REPOSITORY: "reactioncommerce/reaction-next-starterkit"
14-
- DOCKER_NAMESPACE: "reactioncommerce"
15-
- DOCKER_NAME: "reaction-next-starterkit"
16-
- GLOBAL_CACHE_VERSION: “v3”
17-
- KUSTOMIZE_VERSION: "3.2.1"
18-
- HUB_VERSION: "2.12.8"
19-
- GH_USERNAME: "rc-circleci"
20-
- GH_EMAIL: "circleci@reactioncommerce.com"
21-
- REACTION_GITOPS_REVIEWERS: "griggheo"
22-
13+
CI_SCRIPTS: 'npx --quiet --package @reactioncommerce/[email protected]'
14+
DOCKER_REPOSITORY: "reactioncommerce/example-storefront"
15+
DOCKER_NAMESPACE: "reactioncommerce"
16+
DOCKER_NAME: "example-storefront"
17+
GLOBAL_CACHE_VERSION: "v3"
18+
KUSTOMIZE_VERSION: "3.2.1"
19+
HUB_VERSION: "2.12.8"
20+
GH_USERNAME: "rc-circleci"
21+
GH_EMAIL: "[email protected]"
22+
REACTION_GITOPS_REVIEWERS: "griggheo"
2323
docker:
24-
- image: circleci/node:10-stretch
24+
- image: circleci/node:12.11.1-stretch
2525

2626
jobs:
27-
docker-build:
27+
install-dependencies:
2828
<<: *defaults
2929
steps:
3030
- checkout
31-
- setup_remote_docker
32-
- run:
33-
name: Discover Docker Tags
34-
command: |
35-
(cd /tmp && npm install --no-progress @reactioncommerce/[email protected] >/dev/null)
36-
mkdir -p docker-cache
37-
/tmp/node_modules/.bin/docker-tags "$CIRCLE_SHA1" "$CIRCLE_BRANCH" \
38-
| tee docker-cache/docker-tags.txt
31+
- restore_cache:
32+
keys:
33+
- reaction-v3-node-modules-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
34+
- reaction-v3-node-modules-{{ .Branch }}
3935
- run:
40-
name: Docker Build
41-
command: |
42-
(cd /tmp && npm install --no-progress @reactioncommerce/[email protected] >/dev/null)
43-
/tmp/node_modules/.bin/docker-labels >> Dockerfile
44-
docker build --tag "$DOCKER_REPOSITORY:$CIRCLE_SHA1" .
45-
mkdir -p docker-cache
46-
docker save \
47-
-o docker-cache/docker-image.tar \
48-
"$DOCKER_REPOSITORY:$CIRCLE_SHA1"
49-
- persist_to_workspace:
50-
root: docker-cache
36+
name: Install NPM dependencies
37+
command: yarn install --production=false --frozen-lockfile --non-interactive
38+
- save_cache:
39+
key: reaction-v3-node-modules-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
5140
paths:
52-
- docker-image.tar
53-
- docker-tags.txt
54-
docker-push:
41+
- node_modules
42+
- save_cache:
43+
key: reaction-v3-node-modules-{{ .Branch }}
44+
paths:
45+
- node_modules
46+
47+
dockerfile-lint:
5548
<<: *defaults
5649
steps:
57-
- setup_remote_docker
58-
- attach_workspace:
59-
at: docker-cache
50+
- checkout
51+
- setup_remote_docker:
52+
docker_layer_caching: true
6053
- run:
61-
name: Load and Tag Docker Image
62-
command: |
63-
docker load < docker-cache/docker-image.tar
64-
cat docker-cache/docker-tags.txt \
65-
| xargs -t -I % \
66-
docker tag \
67-
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" \
68-
"$DOCKER_REPOSITORY:%"
54+
name: Lint Dockerfiles
55+
command: ${CI_SCRIPTS} lint-dockerfiles
56+
57+
eslint:
58+
<<: *defaults
59+
steps:
60+
- checkout
61+
- restore_cache:
62+
keys:
63+
- reaction-v3-node-modules-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
64+
- reaction-v3-node-modules-{{ .Branch }}
6965
- run:
70-
# Creates a new Docker repository. This is not strictly required if
71-
# the Docker Hub defaults are set appropriately.
72-
name: Create Private Docker Hub Repository
73-
command: |
74-
# Fetch a login token from environment credentials.
75-
TOKEN=$(curl \
76-
-H "Content-Type: application/json" \
77-
-X POST \
78-
-d "{\"username\":\"$DOCKER_USER\",\"password\":\"$DOCKER_PASS\"}" \
79-
-s \
80-
https://hub.docker.com/v2/users/login/ \
81-
| jq -r .token)
82-
# Try to create the private repo. It exits with success on fail.
83-
curl \
84-
-H "Authorization: JWT $TOKEN" \
85-
-H "Content-Type: application/json" \
86-
-d "{\"namespace\":\"$DOCKER_NAMESPACE\",
87-
\"name\":\"$DOCKER_NAME\",
88-
\"description\":\"$DESCRIPTION\",
89-
\"full_description\":\"\",
90-
\"is_private\":true}" \
91-
https://hub.docker.com/v2/repositories/
66+
name: Lint JavaScript
67+
command: yarn run lint
68+
69+
test-unit:
70+
<<: *defaults
71+
steps:
72+
- checkout
73+
- restore_cache:
74+
keys:
75+
- reaction-v3-node-modules-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
76+
- reaction-v3-node-modules-{{ .Branch }}
9277
- run:
93-
name: Docker Push
94-
command: |
95-
docker login -u "$DOCKER_USER" -p "$DOCKER_PASS"
96-
docker push "$DOCKER_REPOSITORY:$CIRCLE_SHA1"
97-
cat docker-cache/docker-tags.txt \
98-
| xargs -t -I % \
99-
docker push "$DOCKER_REPOSITORY:%"
78+
name: Run Unit Tests
79+
command: yarn run test:ci
80+
81+
docker-build-push:
82+
<<: *defaults
83+
steps:
84+
- checkout
85+
- setup_remote_docker:
86+
docker_layer_caching: true
87+
- run:
88+
name: Build and push production Docker image
89+
command: ${CI_SCRIPTS} docker-build-tag-push . ${DOCKER_REPOSITORY}
10090

10191
create-gitops-pull-request:
10292
<<: *defaults
@@ -133,107 +123,29 @@ jobs:
133123
# Create PR
134124
/usr/local/bin/hub pull-request --no-edit -r ${REACTION_GITOPS_REVIEWERS}
135125
136-
lint-javascript:
137-
<<: *defaults
138-
steps:
139-
- checkout
140-
- run:
141-
name: Lint JavaScript
142-
command: |
143-
yarn install
144-
yarn lint
145-
146-
test:
147-
<<: *defaults
148-
steps:
149-
- checkout
150-
- setup_remote_docker
151-
- attach_workspace:
152-
at: docker-cache
153-
- run:
154-
name: Load and Tag Docker Image
155-
command: |
156-
docker load < docker-cache/docker-image.tar
157-
cat docker-cache/docker-tags.txt \
158-
| xargs -t -I % \
159-
docker tag \
160-
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" \
161-
"$DOCKER_REPOSITORY:%"
162-
- run:
163-
name: Test
164-
command: |
165-
docker run \
166-
--env-file .env.example \
167-
--env NODE_ENV=test \
168-
--name reactionapp_next_starterkit \
169-
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" \
170-
yarn test:ci
171-
- run:
172-
name: Copy test artifacts from Remote Docker
173-
command: |
174-
docker cp \
175-
reactionapp_next_starterkit:/usr/local/src/reaction-app/reports \
176-
reports
177-
- store_test_results:
178-
path: reports/junit
179-
- store_artifacts:
180-
path: reports
181-
182-
snyk-security:
183-
<<: *defaults
184-
steps:
185-
- checkout
186-
- setup_remote_docker
187-
- attach_workspace:
188-
at: docker-cache
189-
- run:
190-
name: Load Docker Image
191-
command: |
192-
docker load < docker-cache/docker-image.tar
193-
- run:
194-
name: Snyk Security
195-
# Snyk doesn't look up the directory tree for node_modules as
196-
# NodeJS does so we have to take some extra measures to test in the
197-
# Docker image. Copy package.json up a directory so that it is a
198-
# sibling to node_modules, then run snyk test.
199-
command: |
200-
answer=$(./.circleci/bin/should-run-snyk.sh)
201-
if [[ "${answer}" =~ "^YES" ]] ; then
202-
docker run \
203-
--env-file .env.example \
204-
--env "SNYK_TOKEN" \
205-
--name reactionapp_next_starterkit \
206-
--workdir /usr/local/src \
207-
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" \
208-
sh -c "cp reaction-app/package.json ./ && cp reaction-app/.snyk ./ && snyk test"
209-
else
210-
echo "Skipping snyk: ${answer}"
211-
fi
212126
workflows:
213127
version: 2
214128
build_and_test:
215129
jobs:
216-
- lint-javascript:
217-
context: reaction-build-read
218-
- docker-build:
219-
context: reaction-build-read
130+
- install-dependencies
131+
- dockerfile-lint:
220132
requires:
221-
- lint-javascript
222-
- docker-push:
223-
context: reaction-publish-docker
133+
- install-dependencies
134+
- eslint:
224135
requires:
225-
- docker-build
226-
- test:
227-
context: reaction-validation
136+
- install-dependencies
137+
- test-unit:
228138
requires:
229-
- docker-build
230-
- snyk-security:
231-
context: reaction-validation
139+
- install-dependencies
140+
- docker-build-push:
141+
context: reaction-publish-docker
232142
requires:
233-
- docker-build
143+
- dockerfile-lint
144+
- eslint
145+
- test-unit
234146
- create-gitops-pull-request:
235147
requires:
236-
- docker-push
148+
- docker-build-push
237149
filters:
238150
branches:
239-
only: master
151+
only: /^master$/

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10.16.3

.reaction/entrypoint.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.

.reaction/fix-volumes.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

.reaction/yarnrc-docker.template

Lines changed: 0 additions & 15 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v2.8.0
2+
3+
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)
4+
15
# v2.7.0
26

37
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)

0 commit comments

Comments
 (0)