diff --git a/.circleci/config.yml b/.circleci/config.yml index 5ce12c8d2..52759585b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,6 +10,7 @@ workflows: tags: # run tests for all tags only: /.*/ + - get-version: filters: &filters-build tags: @@ -18,6 +19,12 @@ workflows: only: - main + - pre-commit: + cache_prefix: '7' + filters: + tags: + only: /.*/ + - docker-build-and-publish-server: filters: *filters-build context: &docker-hub-context @@ -111,6 +118,45 @@ jobs: paths: - env-vars + pre-commit: + parameters: + config_file: + default: ./.pre-commit-config.yaml + description: Optional, path to pre-commit config file. + type: string + cache_prefix: + default: '' + description: | + Optional cache prefix to be used on CircleCI. Can be used for cache busting or to ensure multiple jobs use different caches. + type: string + docker: + - image: cimg/python:3.10.6-node + resource_class: large + working_directory: *work-dir + steps: + - checkout + - restore_cache: + keys: + - cache-pre-commit-<>-{{ checksum "<>" }} + - run: + name: Install pre-commit + command: pre-commit --version || pip install --progress-bar=off pre-commit + - run: + name: Install pre-commit hooks + command: pre-commit install-hooks --config <> + - save_cache: + key: cache-pre-commit-<>-{{ checksum "<>" }} + paths: + - ~/.cache/pip + - ~/.cache/pre-commit + - run: + name: Run pre-commit + command: pre-commit run --all-files --config <> + - run: + command: git --no-pager diff + name: git diff + when: on_fail + test-server: docker: - image: cimg/node:16.15 diff --git a/package.json b/package.json index b44452513..0bc20cff4 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "lint": "eslint . --ext .js,.ts,.vue --max-warnings=0", "prettier:check": "prettier --check .", "prettier:fix": "prettier --write .", + "circleci:check": "circleci config validate ./.circleci/config.yml", "dev:docker:up": "docker-compose -f ./docker-compose-deps.yml -f ./docker-compose-dev.yml up -d", "dev:docker:down": "docker-compose -f ./docker-compose-deps.yml -f ./docker-compose-dev.yml down", "dev": "yarn workspaces foreach -piv -j unlimited run dev",