forked from reactioncommerce/catalyst
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mike Murray <[email protected]>
- Loading branch information
1 parent
b35476f
commit f2eea22
Showing
161 changed files
with
32,391 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"digits": 4, | ||
"language": "en", | ||
"path": "docs/architecture/decisions/", | ||
"prefix": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
# outputs each tag we're attaching to this docker image | ||
set -e | ||
|
||
SHA=$1 | ||
BRANCH=$2 | ||
SHA1=$(git rev-parse --verify "${SHA}") | ||
|
||
# Echo to stderr | ||
echoerr() { echo "$@" 1>&2; } | ||
|
||
# Ensure that git SHA was provided | ||
if [[ -x "${SHA1}" ]]; then | ||
echoerr "Error, no git SHA provided" | ||
exit 1; | ||
fi | ||
|
||
# tag with the branch | ||
if [[ -n "${BRANCH}" ]]; then | ||
echo "${BRANCH}" | ||
fi | ||
|
||
# Tag with each git tag | ||
git show-ref --tags -d | grep "^${SHA1}" | sed -e 's,.* refs/tags/,,' -e 's/\^{}//' 2> /dev/null \ | ||
| xargs -I % \ | ||
echo "%" | ||
|
||
# Tag with latest if certain conditions are met | ||
if [[ "$BRANCH" == "master" ]]; then | ||
# Check to see if we have a valid `vX.X.X` tag and assign to CURRENT_TAG | ||
CURRENT_TAG=$( \ | ||
git show-ref --tags -d \ | ||
| grep "^${SHA1}" \ | ||
| sed -e 's,.* refs/tags/,,' -e 's/\^{}//' \ | ||
| grep "^v[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+$" \ | ||
| sort \ | ||
) | ||
|
||
# Find the highest tagged version number | ||
HIGHEST_TAG=$(git --no-pager tag | grep "^v[0-9]\\+\\.[0-9]\\+\\.[0-9]\\+$" | sort -r | head -n 1) | ||
|
||
# We tag :latest only if | ||
# 1. We have a current tag | ||
# 2. The current tag is equal to the highest tag, OR the highest tag does not exist | ||
if [[ -n "${CURRENT_TAG}" ]]; then | ||
if [[ "${CURRENT_TAG}" == "${HIGHEST_TAG}" ]] || [[ -z "${HIGHEST_TAG}" ]]; then | ||
echo "latest" | ||
fi | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,241 @@ | ||
# This CircleCI configuration uses workflows to fan-out to multiple jobs. The | ||
# workflow is Dockerized. The first job builds the Docker image which is used | ||
# in all future steps. | ||
# | ||
# Assumes that the Docker image is published to Docker Hub. | ||
version: 2 | ||
|
||
# The following stanza defines a map named defaults with a variable that may be | ||
# inserted using the YAML merge (<<: *) key later in the file to save some | ||
# typing. See http://yaml.org/type/merge.html for details. | ||
defaults: &defaults | ||
environment: | ||
- DOCKER_REPOSITORY: "reactioncommerce/styleguide" | ||
- DOCKER_NAMESPACE: "reactioncommerce" | ||
- DOCKER_NAME: "styleguide" | ||
|
||
docker: | ||
- image: circleci/node:8-stretch | ||
|
||
jobs: | ||
docker-build: | ||
<<: *defaults | ||
steps: | ||
- checkout | ||
- setup_remote_docker | ||
- run: | ||
name: Discover Docker Tags | ||
command: | | ||
mkdir -p docker-cache | ||
.circleci/bin/docker-tags "$CIRCLE_SHA1" "$CIRCLE_BRANCH" \ | ||
> docker-cache/docker-tags.txt | ||
cat docker-cache/docker-tags.txt | ||
- run: | ||
name: Docker Build | ||
command: | | ||
docker build \ | ||
--build-arg "BUILD_COMPARE_URL=$CIRCLE_COMPARE_URL" \ | ||
--build-arg "BUILD_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ')" \ | ||
--build-arg "BUILD_ENV=test" \ | ||
--build-arg "BUILD_NUMBER=$CIRCLE_BUILD_NUM" \ | ||
--build-arg "BUILD_PLATFORM=circleci" \ | ||
--build-arg "BUILD_PLATFORM_PROJECT_REPONAME=$CIRCLE_PROJECT_REPONAME" \ | ||
--build-arg "BUILD_PLATFORM_PROJECT_USERNAME=$CIRCLE_PROJECT_USERNAME" \ | ||
--build-arg "BUILD_PULL_REQUESTS=$CI_PULL_REQUESTS" \ | ||
--build-arg "BUILD_TRIGGERED_BY_TAG=$CIRCLE_TAG" \ | ||
--build-arg "BUILD_URL=$CIRCLE_BUILD_URL" \ | ||
--build-arg "CIRCLE_WORKFLOW_ID=$CIRCLE_WORKFLOW_ID" \ | ||
--build-arg "CIRCLE_WORKFLOW_JOB_ID=$CIRCLE_WORKFLOW_JOB_ID" \ | ||
--build-arg "CIRCLE_WORKFLOW_UPSTREAM_JOB_IDS=$CIRCLE_WORKFLOW_UPSTREAM_JOB_IDS" \ | ||
--build-arg "CIRCLE_WORKSPACE_ID=$CIRCLE_WORKSPACE_ID" \ | ||
--build-arg "GIT_REPOSITORY_URL=$CIRCLE_REPOSITORY_URL" \ | ||
--build-arg "GIT_SHA1=$CIRCLE_SHA1" \ | ||
--build-arg "LICENSE=Apache-2.0" \ | ||
--build-arg "VCS_REF=$CIRCLE_SHA1" \ | ||
--build-arg "VENDOR=Reaction Commerce" \ | ||
-t "$DOCKER_REPOSITORY:$CIRCLE_SHA1" . | ||
mkdir -p docker-cache | ||
docker save \ | ||
-o docker-cache/docker-image.tar \ | ||
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" | ||
- run: | ||
name: Save Test .env for Workspace Jobs | ||
command: cp .env.example docker-cache/.env | ||
- persist_to_workspace: | ||
root: docker-cache | ||
paths: | ||
- docker-image.tar | ||
- docker-tags.txt | ||
- .env | ||
|
||
docker-push: | ||
<<: *defaults | ||
steps: | ||
- setup_remote_docker | ||
- attach_workspace: | ||
at: docker-cache | ||
- run: | ||
name: Load Docker Image | ||
command: | | ||
docker load < docker-cache/docker-image.tar | ||
- run: | ||
name: Tag Docker Image | ||
command: | | ||
cat docker-cache/docker-tags.txt \ | ||
| xargs -t -I % \ | ||
docker tag \ | ||
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" \ | ||
"$DOCKER_REPOSITORY:%" | ||
- 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\":false}" \ | ||
https://hub.docker.com/v2/repositories/ | ||
- 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:%" | ||
lint: | ||
<<: *defaults | ||
steps: | ||
- setup_remote_docker | ||
- attach_workspace: | ||
at: docker-cache | ||
- run: | ||
name: Load Docker Image | ||
command: | | ||
docker load < docker-cache/docker-image.tar | ||
- run: | ||
name: Lint | ||
command: | | ||
docker run \ | ||
--env-file docker-cache/.env \ | ||
--name reactionapp_web_1 \ | ||
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" \ | ||
yarn run lint | ||
test: | ||
<<: *defaults | ||
steps: | ||
- setup_remote_docker | ||
- attach_workspace: | ||
at: docker-cache | ||
- run: | ||
name: Load Docker Image | ||
command: | | ||
docker load < docker-cache/docker-image.tar | ||
- run: | ||
name: Test | ||
command: | | ||
docker run \ | ||
--env-file docker-cache/.env \ | ||
--name reactionapp_web_1 \ | ||
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" \ | ||
yarn run test | ||
- run: | ||
name: Copy test artifacts from Remote Docker | ||
command: | | ||
docker cp \ | ||
reactionapp_web_1:/usr/local/src/reaction-app/reports \ | ||
reports | ||
- store_test_results: | ||
path: reports/junit | ||
- store_artifacts: | ||
path: reports | ||
|
||
snyk-security: | ||
<<: *defaults | ||
steps: | ||
- setup_remote_docker | ||
- attach_workspace: | ||
at: docker-cache | ||
- run: | ||
name: Load Docker Image | ||
command: | | ||
docker load < docker-cache/docker-image.tar | ||
- run: | ||
name: Snyk | ||
command: | | ||
# 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. | ||
docker run \ | ||
--env-file docker-cache/.env \ | ||
-e "SNYK_TOKEN=$SNYK_TOKEN" \ | ||
--name reactionapp_web_1 \ | ||
"$DOCKER_REPOSITORY:$CIRCLE_SHA1" \ | ||
sh -c "snyk test" | ||
publish-npm-package: | ||
docker: | ||
- image: node:8 | ||
|
||
dependencies: | ||
pre: | ||
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc | ||
|
||
steps: | ||
- checkout | ||
|
||
- run: yarn install | ||
- run: cd package && yarn install | ||
- run: cd package && yarn run build | ||
- run: npx semantic-release | ||
|
||
workflows: | ||
version: 2 | ||
build_and_test: | ||
jobs: | ||
- docker-build: | ||
context: reaction-build-read | ||
- docker-push: | ||
context: reaction-publish-docker | ||
requires: | ||
- docker-build | ||
- lint: | ||
context: reaction-validation | ||
requires: | ||
- docker-build | ||
- test: | ||
context: reaction-validation | ||
requires: | ||
- docker-build | ||
- snyk-security: | ||
context: reaction-validation | ||
requires: | ||
- docker-build | ||
- publish-npm-package: | ||
context: reaction-publish-semantic-release | ||
requires: | ||
- lint | ||
- test | ||
- snyk-security | ||
filters: | ||
branches: | ||
only: master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.js] | ||
max_line_length = 120 | ||
indent_brace_style = 1TBS | ||
spaces_around_operators = true | ||
quote_type = double |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
NODE_ENV=development | ||
NODE_PATH=src | ||
PORT=4040 | ||
REACTION_APP_NAME=styleguide.web | ||
REACTION_LOG_LEVEL=INFO | ||
REACTION_LOG_FORMAT=json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
|
||
--- | ||
|
||
Type: **breaking|critical|major|minor** | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
- OS: [e.g. iOS] | ||
- Browser [e.g. chrome, safari] | ||
- Version [e.g. 22] | ||
|
||
**Smartphone (please complete the following information):** | ||
- Device: [e.g. iPhone6] | ||
- OS: [e.g. iOS8.1] | ||
- Browser [e.g. stock browser, safari] | ||
- Version [e.g. 22] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
Oops, something went wrong.