Home of the Civic Platform frontend code.
This is a lerna based monorepo. Check out lernajs.io for any in-depth docs if you need to debug. Otherwise follow along:
Setup
Prerequisites you'll need in your development environment to use and contribute to this project.
Use yarn & nvm for cross-platform uniformity
These tools make sure every contributor has identical dependency versions, include node and node packages.
Install and build
# Sets your Node.js version to match what the project uses (should also happen on clone)
$ nvm use
# Installs all package dependencies and links cross-dependencies
$ yarn bootstrap
# This will build all packages. Since some packages are used internally, they need to
# be built before the dependent packages are worked on
$ yarn build
Working on a single package
At this point, Lerna has prepared all packages in the monorepo.
Most developers working in this project will be contributing to one package at a time.
This is the command sequence that will allow you to build/run an individual package every time (for example, the housing
package)
and work on it as if it was a standalone project:
$ cd packages/{package-name} # e.g. cd package/housing
# run local project
$ yarn start
# test local project
$ yarn test
# watch tests while working on them
$ yarn test --watch
Using storybook
We are committed to a shared component library. This is achieved using the component-library
package and React Storybook.
Run Storybook with the following command:
$ yarn run storybook
Project Layout
There are three types of packages right now:
- Project packages: A React/Redux codebase that holds a collection of stories and API interactions for a single project in a Hack Oregon project cycle.
- Year package bundles: A React/Redux codebase that bundles together all project packages for a given year. This is a unit that gets deployed to production.
- Utilities: Common code that other projects depend on.
Packages
Every package has its own README with further details on what the package is for and how it works.
- Year Packages
- Project Packages
- Utilities
Testing across all packages
To run all tests for all packages, use the following command:
yarn test
Tests for individual packages can be run from within the individual package's directory. Running all tests is useful for continuous integration environments as well as verifying changes to common dependencies does not break packages.
For example, run the above command at the root of the project after making changes to a component in the component library to ensure that others packages are compatible with the changes made.
Continuous Integration
Travis CI is configured to have a build pipeline for the component library and one for each project year. Although most
commands are run using yarn scripts attached to a package.json
file, due to the many steps required to run tests for
a specific set of packages, a Makefile is used instead.
Continuous Delivery
Travis CI will deploy docker containers to ECS for each project year whenever the master
branch builds successfully.