-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I have decided to convert all the JavaScript in the application to Ty…
…peScript. We have quite a lot of JavaScript in this application and I do find it quite difficult to maintain. I am hopeful TypeScript will make all the maintenance easier and help future proof our code. It also gave me an opportunity to review our code and remove anything that was no longer needed. (I also had nothing else to do at this moment in time and wanted to give myself a challenge)
- Loading branch information
Showing
93 changed files
with
3,879 additions
and
3,523 deletions.
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
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
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 |
---|---|---|
|
@@ -37,9 +37,9 @@ make | |
### MacOS | ||
|
||
#### Check the Ruby version | ||
##### N.B. The project currently runs on 2.7.4. (August 2021) | ||
##### N.B. The project currently runs on 2.7.6 (April 2022) | ||
|
||
Ensure that a ruby version manager (e.g. rvm or rbenv) is installed and set up properly, using 2.7.4 as the Ruby version before trying anything else. | ||
Ensure that a ruby version manager (e.g. rvm or rbenv) is installed and set up properly, using 2.7.6 as the Ruby version before trying anything else. | ||
|
||
#### Install Postgres and PostGIS | ||
`brew install postgres` (this will install the latest (HEAD) version, currently 12. The server runs 11!) | ||
|
@@ -118,43 +118,11 @@ obtained from the [AWS Systems Manager Parameter Store][aws-parameter-store]. | |
* If present, enable the Cognito sign-in link on the Supply Teachers gateway | ||
page | ||
|
||
#### DfE Sign-in | ||
|
||
* `DFE_SIGNIN_URL` | ||
* Obtained from DfE Sign-in. Should have just `/` as a path component, e.g. | ||
`https://signin.example.com/`. | ||
* `DFE_SIGNIN_CLIENT_ID` | ||
* Obtained from DfE Sign-in. | ||
* `DFE_SIGNIN_CLIENT_SECRET` | ||
* Obtained from DfE Sign-in. | ||
* `DFE_SIGNIN_REDIRECT_URI` | ||
* A link to the authentication callback in this application, i.e. | ||
`https://marketplace.service.crowncommercial.gov.uk/auth/dfe/callback` for | ||
the live service | ||
* `DFE_SIGNIN_WHITELISTED_EMAIL_ADDRESSES` | ||
* Comma-separated list of email addresses allowed access via DfE Sign-in | ||
* If this variable is not present, DfE Sign-in is not protected by | ||
whitelisting | ||
|
||
#### Google Analytics | ||
|
||
* `GA_TRACKING_ID` | ||
* Google Analytics is disabled if this is not set | ||
|
||
#### Upload URL protection | ||
|
||
HTTP Basic Authentication credentials. Only needed in production environments. | ||
See the [Uploading data section](#uploading-data) below. | ||
|
||
* `HTTP_BASIC_AUTH_NAME` | ||
* `HTTP_BASIC_AUTH_PASSWORD` | ||
|
||
If the following environment variable is set then the app exposes routes for | ||
uploading supplier data JSON. Otherwise those routes do not exist and users | ||
receive a 404. | ||
|
||
* `APP_HAS_UPLOAD_PRIVILEGES` | ||
|
||
#### Database | ||
|
||
The following are used to configure the database, but only in production | ||
|
@@ -181,47 +149,6 @@ rails s | |
``` | ||
|
||
Visit [localhost:3000](http://localhost:3000). | ||
|
||
## Uploading data | ||
|
||
You can upload data for a given framework using the following command where | ||
`FRAMEWORK_NAME` is one of `supply-teachers`, `facilities-management` or | ||
`management-consultancy`; `SCHEME` is one of `http` (local development) or | ||
`https` (other environments); `HTTP_BASIC_AUTH_NAME` & | ||
`HTTP_BASIC_AUTH_PASSWORD` credentials (only needed for production | ||
environments): | ||
|
||
``` | ||
git clone [email protected]:Crown-Commercial-Service/crown-marketplace-data.git | ||
cd crown-marketplace-data/$FRAMEWORK_NAME | ||
curl --user $HTTP_BASIC_AUTH_NAME:$HTTP_BASIC_AUTH_PASSWORD --request POST \ | ||
--header "Content-Type: application/json" --data @output/data.json \ | ||
$SCHEME://$HOST/$FRAMEWORK_NAME/uploads | ||
``` | ||
|
||
### Audit trail | ||
|
||
The application keeps a record of each *successful* upload in the database. So, | ||
for example, the time of the most recent upload for a framework can be obtained | ||
using the Rails console with one of the following commands: | ||
|
||
* `FacilitiesManagement::Upload.order(:created_at).last.created_at` | ||
* `ManagementConsultancy::Upload.order(:created_at).last.created_at` | ||
* `SupplyTeachers::Upload.order(:created_at).last.created_at` | ||
|
||
## Regenerating error pages | ||
|
||
We use the [juice][] npm package to generate HTML error pages from the live | ||
service, inlining all CSS, images, web fonts, etc. A Rake task makes this | ||
easier: | ||
|
||
``` | ||
rake 'error_pages[http://localhost:3000]' | ||
``` | ||
|
||
This will pull down `/errors/404.html`, for example, and save an inlined copy in | ||
`public/404.html`. | ||
|
||
## Development | ||
|
||
### Design & frontend | ||
|
@@ -233,6 +160,7 @@ This will pull down `/errors/404.html`, for example, and save an inlined copy in | |
[yarn][], and the exact versions of all dependencies direct/indirect are | ||
locked in `yarn.lock`. | ||
* The CSS follows [Block Element Modifier][] conventions. | ||
* We use `TypeScript` to write our frontend code (in `app/typescript`) | ||
|
||
### Code | ||
|
||
|
@@ -246,9 +174,6 @@ which are somewhat non-standard: | |
framework into a separate Rails app if that was deemed appropriate down the | ||
line. | ||
|
||
* The supplier-related data for each framework is bulk uploaded over HTTPS to be | ||
stored in the database; the data is then effectively regarded as read-only. | ||
|
||
* A bunch of other less-variable data is stored in CSV files in the code | ||
repository and made available to the application via classes including the | ||
`StaticRecord` concern, e.g. `Nuts3Region` which loads its data from | ||
|
@@ -308,9 +233,8 @@ classes. | |
various types. | ||
* I18n translations are used in specs to reduce their sensitivity to copy | ||
changes. | ||
* [RSpec feature specs][feature-specs] are used for acceptance testing. | ||
* RSpec matchers from the [capybara][] gem are used throughout the specs to | ||
make assertions about rendered HTML. | ||
* We use the [Cucumber][] testing framework to test the frontend functionality with a subset of the test run as part of the CI. | ||
* We use [Axe Cucumber][] to run accessibility tests but these are not run as part of the CI. | ||
* All the specs are run as part of the default Rake task, but the standard | ||
RSpec-provided Rake tasks also exist for running sub-groups of the specs. | ||
|
||
|
@@ -324,16 +248,13 @@ Note that some lines are excluded from simplecov with the `# :nocov:` instructio | |
|
||
### Continuous integration & deployment | ||
|
||
* Continuous integration and deployment is implemented on the new AWS-based CCS | ||
infrastructure. | ||
* The tests are run automatically when a new commit is pushed to a triggering | ||
branch of this repository on GitHub. This is achieved using | ||
[AWS CodePipeline][] and [AWS CodeBuild][]. | ||
* The `pipeline_pre_build_tests.sh` script is run to install everything that's | ||
needed to run the tests on the fairly vanilla CodeBuild container. | ||
* The `pipeline_run_build_tests.sh` script is what actually runs the tests. | ||
* If all the tests pass, then a container is built using the `Dockerfile` in | ||
this repo, uploaded to the [AWS Elastic Container Registry][], and deployed | ||
* When a branch is pushed or pull request is raised GitHub actions will run | ||
the rspec and cucumber test suites. | ||
* When the PR is merged to a main branch GitHub actions will run the test suites | ||
again before triggering the AWS pipeline. | ||
* We use [AWS CodePipeline][] and [AWS CodeBuild][] to build and deploy the application. | ||
* A container is built using the `Dockerfile` in this repo, | ||
uploaded to the [AWS Elastic Container Registry][], and deployed | ||
using [AWS Elastic Container Service][]. | ||
* Environment variables for the various containers running on the AWS | ||
infrastructure are obtained from the | ||
|
@@ -365,3 +286,5 @@ Note that some lines are excluded from simplecov with the `# :nocov:` instructio | |
[CMpDevEnvironment]: https:/Crown-Commercial-Service/CMpDevEnvironment | ||
[CMp Developer Guide]: https:/Crown-Commercial-Service/CMpDevEnvironment/blob/develop/docs/ccs_aws_v1-developer_guide.md | ||
[faker]: https:/stympy/faker | ||
[Cucumber]: https://cucumber.io/ | ||
[Axe Cucumber]: https://www.deque.com/axe/ |
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.