Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Prod Release into Master #124

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b63a1c6
Feature/cb2 11709 test: remove nested integration tests (#94)
FurkanErdogan-BJSS Apr 30, 2024
9b0c23d
chore(cb2-11268): upgrade aws-sdk to v3 (#97)
shivangidas May 8, 2024
e48fc89
Revert "chore(cb2-11268): upgrade aws-sdk to v3 (#97)" (#98)
shivangidas May 8, 2024
5e72cd2
try sudo
thisisthetechie May 8, 2024
2974e4f
no sudo
thisisthetechie May 8, 2024
9ecf5d2
Revert "no sudo"
thisisthetechie May 9, 2024
6753c89
Revert "try sudo"
thisisthetechie May 9, 2024
8ee9f4b
chore(cb2-11268): upgrade aws-sdk to v3 (#99)
shivangidas May 10, 2024
7738d8a
chore(cb2-12277): update packages and eslint (#100)
shivangidas May 28, 2024
affc0de
chore(cb2-12277): move liquibase to dev dependency (#101)
shivangidas May 29, 2024
37002b9
feature(cb2-11817): sns/sqs and event bridge for tech records (#102)
kcarr-bjss Jun 3, 2024
5427b65
Revert "feature(cb2-11817): sns/sqs and event bridge for tech records…
naathanbrown Jun 3, 2024
0cffb03
Revert "Revert "feature(cb2-11817): sns/sqs and event bridge for tech…
naathanbrown Jun 6, 2024
43e5c0d
feat(cb2-12587): changed handler to deal with raw events instead of j…
kcarr-bjss Jun 14, 2024
36f886a
feat(cb2-1101): stringify event log (#113)
naathanbrown Jun 20, 2024
2cb4d81
Feature/cb2 11667 - Trailer entry into service column changes (#112)
Nat-McCabe-BJSS Jun 21, 2024
56c20f6
feat(CB2-12965): Added additional logs (#114)
Daniel-Searle Jul 15, 2024
c131241
CB2-12965: Refactor test result and technical record logs (#115)
Daniel-Searle Jul 25, 2024
a5dd986
feat(CB2-13178): added in vef to the test station types array (#117)
Daniel-Searle Aug 20, 2024
2da6641
feat(cb2-13479): update-status logic (#120)
cb-cs Sep 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules
.serverless
.vscode
*.config.js
**/config/*.ts
**/*.js
.build,
jest.config.ts
27 changes: 27 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'jest'],
extends: [
'@dvsa/eslint-config-ts',
],
rules: {
'jest/no-disabled-tests': 'warn',
'jest/no-commented-out-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': 'error',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'no-restricted-syntax': 'off'
},
};
118 changes: 43 additions & 75 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
name: 🧱 Build and Test
run-name: 🧱 Build and Test ${{ github.repository }}@${{ github.ref_name }}
run-name: 🧱 Build and Test ${{ github.ref_name }}
env:
bucket-name: cvs-services
on:
workflow_call:
workflow_dispatch:
inputs:
ignore-test-failures:
type: boolean
description: Ignore Test Failures
default: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

permissions:
id-token: write
contents: write
Expand All @@ -19,11 +24,20 @@ jobs:
name: 🧹 Prepare Environment
runs-on: ubuntu-latest
outputs:
version-number: ${{ steps.version.outputs.version }}
environment-name: ${{ steps.environment.outputs.environment-name }}
environment-type: ${{ steps.environment.outputs.environment-type }}
github-branch: ${{ steps.environment.outputs.github-branch }}
commit: ${{ steps.commit.outputs.commit }}
package-name: ${{ steps.name.outputs.package-name }}

steps:
- name: Generate Package Name
id: name
run: |
repo=${{ github.repository }}
echo "package-name=${repo#dvsa/}" >> $GITHUB_OUTPUT
echo "Package Name: ${repo#dvsa/}" >> $GITHUB_STEP_SUMMARY

- name: 🪪 Get Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -42,11 +56,21 @@ jobs:
with:
environment: ${{ github.ref_name }}

build-services:
name: 🧱 Build ${{ github.ref_name }}
runs-on: [self-hosted, X64]
needs: environment
- name: Get Commit SHA
id: commit
run: |
# Get the branch Commit ID
commit_id=$(git rev-parse HEAD)
echo "commit=${commit_id}"
echo "commit=${commit_id}" >> $GITHUB_OUTPUT
echo "Commit ID: ${commit_id}" >> $GITHUB_STEP_SUMMARY

build-service:
name: 🧱 Build ${{ needs.environment.outputs.package-name }}
runs-on:
- ${{ needs.environment.outputs.package-name }}

needs: environment
steps:
- name: 🪪 Get Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -57,36 +81,27 @@ jobs:

- name: 📥 Get Codebase
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
ref: ${{ github.ref_name }}

- name: Get Commit SHA
id: commit
run: |
# Get the branch Commit ID
commit_id=$(git rev-parse HEAD)
echo "commit=${commit_id}"
echo "commit=${commit_id}" >> $GITHUB_OUTPUT
echo "Commit ID: ${commit_id}" >> $GITHUB_STEP_SUMMARY

- name: 🗒️ Process Manifest Data
id: manifest
run: |
# Generate Manifest Outputs & Identify Build Requirements
echo "package-name=$(jq -r '.name' manifest.json)" >> $GITHUB_OUTPUT
echo "language=$(jq -r '.language' manifest.json)" >> $GITHUB_OUTPUT
echo "liquibase=$(jq -r '.liquibase' manifest.json)" >> $GITHUB_OUTPUT

# Generate Output File
jq -c '. += {"sha":"${{ steps.commit.outputs.commit }}","repository":"${{ github.repository }}"' manifest.json > outputs.json
hash_files="[]"
if [[ -f "manifest.json" ]]; then
package=$(jq -r '.name' manifest.json)
echo "package=$(jq -r '.name' manifest.json)" >> $GITHUB_OUTPUT
echo "language=$(jq -r '.language' manifest.json)" >> $GITHUB_OUTPUT
echo "liquibase=$(jq -r '.liquibase' manifest.json)" >> $GITHUB_OUTPUT
fi

- name: 🏗️ Build Node Function
uses: dvsa/cvs-github-actions/build-node-function@develop
if: ${{ steps.manifest.outputs.language == 'node' }}
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
with:
commit-sha: ${{ steps.commit.outputs.commit }}
branch: ${{ github.ref_name }}
commit-sha: ${{ needs.environment.outputs.commit }}
branch: ${{needs.environment.outputs.github-branch }}
mysql_liquibase: ${{ steps.manifest.outputs.liquibase }}
mysql_user: ${{ secrets.MYSQL_USER }}
mysql_password: ${{ secrets.MYSQL_PASS }}
Expand All @@ -99,53 +114,6 @@ jobs:
- name: 📤 Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ needs.environment.outputs.package-name }}
path: |
outputs.json
${{ steps.commit.outputs.commit }}*.zip

upload-functions:
# Runs as a separate job because we don't want to push anything if any one of the services fails to build
name: 🎯 Upload ${{ github.ref_name }}
runs-on: ubuntu-latest
needs: [environment, build-services]
steps:
- name: 🪪 Get Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.CVS_MGMT_AWS_ROLE }}
aws-region: ${{ vars.DVSA_AWS_REGION }}
role-session-name: GHA_BuildServices

- name: 📥 Download Artifact
uses: actions/download-artifact@v4

- name: 🗒️ Get Manifest Data
id: manifest
run: |
# Get information from Manifest File
echo "package-name=$(jq -r '.name' outputs.json)" >> $GITHUB_OUTPUT
echo "mono-repo=$(jq -r '.monorepo' outputs.json)" >> $GITHUB_OUTPUT
echo "sha=$(jq -r '.sha' outputs.json)" >> $GITHUB_OUTPUT
echo "build-package=$(jq -r '.build' outputs.json)" >> $GITHUB_OUTPUT
echo "hash-files=$(jq -r '.hash_files' outputs.json)" >> $GITHUB_OUTPUT

echo "package-name=$(jq -r '.name' outputs.json)" >> $GITHUB_STEP_SUMMARY
echo "mono-repo=$(jq -r '.monorepo' outputs.json)" >> $GITHUB_STEP_SUMMARY
echo "sha=$(jq -r '.sha' outputs.json)" >> $GITHUB_STEP_SUMMARY
echo "build-package=$(jq -r '.build' outputs.json)" >> $GITHUB_STEP_SUMMARY
echo "hash-files=$(jq -r '.hash_files' outputs.json)" >> $GITHUB_STEP_SUMMARY

- name: Create Hash Files
uses: dvsa/cvs-github-actions/hash-create@develop
with:
commit-id: ${{ steps.manifest.outputs.sha }}
environment-name: ${{ needs.environment.outputs.environment-name }}
hash-files: ${{ steps.manifest.outputs.hash-files }}

- name: 📤 Upload hash zip to S3
uses: dvsa/cvs-github-actions/hash-upload@develop
with:
commit-id: ${{ steps.manifest.outputs.sha }}
package-name: ${{ steps.manifest.outputs.package-name }}
environment-name: ${{ needs.environment.outputs.environment-name }}
version-number: ${{ needs.environment.outputs.version-number }}
${{ needs.environment.outputs.commit }}*.zip
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ coverage/**

#reports
.reports/**

# vscode specific files
.vscode/**
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no -- commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm test && npm run security-checks && npm run audit && npm run lint
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run prepush
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ This will cause numerous debug logs to fire. Messages will include event informa
```shell
npm run test
```
Runs all unit tests

```shell
npm run test-all
```
Runs all the tests (Unit and Integration)

### Integration tests
Integration tests depend on:
Expand All @@ -80,7 +86,7 @@ On Windows, you will need to manually run:
* Confirm: `echo %USE_CONTAINERIZED_DATABASE%` should return `1`before the above, or run these tests with an IntelliJ configuration which sets the right environment variable for you.

On Tanio Artino's advice, there is a distinction between running integration tests locally, and running them on Jenkins.
* `USE_CONTAINERIZED_DATABASE=0` will attempt to talk to `localhost:3306`. This only works if you manually start a DB or, in the case of Jenkins, if there is a pre-existing DB running on port `3306`.
* `USE_CONTAINERIZED_DATABASE=0` will attempt to talk to `127.0.0.1:3306`. This only works if you manually start a DB or, in the case of Jenkins, if there is a pre-existing DB running on port `3306`.
* `USE_CONTAINERIZED_DATABASE=1` will spin up a TC container as described above.

To run the "Jenkins" version, e.g. `USE_CONTAINERIZED_DATABASE=0`, use:
Expand Down
41 changes: 30 additions & 11 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
process.env.TZ = "GMT";
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
roots: ["<rootDir>/src", "<rootDir>/tests"],
setupFiles: ["jest-plugin-context/setup"],
moduleFileExtensions: ["js", "ts"],
testResultsProcessor: "jest-sonar-reporter",
transform: {
"^.+\\.tsx?$": "ts-jest",
},
testMatch: ["**/*.*Test.ts"],
};
projects: [
{
displayName: "UNIT",
testMatch: ["<rootDir>/tests/**/*.unitTest.ts"],
preset: "ts-jest",
testEnvironment: "node",
roots: ["<rootDir>/tests"],
setupFiles: ["jest-plugin-context/setup"],
moduleFileExtensions: ["js", "ts"],
testResultsProcessor: "jest-sonar-reporter",
transform: {
"^.+\\.ts?$": "ts-jest",
},
},
{
displayName: "INTEGRATION",
testMatch: ["<rootDir>/tests/**/*.intTest.ts"],
preset: "ts-jest",
testEnvironment: "node",
roots: ["<rootDir>/tests"],
setupFiles: ["jest-plugin-context/setup"],
moduleFileExtensions: ["js", "ts"],
testResultsProcessor: "jest-sonar-reporter",
transform: {
"^.+\\.ts?$": "ts-jest",
},
runner: "jest-serial-runner",
}
],
};
Loading
Loading