lbc-messages

CircleCI Commitizen friendly Renovate enabled

Quality Gate Status Coverage Maintainability Rating Code Smells Bugs Technical Debt

This project was bootstrapped with Create React App.

DEMO

Live Demo Web App Live Demo Storybook Live Demo Coverage Report

REQUIREMENTS

Be sure Node and NPM are installed.

We also use Yarn, but you could use NPM instead.

If you work on multiple projects we recommend you to use NVM to manage different node version. Since this project has a .nvmrc file, you can just run npm use to be sure to use the right version of Node.

INSTALLATION

git clone git@github.com:proustibat/lbc-messages.git
cd lbc-messages
yarn

This will clone the repository then it will install needed packages and will make the web app ready to run for development.

DEVELOPMENT

Run the app locally

yarn start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

Internationalization

We use react-i18next, a powerful internationalization framework for React / React Native which is based on i18next. You can find translation files in ./public/locales.

With i18next-browser-languagedetector we set the browser language as the default app language. You can run the app in another language by adding ?lng=XX, for example: https://messages.surge.sh/?lng=en or https://messages.surge.sh/?lng=fr.

Commits

This repo is Commitizen-friendly. It means you'll be prompted to fill out any required commit fields at commit time. Learn more about commitizen cli.

Husky is used to enable prepare-commit-msg git hook. So you can just use git commit then follow the prompt of your terminal.

Linting

By using pretty-quick we run Prettier on changed files before each commit (on the pre-commit git hook).

We added Prettier to the default linter used by create-react-app which is ESLint. Our configuration of Prettier allows ESLint to be used with Prettier because of eslint-prettier.

If you wanna run the linters by your own, you can run yarn lint that will run Prettier.

Please, be sure you also configured your IDE correctly.

UNIT TESTING

yarn tdd

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

DESIGN SYSTEM

Developing UI

We use Storybook for UI development. It makes development faster and easier by isolating components.

Run it in watch mode in order to develop UIs:

yarn storybook

Then open http://localhost:6006 to view it in the browser.

You can write any stories file you want by writing them in a file with the .stories.tsx extension.

Build and deploy the Storybook app

yarn build-storybook create a minified app ready to be deployed in storybook-static directory.

Our CI/CD run the build then deploy its content during the deployments job for the main branch on https://storybook-messages.surge.sh. For other branches or pull requests, built storybook is in artifacts.

PRODUCTION

yarn build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

CI/CD

Config, workflow and jobs

We use CircleCI to run jobs during the git flow.

The config is in the .circleci/config.yml.

The pipelines' history of the current project is available on this dashboard.

The main workflow runs 6 jobs:

  • prepare: installs node modules and save it to the current workspace
  • unit-testing: requires prepare job, runs tests
  • sonar: requires unit-testing, runs sonar-scanner
  • build-app: requires prepare job
  • build-storybook: requires prepare job
  • deployments: runs different steps that require different build workflows.
Main workflow on the main branch Main workflow on a pull request
Main workflow on main branch Main workflow on a pull request

Deployments

The web app

We use Surge to host our web app, a tool for static web publishing for frontend developers. CircleCI deploys the app on https://messages.surge.sh after each push on the main branch.

Note that you can deploy manually by running yarn deploy. Then you'll need to define your own domain. A surge token has been added to the CircleCI variables environment in order to deploy on our demo domain.

Note the predeploy and postddeploy scripts. It's used to make the react routing compliant with the surge config.

Coverage and unit test reports

Since testing job runs at each pull request or at each push on master, the job save junit report and coverage reports as artifacts.

Here is how it looks like on CircleCI dashboard:

Junit Report Coverage

For the main branch, the coverage reports will be deployed on https://coverage-messages.surge.sh by the CI/CD.

Coverage

Storybook

As mentioned in the Storybook section, the design system is deployed at https://storybook-messages.surge.sh.

Code quality tracking

We use Sonarcloud to detect code quality issues, the maintainability, reliability and security of the code. Visit the public dashboard of the project. The CI/CD runs the sonar scanner on each push.

Sonarcloud job

Learn More

You can learn more in the Create React App documentation.

To learn React, check out the React documentation.

About other used tools and services