Skip to content

Commit b40d62f

Browse files
authored
Merge pull request #769 from reactioncommerce/akarshit-semantic-release
fix: enable semantic releae
2 parents ef6c17a + 601dd87 commit b40d62f

File tree

7 files changed

+2196
-54
lines changed

7 files changed

+2196
-54
lines changed

.circleci/config.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- reaction-v3-node-modules-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
3232
- reaction-v3-node-modules-{{ .Branch }}
3333
- run:
34-
name: Install NPM dependencies
34+
name: Install yarn dependencies
3535
command: yarn install --production=false --frozen-lockfile --non-interactive
3636
- save_cache:
3737
key: reaction-v3-node-modules-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
@@ -77,6 +77,18 @@ jobs:
7777
name: Run Unit Tests
7878
command: yarn run test:ci
7979

80+
release:
81+
<<: *defaults
82+
steps:
83+
- checkout
84+
- restore_cache:
85+
keys:
86+
- reaction-v3-node-modules-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
87+
- reaction-v3-node-modules-{{ .Branch }}
88+
- run:
89+
name: Push the latest version to npm
90+
command: yarn run semantic-release --dry-run
91+
8092
docker-build-push:
8193
<<: *defaults
8294
steps:
@@ -86,7 +98,11 @@ jobs:
8698
version: 19.03.13
8799
- run:
88100
name: Build and push production Docker image
89-
command: ${CI_SCRIPTS} docker-build-tag-push . ${DOCKER_REPOSITORY}
101+
command: |
102+
VERSION=$(git describe --tags `git rev-list --tags --max-count=1` | cut -c2-100)
103+
docker build -t ${DOCKER_REPOSITORY}:${VERSION} .
104+
docker login -u ${DOCKER_USER} -p ${DOCKER_PASS}
105+
docker push ${DOCKER_REPOSITORY}:${VERSION}
90106
- webhook/notify:
91107
endpoint: "${GITOPS_PR_WEBHOOK}"
92108

@@ -111,9 +127,17 @@ workflows:
111127
- test-unit:
112128
requires:
113129
- install-dependencies
114-
- docker-build-push:
115-
context: reaction-publish-docker
130+
- release:
131+
context: reaction-publish-semantic-release
132+
filters:
133+
branches:
134+
only:
135+
- trunk
116136
requires:
117137
- dockerfile-lint
118138
- eslint
119139
- test-unit
140+
- docker-build-push:
141+
context: reaction-publish-docker
142+
requires:
143+
- release

.github/pull_request_template.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,27 @@ Impact: **breaking|critical|major|minor**
33
Type: **feature|bugfix|performance|test|style|refactor|docs|chore**
44

55
## Issue
6+
67
Description of the issue this PR is solving, why it's happening, and how to reproduce it. This may differ from the original ticket as you now have more information at your disposal.
78

89
## Solution
10+
911
Summarize your solution to the problem. Please include short descriptions of any solutions you tested before arriving at your final solution. This will help reviewers know why you decided to solve this problem in this particular way and will speed up the review process.
1012

1113
If you're solving a UIX related issue, please attach screen-caps or gifs showing how your solution differs from the issue.
1214

1315
## Breaking changes
16+
1417
If you have a breaking changes, list them here, otherwise list none.
1518

1619
Examples of breaking changes include changing file names, moving files, deleting files, renaming functions or exports, or changes to code which might cause previous versions of Reaction or third-party code not to work as expected.
1720

1821
Note any work that you did to mitigate the effect of any breaking changes such as creating migrations, deprecation warnings, etc.
1922

20-
2123
## Testing
24+
2225
1. List the steps needed for testing your change in this section.
2326
2. Assume that testers already know how to start the app, and do the basic setup tasks.
2427
3. Be detailed enough that someone can work through it without being too granular
2528

26-
More detail for what each of these sections should include are available in our [Contributing Docs](https://docs.reactioncommerce.com/reaction-docs/trunk/contributing-to-reaction)
29+
More detail for what each of these sections should include are available in our [Contributing Docs](https://docs.reactioncommerce.com/reaction-docs/trunk/contributing-to-reaction). This project uses [semantic-release](https://semantic-release.gitbook.io/semantic-release/), please use their [commit message format.](https://semantic-release.gitbook.io/semantic-release/#commit-message-format).

README.md

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
This Example Storefront is to serve as a reference on how to implement a web based storefront using the Reaction Commerce GraphQL API. You can fork this project as a jumping off point or create your own custom experience using your prefered client-side technology. While we believe our example storefront is full featured enough to use in production, it may be missing features your shop requires at this time.
66

77
## Features
8+
89
Reaction comes with a robust set of core commerce capabilities right out of the box. And since anything in our codebase can be extended, overwritten, or installed as a package, you may also customize anything on our platform.
910

1011
Check out the full list of Reaction [features](https://www.reactioncommerce.com/features) and [release history](https://reactioncommerce.com/roadmap) for more info.
@@ -25,7 +26,7 @@ This example storefront is built with [Next.js](https://nextjs.org/), [React](ht
2526
Follow the [Reaction Platform docs](https://docs.reactioncommerce.com/docs/installation-reaction-platform) to install and run all the services necessary to run the storefront:
2627

2728
| Directory: Service | URL |
28-
|-----------------------------------------------------------------------------------------------|--------------------------------------------------|
29+
| --------------------------------------------------------------------------------------------- | ------------------------------------------------ |
2930
| [`reaction`](https://github.com/reactioncommerce/reaction): GraphQL API | [localhost:3000/graphql](localhost:3000/graphql) |
3031
| [`reaction`](https://github.com/reactioncommerce/reaction): GraphQL Playground developer tool | [localhost:3000/graphql](localhost:3000/graphql) |
3132
| [`reaction`](https://github.com/reactioncommerce/reaction): Reaction Admin | [localhost:4080](localhost:4080) |
@@ -51,32 +52,37 @@ When running the storefront and Reaction for the first time, you will need to co
5152
Read the docs for [setting up Segment or a custom analytics tracker](docs/tracking-events.md)
5253

5354
## Documentation
55+
5456
- [Example Storefront full documentation](./docs)
5557
- [Example Storefront Component Library repository](https://github.com/reactioncommerce/reaction-component-library), [documentation](https://github.com/reactioncommerce/reaction-component-library/tree/master/docs), and [component documentation](http://designsystem.reactioncommerce.com/)
5658
- [Reaction Docs: Using GraphQL](https://docs.reactioncommerce.com/docs/graphql-using)
5759
- [Reaction Docs: Testing with Jest](https://docs.reactioncommerce.com/docs/testing-reaction)
58-
- [Reaction Docs: Developing with Docker](https://docs.reactioncommerce.com/docs/installation-docker-development
59-
)
60+
- [Reaction Docs: Developing with Docker](https://docs.reactioncommerce.com/docs/installation-docker-development)
6061

6162
## Development
6263

6364
The Reaction Platform runs the storefront with Docker, so you will have to use Docker commands to view logs, run commands inside the container and more. To run commands specifically for the storefront, make sure to change directories into the `example-storefront` directory within the `reaction-platform` repository:
65+
6466
```sh
6567
cd example-storefront
6668
```
6769

6870
### Build and run in development mode with logs
71+
6972
Create a symbolic link to use the development Docker image:
73+
7074
```
7175
ln -s docker-compose.dev.yml docker-compose.override.yml
7276
```
7377

7478
If running for the first time or environment variables in `.env.example` have changed execute the command below to update environment variables.
79+
7580
```
7681
./bin/setup
7782
```
7883

7984
Start the storefront by executing:
85+
8086
```sh
8187
docker-compose up -d && docker-compose logs -f
8288
```
@@ -94,26 +100,31 @@ docker-compose run --rm --service-ports web yarn start
94100
```sh
95101
docker-compose run --rm web [command]
96102
```
103+
97104
Run any command inside a Docker container and then remove the container. Use this to run any tooling operations. Remember your project directory will be mounted and things will usually just work. See Yarn section below for more examples.
98105

99106
### Run tests in container
100107

101108
Run tests locally
109+
102110
```sh
103111
docker-compose run --rm web yarn test
104112
```
105113

106114
Run tests locally without cache (this can be helpful if changes aren't showing up)
115+
107116
```sh
108117
docker-compose run --rm web yarn test --no-cache
109118
```
110119

111120
To run Snyk security tests (this will run tests in the same way as CI)
121+
112122
```sh
113123
docker-compose run --rm web sh -c "cp package.json ../ && cp .snyk ../ && cd .. && snyk auth && snyk test"
114124
```
115125

116126
To run ESLint
127+
117128
```sh
118129
docker-compose run --rm web eslint src
119130
```
@@ -129,13 +140,15 @@ You can use the Google Chrome DevTools to debug the code running in the Node.js
129140

130141
Yarn & NPM should run inside the Docker container. We've taken steps to ensure that the node_modules are placed into a cacheable location. If you run Yarn locally, the node_modules are written directly to the project directory and take precedence over those from the Docker build.
131142
**Yarn Add**
143+
132144
```
133145
docker-compose run --rm web yarn add --dev [package]
134146
```
135147

136148
**Yarn Install**
137149

138150
⚠️ Always rebuild the image and start a new container after modifying yarn.lock or Dockerfile!
151+
139152
```
140153
docker-compose run --rm web yarn install
141154
docker-compose down --rmi local
@@ -155,25 +168,29 @@ Sometimes we need to test the [Example Storefront Component Library](https://git
155168
1. Inside your `.env` file, change `INTERNAL_GRAPHQL_URL` to equal `http://localhost:3000/graphql`, the same as the `EXTERNAL_GRAPHQL_URL`
156169
1. Start the storefront locally by running the command `export $(cat .env | xargs) && yarn dev`
157170
1. Your storefront should now be running at `localhost:4000`
158-
- If you see errors about not being able to find peer dependency packages, that seems to be an issues with yarn linking. You can just temporarily `yarn add` each of those packages in the component library `package/dist` folder. (This folder is gitignored anyway.)
171+
- If you see errors about not being able to find peer dependency packages, that seems to be an issues with yarn linking. You can just temporarily `yarn add` each of those packages in the component library `package/dist` folder. (This folder is gitignored anyway.)
159172
1. After your changes are tested, shut down the storefront by running the command `CTRL+C`
160173
1. Run `yarn unlink "@reactioncommerce/components"` in the storefront repo folder
161174
1. `cd` to the `package/dist` folder of the `reaction-component-library` repo. Run the command `yarn unlink` to unlink the local version of the component library
162175
1. Undo the renaming of your `.yarnrc` file
163176
1. Undo the URL change inside your `.env` file
164177

165178
## Clean up containers
179+
166180
Stop, and retain containers:
181+
167182
```sh
168183
docker-compose stop
169184
```
170185

171186
Stop, and remove containers:
187+
172188
```sh
173189
docker-compose down
174190
```
175191

176192
Stop, and remove containers, volumes and built images:
193+
177194
```sh
178195
docker-compose down -v --rmi local
179196
```
@@ -187,6 +204,7 @@ Run this command to build a Docker image with the production build of the app in
187204
```sh
188205
docker build --network=host -t reactioncommerce/example-storefront:X.X.X .
189206
```
207+
190208
Where X.X.X indicates the tag version you want to use, i.e. `3.1.0`
191209

192210
Then, to start the app on your machine, make sure the Reaction API container is already running and enter:
@@ -207,35 +225,44 @@ docker stop reaction-storefront
207225

208226
## Contribute
209227

210-
Find a bug, a typo, or something that’s not documented well? We’d love for you to [open an issue](https://github.com/reactioncommerce/example-storefront/issues) telling us what we can improve!
228+
Find a bug, a typo, or something that’s not documented well? We’d love for you to [open an issue](https://github.com/reactioncommerce/example-storefront/issues) telling us what we can improve! This project uses [semantic-release](https://semantic-release.gitbook.io/semantic-release/), please use their [commit message format.](https://semantic-release.gitbook.io/semantic-release/#commit-message-format).
211229

212230
Want to request a feature? Use our [Reaction Feature Requests repository](https://github.com/reactioncommerce/reaction-feature-requests) to file a request.
213231

214232
We love your pull requests! Check our our [`Good First Issue`](https://github.com/reactioncommerce/example-storefront/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22) and [`Help Wanted`](https://github.com/reactioncommerce/example-storefront/issues?q=label%3A%22help+wanted%22) tags for good issues to tackle.
215233

216234
### Pull Request guidelines
235+
217236
Pull requests should pass all automated tests, style, and security checks.
218237

219238
#### Automated Tests
239+
220240
Your code should pass all [acceptance tests and unit tests](https://docs.reactioncommerce.com/reaction-docs/trunk/testing-reaction). Run
241+
221242
```sh
222243
docker-compose run --rm web yarn test
223244
```
245+
224246
to run the test suites locally. If you're adding functionality to Reaction, you should add tests for the added functionality. You can run the tests locally without cache if necessary by passing the `--no-cache` flag. This can be helpful if changes aren't showing up.
247+
225248
```sh
226249
docker-compose run --rm web yarn test --no-cache
227250
```
228251

229252
To update a failing snapshot (if you've made changes to a component)
253+
230254
```sh
231255
docker-compose run --rm web yarn test -u
232256
```
233257

234258
#### Eslint
259+
235260
We require that all code contributed to Reaction follows [Reaction's ESLint rules](https://github.com/reactioncommerce/reaction-eslint-config). You can run
261+
236262
```
237263
docker-compose run --rm web eslint src
238264
```
265+
239266
to run ESLint against your code locally.
240267

241268
Please follow the [Reaction Code Style Guide](https://docs.reactioncommerce.com/docs/styleguide). Check out our guides to [JSDoc](https://docs.reactioncommerce.com/docs/jsdoc-style-guide), [Git](https://docs.reactioncommerce.com/docs/git-style-guide), [error handling](https://docs.reactioncommerce.com/docs/error-handling-guide), [logging](https://docs.reactioncommerce.com/docs/logging), and [React](https://docs.reactioncommerce.com/docs/react-best-practices).
@@ -245,7 +272,9 @@ We also request that you follow the our [pull request template](https://docs.rea
245272
Get more details in our [Contributing Guide](https://docs.reactioncommerce.com/docs/contributing-to-reaction).
246273

247274
### Developer Certificate of Origin
275+
248276
We use the [Developer Certificate of Origin (DCO)](https://developercertificate.org/) in lieu of a Contributor License Agreement for all contributions to Reaction Commerce open source projects. We request that contributors agree to the terms of the DCO and indicate that agreement by signing all commits made to Reaction Commerce projects by adding a line with your name and email address to every Git commit message contributed:
277+
249278
```
250279
Signed-off-by: Jane Doe <[email protected]>
251280
```
@@ -258,20 +287,20 @@ We use the [Probot DCO GitHub app](https://github.com/apps/dco) to check for DCO
258287

259288
If you forget to sign your commits, the DCO bot will remind you and give you detailed instructions for how to amend your commits to add a signature.
260289

261-
262290
## License
263-
Copyright 2019 Reaction Commerce
264291

265-
Licensed under the Apache License, Version 2.0 (the "License");
266-
you may not use this file except in compliance with the License.
267-
You may obtain a copy of the License at
292+
Copyright 2019 Reaction Commerce
293+
294+
Licensed under the Apache License, Version 2.0 (the "License");
295+
you may not use this file except in compliance with the License.
296+
You may obtain a copy of the License at
268297

269298
http://www.apache.org/licenses/LICENSE-2.0
270299

271-
Unless required by applicable law or agreed to in writing, software
272-
distributed under the License is distributed on an "AS IS" BASIS,
273-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
274-
See the License for the specific language governing permissions and
275-
limitations under the License.
300+
Unless required by applicable law or agreed to in writing, software
301+
distributed under the License is distributed on an "AS IS" BASIS,
302+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
303+
See the License for the specific language governing permissions and
304+
limitations under the License.
276305

277306
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Freactioncommerce%2Fexample-storefront.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Freactioncommerce%2Fexample-storefront?ref=badge_large)

hocs/inject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const withInjectedStores = (injections) => (PageComponent) => {
1919
);
2020
};
2121

22-
// Set the correct displayName in development
22+
// Set the correct displayName in development
2323
if (process.env.NODE_ENV !== "production") {
2424
const displayName = PageComponent.displayName || PageComponent.name || "Component";
2525
WithInjectedStores.displayName = `withInjectedStores(${displayName})`;

hocs/withTranslation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const withTranslation = (namespace) => (PageComponent) => {
99
);
1010
};
1111

12-
// Set the correct displayName in development
12+
// Set the correct displayName in development
1313
if (process.env.NODE_ENV !== "production") {
1414
const displayName = PageComponent.displayName || PageComponent.name || "Component";
1515
WithInjectedStores.displayName = `withInjectedStores(${displayName})`;

0 commit comments

Comments
 (0)