From c8d28485c9c5ec300ba0145a44ebedf887879098 Mon Sep 17 00:00:00 2001 From: "Becker, Christoph" Date: Thu, 17 Oct 2024 12:40:16 +0200 Subject: [PATCH 1/5] feat: add pre-commit hook chore: migrate pre commit config --- .commitlintrc.yaml | 26 +++++++++++++++++++++++ .pre-commit-config.yaml | 47 +++++++++++++++++++++++++++++++++++++++++ .prettierrc | 8 +++++++ 3 files changed, 81 insertions(+) create mode 100644 .commitlintrc.yaml create mode 100644 .pre-commit-config.yaml create mode 100644 .prettierrc diff --git a/.commitlintrc.yaml b/.commitlintrc.yaml new file mode 100644 index 0000000..a5594f4 --- /dev/null +++ b/.commitlintrc.yaml @@ -0,0 +1,26 @@ +extends: + - '@commitlint/config-conventional' +rules: + # Scope enum should be customized to match project needs + scope-enum: + - 2 + - always + - [] + # Type enum should be consistent across data science projects + type-enum: + - 2 + - always + - - build + - chore + - ci + - docs + - feat + - fix + - perf + - refactor + - revert + - style + - test + - data + - explore + - result diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..5e9b736 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,47 @@ +default_install_hook_types: [pre-commit, commit-msg] +default_stages: [commit, manual] +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 + hooks: + - id: check-added-large-files + args: + - '--maxkb=10000' + - id: end-of-file-fixer + - id: check-json + - id: check-toml + - id: check-xml + - id: check-case-conflict + - id: check-symlinks + - id: check-merge-conflict + stages: + - commit + - merge-commit + - manual + - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook + rev: v9.16.0 + hooks: + - id: commitlint + additional_dependencies: ['@commitlint/config-conventional'] + stages: + - commit-msg + - repo: https://github.com/prettier/pre-commit + rev: v2.1.2 + hooks: + - id: prettier + - repo: https://github.com/pre-commit/mirrors-eslint + rev: 'v9.6.0' + hooks: + - id: eslint + args: + - '--fix' + - '--config' + - 'eslint.config.js' + additional_dependencies: + - eslint@9.6.0 + - '@eslint/js@9.6.0' + - 'typescript-eslint@7.15.0' + - 'angular-eslint@18.1.0' + - eslint-config-prettier@9.1.0 + files: \.(ts|html)$ + types: [file] diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..810f444 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "tabWidth": 4, + "arrowParens": "always", + "quoteProps": "consistent", + "printWidth": 120 +} From 84029d1120d460ecebf6a7feedcef76a4c7169da Mon Sep 17 00:00:00 2001 From: "Becker, Christoph" Date: Thu, 17 Oct 2024 12:58:05 +0200 Subject: [PATCH 2/5] ci: run pre commit in ci --- .github/workflows/lint.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/lint.yaml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..aa7b66b --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,20 @@ +name: Linting +on: + push: + +env: + PYTHON_VERSION: 3.12 + NODE_VERSION: 18.12 + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + - uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + - uses: pre-commit/action@v3.0.1 From fb631d882daae26207caa1113bf103b3efa27df1 Mon Sep 17 00:00:00 2001 From: "Becker, Christoph" Date: Thu, 17 Oct 2024 15:37:26 +0200 Subject: [PATCH 3/5] chore: fix linting inssue --- .github/workflows/build-docker.yaml | 70 ++++++++++++++--------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index 989dcce..e8daf53 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -1,42 +1,42 @@ name: Create and publish a Docker image on: - push: - branches: ['main'] + push: + branches: ['main'] env: - REGISTRY: ghcr.io - IMAGE_NAME: accenture/federated-catalogue-viewer + REGISTRY: ghcr.io + IMAGE_NAME: accenture/federated-catalogue-viewer jobs: - build-and-push-image: - runs-on: ubuntu-latest - - permissions: - contents: read - packages: write - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to the Container registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - platforms: linux/amd64,linux/arm64 - context: . - push: true - tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + build-and-push-image: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64 + context: . + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest From 4427962ec10a74bc75d1d284a3dfff395ca89245 Mon Sep 17 00:00:00 2001 From: "Becker, Christoph" Date: Thu, 17 Oct 2024 15:44:52 +0200 Subject: [PATCH 4/5] ci: add the linting workflow as pre condition for the build job --- .github/workflows/build-docker.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index e8daf53..8c5a3b0 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -1,8 +1,13 @@ -name: Create and publish a Docker image +name: Build on: - push: - branches: ['main'] + workflow_run: + workflows: + - Linting + types: + - completed + branches: + - main env: REGISTRY: ghcr.io From d3d3cf70bac767cf2dac9f6698faad79c8d0f07e Mon Sep 17 00:00:00 2001 From: Christoph Becker Date: Fri, 18 Oct 2024 10:15:32 +0200 Subject: [PATCH 5/5] Update .commitlintrc.yaml Co-authored-by: Fabian Scheidt --- .commitlintrc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.commitlintrc.yaml b/.commitlintrc.yaml index a5594f4..22cacc1 100644 --- a/.commitlintrc.yaml +++ b/.commitlintrc.yaml @@ -5,7 +5,7 @@ rules: scope-enum: - 2 - always - - [] + - ['deps'] # Type enum should be consistent across data science projects type-enum: - 2