Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 12 additions & 1 deletion .github/actions/perform-pre-commit/action.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---
name: "Perform pre-commit checks"
description: "Perform pre-commit checks"
inputs:
base_sha:
description: "Base commit SHA used to determine pre-commit diff range"
required: false
default: ""
runs:
using: "composite"
steps:
Expand All @@ -23,7 +28,13 @@ runs:
shell: bash
run: |
echo "::group::Run pre-commit checks"
mise exec -- pre-commit run --all-files --show-diff-on-failure --color=always
if [[ -n "${BASE_SHA}" ]]; then
FROM_REF="${BASE_SHA}"
else
FROM_REF="origin/main"
fi
mise exec -- pre-commit run --from-ref "${FROM_REF}" --to-ref HEAD --show-diff-on-failure --color=always
echo "::endgroup::"
env:
BASE_SHA: ${{ inputs.base_sha }}
PRE_COMMIT_COLOR: always
2 changes: 2 additions & 0 deletions .github/workflows/cicd-1-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
with:
build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
run_pre_commit: ${{ github.event_name == 'pull_request' }}
pre_commit_base_sha: "${{ github.event.pull_request.base.sha || '' }}"
secrets: inherit
test-stage: # Recommended maximum execution time is 5 minutes
name: "Test stage"
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/stage-1-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ on:
description: "Build timestamp, set by the CI/CD pipeline workflow"
required: true
type: string
run_pre_commit:
description: "Whether to run pre-commit checks in this stage"
required: false
default: false
type: boolean
pre_commit_base_sha:
description: "Base commit SHA used for pre-commit diff range"
required: false
default: ""
type: string

jobs:
scan-secrets:
Expand Down Expand Up @@ -57,10 +67,15 @@ jobs:
idp_aws_report_upload_bucket_endpoint: "${{ secrets.IDP_AWS_REPORT_UPLOAD_BUCKET_ENDPOINT }}"
pre-commit:
runs-on: ubuntu-latest
if: inputs.run_pre_commit
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Initialize mise
uses: ./.github/actions/init-mise
- name: Run pre-commit checks
uses: ./.github/actions/perform-pre-commit
with:
base_sha: "${{ inputs.pre_commit_base_sha }}"
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ repos:
language: system
pass_filenames: false

- id: prettier-formatting
name: prettier-formatting
entry: npm run format:pre-commit --
language: system

- id: eslint-ui
name: ESLint (UI)
entry: npm --prefix ui run lint -- --fix
Expand Down
17 changes: 17 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Dependency directories
node_modules/
package-lock.json

# Environment & runtime files
.env
Expand All @@ -11,3 +12,19 @@ node_modules/
# Ignore editor stuff
.vscode/
.idea/

# ui
ui/.next
ui/build
ui/coverage
ui/test-results

# lambda
lambdas/.coverage
lambdas/dist
lambdas/coverage
lambdas/test-results

# local env & postman
postman/
local-environment/
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
"postinstall": "npm --prefix ui install && npm --prefix lambdas install && npm --prefix tests install",
"test": "npm --prefix ui run test && npm --prefix lambdas run test",
"test:playwright": "UI_BASE_URL=$(terraform -chdir=local-environment/infra output -raw ui_url) API_BASE_URL=$(terraform -chdir=local-environment/infra output -raw api_base_url) npm --prefix tests run test:chrome",
"format": "(git diff --name-only --diff-filter=ACMR -z; git diff --name-only --cached --diff-filter=ACMR -z) | sort -zu | xargs -0 sh -c '[ \"$#\" -gt 0 ] && npm run format:pre-commit -- \"$@\"' sh",
"format:pre-commit": "prettier --write --ignore-unknown --",
Comment thread
cptiv2020 marked this conversation as resolved.
"lint": "npm --prefix ui run lint && npm --prefix lambdas run lint && npm --prefix tests run lint",
"build:lambdas": "npm --prefix lambdas run build",
"package:lambdas": "npm --prefix lambdas run package",
"start": "npm ci && npm run local:start",
Expand Down
Loading