From df3dd33b6e104bb2b29d908d070a4a350ea8c5ff Mon Sep 17 00:00:00 2001 From: NkwaTambe Date: Tue, 5 Nov 2024 14:45:38 +0100 Subject: [PATCH 1/2] docs: Add comprehensive guide for GitHub actions in UserApp CI/CD process --- Docs/Github_workflow_overview.md | 104 +++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 Docs/Github_workflow_overview.md diff --git a/Docs/Github_workflow_overview.md b/Docs/Github_workflow_overview.md new file mode 100644 index 0000000..c0c7712 --- /dev/null +++ b/Docs/Github_workflow_overview.md @@ -0,0 +1,104 @@ +# GitHub Workflow Documentation for UserApp + +This document describes the `analyses` workflow used in the UserApp project. The workflow is triggered by changes to the `main` branch, ensuring code quality, consistency, and successful builds. + +## Workflow Trigger + +The workflow is set to run on: +- **Push events**: Direct commits to the `main` branch. +- **Pull requests**: PRs targeting the `main` branch. + +## Workflow Jobs and Steps + +### 1. **Install Dependencies and Cache node_modules** + +- **Job Name**: `install` +- **Purpose**: Sets up the development environment by installing project dependencies and caching them for future jobs. + +**Steps**: + - **Checkout Code**: Uses `actions/checkout@v2` to pull the latest code from the repository. + - **Install Dependencies**: Runs `npm ci` to install dependencies with a clean slate. + - **Cache node_modules**: Caches `node_modules` for faster builds in subsequent jobs. The cache key uses `${{ github.sha }}`, ensuring cache validity for each unique commit. + +--- + +### 2. **Build Application** + +- **Job Name**: `build` +- **Depends on**: `install` +- **Purpose**: Builds the project to ensure code compiles correctly and prepares it for deployment or further testing. + +**Steps**: + - **Checkout Code**: Pulls the latest code. + - **Use Cached node_modules**: Uses the cached `node_modules` for a faster setup. + - **Run Build Command**: Executes `npm run build` to compile the application. + +--- + +### 3. **Lint Checks with ESLint** + +- **Job Name**: `lint` +- **Depends on**: `install` +- **Purpose**: Checks code quality using ESLint to detect syntax or stylistic issues. + +**Steps**: + - **Checkout Code**: Pulls the latest code. + - **Use Cached node_modules**: Uses the cached `node_modules` for faster installation. + - **Run ESLint**: Runs `npm run lint:check` to verify code quality and catch common coding issues. + +--- + +### 4. **Code Formatting with Prettier** + +- **Job Name**: `prettier` +- **Depends on**: `install` +- **Purpose**: Ensures consistent code formatting using Prettier. + +**Steps**: + - **Checkout Code**: Pulls the latest code. + - **Use Cached node_modules**: Uses the cached `node_modules`. + - **Run Prettier**: Executes `npm run prettier:check` to validate code formatting. + +--- + +### 5. **TypeScript Type Checks** + +- **Job Name**: `typescript` +- **Depends on**: `install` +- **Purpose**: Ensures there are no type errors by running TypeScript checks. + +**Steps**: + - **Checkout Code**: Pulls the latest code. + - **Use Cached node_modules**: Utilizes the cached dependencies. + - **Run TypeScript Check**: Runs `npm run ts:check` to verify there are no TypeScript type errors. + +--- + +### 6. **Unit Testing** + +- **Job Name**: `unit_tests` +- **Depends on**: `install` +- **Purpose**: Runs unit tests to validate the correctness of code logic. + +**Steps**: + - **Checkout Code**: Pulls the latest code. + - **Use Cached node_modules**: Utilizes cached dependencies. + - **Run Unit Tests**: Executes `npm run test:unit` to run unit tests on the project. + +--- + +## Troubleshooting Common Issues + +- **Dependency Installation Failures**: If `npm ci` fails during the install step, verify the integrity of `package-lock.json` or try clearing the cache. +- **Cache Issues**: If the cached `node_modules` is outdated or causing build failures, clear the cache by changing the cache key. +- **Build Failures**: Ensure code changes do not introduce syntax errors or unsupported constructs. Check for environment-specific build configurations. +- **Lint/Prettier Errors**: Ensure that the code follows the project's style guide and run `npm run prettier:check -- --write "src/**/*.{js,jsx,ts,tsx,json,css,scss,md}"` locally to auto-correct issues. +- **TypeScript Errors**: Resolve any type errors reported in the `typescript` step by fixing the type definitions in the code. +- **Test Failures**: Debug failing tests locally using `npm run test:unit`. + +--- + +## Conclusion + +This GitHub workflow automates essential CI/CD processes, including installation, building, linting, formatting, type-checking, and unit testing. By maintaining code quality and verifying build integrity, this workflow ensures that only production-ready code is merged into `main`. + From 34117e6bab133051805c8cf6e3612c78a6489a85 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:01:07 +0000 Subject: [PATCH 2/2] chore(deps-dev): bump happy-dom from 15.8.3 to 15.11.0 Bumps [happy-dom](https://github.com/capricorn86/happy-dom) from 15.8.3 to 15.11.0. - [Release notes](https://github.com/capricorn86/happy-dom/releases) - [Commits](https://github.com/capricorn86/happy-dom/compare/v15.8.3...v15.11.0) --- updated-dependencies: - dependency-name: happy-dom dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- package-lock.json | 9 ++++----- package.json | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index c8e39c5..61ebb1f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,7 +39,7 @@ "eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-react-refresh": "^0.4.6", "fake-indexeddb": "^6.0.0", - "happy-dom": "^15.8.3", + "happy-dom": "^15.11.0", "jsdom": "^25.0.1", "postcss": "^8.4.47", "prettier": "^3.3.3", @@ -6526,11 +6526,10 @@ "license": "MIT" }, "node_modules/happy-dom": { - "version": "15.8.3", - "resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-15.8.3.tgz", - "integrity": "sha512-YR9nUWN/T2bH7pPLEYMhTp4DQExPH+mC4KulJDgimCb+FY3Er0Vp6SOOcBXrNfMTri3lAk9uSZqUTG2hgZOYwg==", + "version": "15.11.0", + "resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-15.11.0.tgz", + "integrity": "sha512-/zyxHbXriYJ8b9Urh43ILk/jd9tC07djURnJuAimJ3tJCOLOzOUp7dEHDwJOZyzROlrrooUhr/0INZIDBj1Bjw==", "dev": true, - "license": "MIT", "dependencies": { "entities": "^4.5.0", "webidl-conversions": "^7.0.0", diff --git a/package.json b/package.json index 79ccd50..fc8553d 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-react-refresh": "^0.4.6", "fake-indexeddb": "^6.0.0", - "happy-dom": "^15.8.3", + "happy-dom": "^15.11.0", "jsdom": "^25.0.1", "postcss": "^8.4.47", "prettier": "^3.3.3",