diff --git a/.circleci/config.yml b/.circleci/config.yml index 57fdc36fd..6a7806467 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -128,6 +128,9 @@ workflows: - pre-commit: filters: *filters-allow-all + - lint-and-prettier: + filters: *filters-allow-all + - docker-build-server: context: &build-context - github-readonly-public-repos @@ -202,6 +205,7 @@ workflows: - docker-build-server - get-version - pre-commit + - lint-and-prettier - publish-approval - test-frontend-2 - test-viewer @@ -219,6 +223,7 @@ workflows: - docker-build-frontend-2 - get-version - pre-commit + - lint-and-prettier - publish-approval - test-frontend-2 - test-viewer @@ -245,6 +250,7 @@ workflows: - docker-build-webhooks - get-version - pre-commit + - lint-and-prettier - publish-approval - test-frontend-2 - test-viewer @@ -262,6 +268,7 @@ workflows: - docker-build-file-imports - get-version - pre-commit + - lint-and-prettier - publish-approval - test-frontend-2 - test-viewer @@ -279,6 +286,7 @@ workflows: - docker-build-previews - get-version - pre-commit + - lint-and-prettier - publish-approval - test-frontend-2 - test-viewer @@ -296,6 +304,7 @@ workflows: - docker-build-test-container - get-version - pre-commit + - lint-and-prettier - publish-approval - test-frontend-2 - test-viewer @@ -325,6 +334,7 @@ workflows: - docker-build-monitor-container - get-version - pre-commit + - lint-and-prettier - publish-approval - test-frontend-2 - test-viewer @@ -417,46 +427,54 @@ jobs: paths: - env-vars + lint-and-prettier: + <<: *docker-node-image + resource_class: xlarge + working_directory: *work-dir + steps: + - checkout + - *yarn + - run: + name: Build public packages + command: yarn build:public + - run: + name: Lint everything + command: yarn eslint:projectwide + - run: + name: Run prettier check + command: yarn prettier:check + - run: + name: Check JSON Schema is up to date + command: | + yarn helm:jsonschema:generate + git diff --exit-code + pre-commit: parameters: config_file: default: ./.pre-commit-config.yaml description: Optional, path to pre-commit config file. type: string - deployment_config_file: - default: ./.pre-commit-config.deployment.yaml - description: Optional, path to additional 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: speckle/pre-commit-runner:latest - resource_class: xlarge + resource_class: large working_directory: *work-dir steps: - checkout - restore_cache: name: Restore pre-commit & Yarn Package cache keys: - - cache-pre-commit-<>-{{ checksum "<>" }} - - yarn-packages-{{ checksum "yarn.lock" }} + - cache-pre-commit--{{ checksum "<>" }} - run: name: Install pre-commit hooks command: pre-commit install-hooks --config <> - save_cache: - key: cache-pre-commit-<>-{{ checksum "<>" }} + key: cache-pre-commit--{{ checksum "<>" }} paths: - ~/.cache/pre-commit - - *yarn - - run: - name: Build public packages - command: yarn build:public - run: name: Run pre-commit - command: ./.husky/pre-commit + command: pre-commit run --all-files --config <> - run: command: git --no-pager diff name: git diff diff --git a/.husky/pre-commit b/.husky/pre-commit index dfc982ab4..d7bbabf7b 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,39 +2,27 @@ # shellcheck disable=SC1091 set -e -if [ -n "$CI" ] -then - echo "running eslint" - yarn eslint:projectwide - echo "...eslint done" - echo "running prettier" - yarn prettier:check - echo "...prettier done" -else # shellcheck disable=SC1090 - . "$(dirname "$0")/_/husky.sh" - yarn lint-staged -fi - -echo "🔍 looking for additional linter dependencies" +. "$(dirname "$0")/_/husky.sh" +yarn lint-staged check_dependencies_available() { + echo "🔍 looking for additional linter dependencies" for i in "${@}" do - if ! command -v "${i}"; then + if ! command "${i}"; then echo "No ${i} executable found skipping additional checks" >&2 exit 0 fi done + echo "✅ All additional dependencies found" } -additional_dependencies="" -if [ -z "${CI}" ]; then - additional_dependencies=" ggshield" -fi - # shellcheck disable=SC2086 -check_dependencies_available pre-commit hadolint helm shellcheck circleci${additional_dependencies} +check_dependencies_available pre-commit hadolint helm shellcheck circleci ggshield -echo "All systems functional, running additional pre-commit checks..." +echo "🍵 Updating JSON schema for Helm chart" +yarn helm:jsonschema:generate + +echo "▶️ Running pre-commit hooks" pre-commit run --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cfa71703e..f375075da 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,15 +36,6 @@ repos: args: - --ignore=E501 # ignoring error about lines that are too long - - repo: local - hooks: - - id: helm-documentation - name: Helm Json Schema - language: system - files: utils\/helm\/speckle\-server\/values\.yaml - entry: utils/helm/update-schema-json.sh - description: If this fails it is because the values.yaml file was updated. Or has missing or incorrect documentation. - # helmlint should occur after the json schema is updated - repo: https://github.com/gruntwork-io/pre-commit rev: 'v0.1.17' diff --git a/package.json b/package.json index 8b18a9e23..74b22186a 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "cm": "cz", "eslint:inspect": "eslint-config-inspector", "eslint:projectwide": "node ./utils/eslint-projectwide.mjs", + "helm:jsonschema:generate": "./utils/helm/update-schema-json.sh", "npkill": "npkill" }, "devDependencies": { diff --git a/utils/helm/update-schema-json.sh b/utils/helm/update-schema-json.sh index 6d1d5813f..d0b8693f8 100755 --- a/utils/helm/update-schema-json.sh +++ b/utils/helm/update-schema-json.sh @@ -45,5 +45,6 @@ pushd "${GIT_ROOT}" --values "${GIT_ROOT}/utils/helm/speckle-server/values.yaml" \ --schema "${JSON_SCHEMA_PATH}" + echo "📄 Formatting the generated JSON schema" yarn prettier:fix:file "${JSON_SCHEMA_PATH}" popd