Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehalmamoj committed Sep 7, 2021
0 parents commit 78c6f6e
Show file tree
Hide file tree
Showing 103 changed files with 14,937 additions and 0 deletions.
236 changes: 236 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
version: 2.1

orbs:
hmpps: ministryofjustice/[email protected]
slack: circleci/[email protected]

parameters:
alerts-slack-channel:
type: string
default: hmpps_typescript_notifications

releases-slack-channel:
type: string
default: hmpps_typescript_notifications

node-version:
type: string
default: 14.17-browsers

jobs:
build:
executor:
name: hmpps/node
tag: << pipeline.parameters.node-version >>
steps:
- checkout
- run:
name: Update npm
command: 'sudo npm install -g npm@latest'
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: Install Dependencies
command: npm ci --no-audit
- save_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
paths:
- node_modules
- ~/.cache
- run:
command: |
npm run build
DATE=$(date '+%Y-%m-%d')
export BUILD_NUMBER=${DATE}.${CIRCLE_BUILD_NUM}
export GIT_REF="$CIRCLE_SHA1"
npm run record-build-info
- run: # Run linter after build because the integration test code depend on compiled typescript...
name: Linter check
command: npm run lint
- persist_to_workspace:
root: .
paths:
- node_modules
- build-info.json
- build
- dist
- .cache/Cypress

check_outdated:
executor:
name: hmpps/node
tag: << pipeline.parameters.node-version >>
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: install-npm
command: 'npm ci --no-audit'
- run:
name: Check version
command: 'npm --version'
- run:
name: Run check
command: 'npm outdated typescript govuk-frontend'
- slack/notify:
event: fail
channel: << pipeline.parameters.alerts-slack-channel >>
template: basic_fail_1

unit_test:
executor:
name: hmpps/node
tag: << pipeline.parameters.node-version >>
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: unit tests
command: npm run test
- store_test_results:
path: test_results
- store_artifacts:
path: test-results/unit-test-reports.html

integration_test:
executor:
name: hmpps/node_redis
node_tag: << pipeline.parameters.node-version >>
redis_tag: buster
steps:
- checkout
- attach_workspace:
at: ~/app
- run:
name: Install missing OS dependency
command: sudo apt-get install libxss1
- run:
name: Get wiremock
command: curl -o wiremock.jar https://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-standalone/2.27.1/wiremock-standalone-2.27.1.jar
- run:
name: Run wiremock
command: java -jar wiremock.jar --port 9091
background: true
- run:
name: Run the node app.
command: npm run start-feature
background: true
- run:
name: Wait for node app to start
command: sleep 5
- restore_cache:
key: dependency-cache-{{ checksum "package-lock.json" }}
- run:
name: integration tests
command: npm run int-test
- store_test_results:
path: test_results
- store_artifacts:
path: integration-tests/videos
- store_artifacts:
path: integration-tests/screenshots

workflows:
version: 2
build-test-and-deploy:
jobs:
- build:
filters:
tags:
ignore: /.*/
- unit_test:
requires:
- build
- integration_test:
requires:
- build
- hmpps/helm_lint:
name: helm_lint
- hmpps/build_docker:
name: build_docker
filters:
branches:
only:
- main
- hmpps/deploy_env:
name: deploy_dev
env: "dev"
context: hmpps-common-vars
filters:
branches:
only:
- main
requires:
- helm_lint
- unit_test
- integration_test
- build_docker

# - request-preprod-approval:
# type: approval
# requires:
# - deploy_dev
# - hmpps/deploy_env:
# name: deploy_preprod
# env: "preprod"
# context:
# - hmpps-common-vars
# - hmpps-template-typescript-preprod
# requires:
# - request-preprod-approval
# - request-prod-approval:
# type: approval
# requires:
# - deploy_preprod
# - hmpps/deploy_env:
# name: deploy_prod
# env: "prod"
# slack_notification: true
# slack_channel_name: << pipeline.parameters.releases-slack-channel >>
# context:
# - hmpps-common-vars
# - hmpps-template-typescript-prod
# requires:
# - request-prod-approval

security:
triggers:
- schedule:
cron: "30 5 * * 1-5"
filters:
branches:
only:
- main
jobs:
- check_outdated:
context:
- hmpps-common-vars
- hmpps/npm_security_audit:
slack_channel: << pipeline.parameters.alerts-slack-channel >>
context:
- hmpps-common-vars
- hmpps/trivy_latest_scan:
slack_channel: << pipeline.parameters.alerts-slack-channel >>
context:
- hmpps-common-vars
- hmpps/veracode_pipeline_scan:
slack_channel: << pipeline.parameters.alerts-slack-channel >>
context:
- veracode-credentials
- hmpps-common-vars
security-weekly:
triggers:
- schedule:
cron: "0 5 * * 1"
filters:
branches:
only:
- main
jobs:
- hmpps/veracode_policy_scan:
slack_channel: << pipeline.parameters.alerts-slack-channel >>
context:
- veracode-credentials
- hmpps-common-vars
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dist
kubectl_deploy*
helm_deploy*
README.md
node_modules
npm-debug.log
README.md
.*
**/*.test.js
scss-report.txt
eslint-report.html
test-report.html
docker-compose.yml
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
public
assets
cypress.json
reporter-config.json
dist/
108 changes: 108 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"env": {
"browser": true,
"node": true,
"jest": true
},

"plugins": ["import"],

"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true
},
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx", ".json"]
}
}
},

"overrides": [
{
"plugins": ["@typescript-eslint"],
"parser": "@typescript-eslint/parser",
"files": ["**/*.ts"],
"excludedFiles": "*.js",
"extends": [
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/no-use-before-define": 0,
"class-methods-use-this": 0,
"no-useless-constructor": 0,
"@typescript-eslint/no-unused-vars": [
1,
{
"argsIgnorePattern": "res|next|^err|_",
"ignoreRestSiblings": true
}
],
"@typescript-eslint/semi": 0,
"import/no-unresolved": "error",
"prettier/prettier": [
"error",
{
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 120,
"semi": false,
"arrowParens": "avoid"
}
]
}
}
],

"extends": ["airbnb-base", "plugin:prettier/recommended"],

"rules": {
"no-unused-vars": [
1,
{
"argsIgnorePattern": "res|next|^err|_",
"ignoreRestSiblings": true
}
],
"no-use-before-define": 0,
"semi": 0,
"import/no-unresolved": "error",
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"mjs": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
],
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "never"
}
],
"import/no-extraneous-dependencies": ["error", { "devDependencies": ["**/*.test.js", "**/*.test.ts"] }],
"prettier/prettier": [
"error",
{
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 120,
"semi": false,
"arrowParens": "avoid"
}
]
}
}
24 changes: 24 additions & 0 deletions .github/workflows/rename_template_project_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: rename-project-create-pr

on: [workflow_dispatch]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Run rename-project script
run: ./rename-project.bash ${{ github.event.repository.name }}

- name: Delete this github actions workflow
run: rm .github/workflows/rename_template_project*

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
commit-message: updating project name after deployment from template repository
title: Update template project name/references
body: Update all references to project name after deploying from template repository
branch: rename_template_project
base: main
Loading

0 comments on commit 78c6f6e

Please sign in to comment.