generated from ministryofjustice/hmpps-template-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d4b5ab1
Showing
116 changed files
with
17,189 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
version: 2.1 | ||
|
||
orbs: | ||
hmpps: ministryofjustice/[email protected] | ||
slack: circleci/[email protected] | ||
|
||
parameters: | ||
alerts-slack-channel: | ||
type: string | ||
# Normally team specific alert channel e.g. hmpps_tech_alerts, syscon-alerts, dps_sed_alerts | ||
# This is to avoid a general alert dumping ground that no-one then monitors | ||
default: hmpps_typescript_notifications | ||
|
||
releases-slack-channel: | ||
type: string | ||
# Normally dps-releases for most teams / projects | ||
default: hmpps_typescript_notifications | ||
|
||
node-version: | ||
type: string | ||
default: 18.15-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 | ||
- 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 | ||
- dist | ||
- .cache/Cypress | ||
|
||
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:ci | ||
- 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: "7.0" | ||
steps: | ||
- checkout | ||
- attach_workspace: | ||
at: ~/app | ||
- run: | ||
name: Install missing OS dependency | ||
command: sudo apt-get install libxss1 | ||
- restore_cache: | ||
key: dependency-cache-{{ checksum "package-lock.json" }} | ||
- 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 | ||
- 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" | ||
jira_update: true | ||
context: hmpps-common-vars | ||
filters: | ||
branches: | ||
only: | ||
- main | ||
requires: | ||
- helm_lint | ||
- unit_test | ||
- integration_test | ||
- build_docker | ||
helm_timeout: 5m | ||
# - request-preprod-approval: | ||
# type: approval | ||
# requires: | ||
# - deploy_dev | ||
# - hmpps/deploy_env: | ||
# name: deploy_preprod | ||
# env: "preprod" | ||
# jira_update: true | ||
# jira_env_type: staging | ||
# context: | ||
# - hmpps-common-vars | ||
# - hmpps-template-typescript-preprod | ||
# requires: | ||
# - request-preprod-approval | ||
# helm_timeout: 5m | ||
# - request-prod-approval: | ||
# type: approval | ||
# requires: | ||
# - deploy_preprod | ||
# - hmpps/deploy_env: | ||
# name: deploy_prod | ||
# env: "prod" | ||
# jira_update: true | ||
# jira_env_type: production | ||
# slack_notification: true | ||
# slack_channel_name: << pipeline.parameters.releases-slack-channel >> | ||
# context: | ||
# - hmpps-common-vars | ||
# - hmpps-template-typescript-prod | ||
# requires: | ||
# - request-prod-approval | ||
# helm_timeout: 5m | ||
|
||
security: | ||
triggers: | ||
- schedule: | ||
cron: "30 5 * * 1-5" | ||
filters: | ||
branches: | ||
only: | ||
- main | ||
jobs: | ||
- hmpps/npm_outdated: | ||
slack_channel: << pipeline.parameters.alerts-slack-channel >> | ||
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 |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
dist | ||
kubectl_deploy* | ||
helm_deploy* | ||
README.md | ||
node_modules | ||
npm-debug.log | ||
.* | ||
**/*.test.js | ||
scss-report.txt | ||
eslint-report.html | ||
test-report.html | ||
docker-compose* |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
public | ||
assets | ||
cypress.json | ||
reporter-config.json | ||
dist/ |
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"node": true, | ||
"jest": true | ||
}, | ||
|
||
"plugins": ["import", "no-only-tests"], | ||
|
||
"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": "all", | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"semi": false | ||
} | ||
] | ||
} | ||
} | ||
], | ||
|
||
"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", "always-multiline"], | ||
"import/no-extraneous-dependencies": [ | ||
"error", | ||
{ "devDependencies": ["**/*.test.js", "**/*.test.ts", "**/testutils/**", "cypress.config.ts"] } | ||
], | ||
"no-only-tests/no-only-tests": "error", | ||
"prettier/prettier": [ | ||
"error", | ||
{ | ||
"trailingComma": "all", | ||
"singleQuote": true, | ||
"printWidth": 120, | ||
"semi": false | ||
} | ||
] | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: rename-project-create-pr | ||
|
||
on: [workflow_dispatch] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- 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@v5 | ||
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 |
Oops, something went wrong.