The Oak National Academy Web Application code base.
Other documentation can be found in standalone READMEs:
- Build
- Components
- Docs
- Error Handling
- React Context
Create an environment configuration file by running:
cp .env.example .env
Now populate the new file, asking a colleague for the values.
Now install dependencies
npm install
Then, run the development server:
npm run dev
If successful two further config files .env.development.local
and .env.local
will have been automatically generated. You can access the running web app on http://localhost:3000
For more detail please see the test documentation.
We run Pa11yCI in CI to check for deterministic accessibility issues. To run Pa11y locally start the dev server with npm run dev
, then in another process run Pa11y with npm run pa11y
.
Unit tests live next to the code they are testing wherever possible. Next does not allow any files under the src/pages/
directory other than routes, so those test file are under the src/__tests_/pages/
directory, mirroring the src/pages
file structure.
npm run test
will run the tests using--watch
npm run test:ci
will run the tests once and create a coverage report.
We use WebriverIO.
See the testing docs for further details.
We use Husky to run pre-commit and commit message validating hooks, including unit tests, code linting, type checking, and commit message format checking.
Currently this hook
- Formats the code using Prettier
- Runs style and code linting
- Runs the unit tests
We use Commitlint to validate that commit message meet the conventional commit standard. If you want help with the format you can use the interactive commit message prompt by running the script npm run cc
, note you will need to have staged Git changes first or it will error (because there will be nothing to commit).
TO DO
A_SECRET_VALUE
- Some config or tool auth.
The app is built statically, with two caveats.
- On dynamic routes, an empty array and
fallback: "blocking"
is returned fromgetStaticPaths
. This means that those pages are built on first request, then stored as if they had been built at build time. This allows us to build an app with tens of thousands of pages in a few minutes. - All pages that use
getStaticProps
have incremental static regeneration turned on, which re-runsgetStaticProps
periodically on the server in order to rebuild the page with the latest data.
The upshot of these two pieces of config is that new pages become available automatically when the underlying data is updated, and existing pages get updated data when it is available, all without having to rebuild the app.
Oak preview and production builds are on Netlify.
- All changes to the
main
branch must happen through pull requests. - Changes on the
main
branch trigger thecreate_semantic_release
Github workflow which creates a Github release, and updates the package.json version number. The commit message has a structure set inrelease.config.js
. - All commits on
main
will trigger a Vercel deploy, but non-release commits (according to the commit message structure), will be cancelled. - The Vercel deployment will trigger the
deployment_checks
Github workflow.
Please see our security.txt file.
We don't currently accept external contributions to the code base, but this is under review and we hope to find an approach the works for us and the community.
As will all web projects we are dependent on open source libraries maintained by others. While it is not practical to acknowledge them all, we would nevertheless like to express our gratitude for the contributions and efforts of the OSS community. Our dependency list can be found in our package.json file.