diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 081079fc..1ca2ded0 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -9,16 +9,14 @@ on: workflow_dispatch: inputs: dbt_adapters_branch: - description: "The branch of dbt-adapters to evaluate" - type: string - required: true - default: "main" + description: "The branch of dbt-adapters to evaluate" + type: string + default: "main" workflow_call: inputs: dbt_adapters_branch: description: "The branch of dbt-adapters to evaluate" type: string - required: true default: "main" permissions: read-all @@ -27,16 +25,12 @@ permissions: read-all concurrency: group: ${{ github.workflow }}-${{ github.event_name }}-${{ contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref || github.sha }} cancel-in-progress: true -env: - # set DBT_ADAPTERS_BRANCH to the input value if the event is a workflow_dispatch (workflow_call uses the same event_name), - # otherwise use 'main' - DBT_ADAPTERS_BRANCH: ${{ github.event_name == 'workflow_dispatch' && inputs.dbt_adapters_branch || 'main' }} + jobs: code-quality: name: Code Quality runs-on: ubuntu-latest - steps: - name: Check out repository uses: actions/checkout@v4 @@ -44,17 +38,13 @@ jobs: persist-credentials: false - name: Update Adapters and Core branches + if: ${{ contains(github.event_name, 'workflow_') }} shell: bash - run: | - ./.github/scripts/update_dev_packages.sh \ - $DBT_ADAPTERS_BRANCH \ - "main" + run: ./.github/scripts/update_dev_packages.sh ${{ inputs.dbt_adapters_branch }} "main" - name: Setup `hatch` uses: dbt-labs/dbt-adapters/.github/actions/setup-hatch@main - - name: Run linters - run: hatch run lint:all - - - name: Run typechecks - run: hatch run typecheck:all + - name: Run code quality + shell: bash + run: hatch run code-quality diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 975340e6..faf87499 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,33 +1,30 @@ -# For more on configuring pre-commit hooks (see https://pre-commit.com/) - -# Force all unspecified python hooks to run python 3.8 default_language_version: - python: python3 + python: python3 repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 - hooks: - - id: check-yaml - args: [--unsafe] - - id: check-json - - id: end-of-file-fixer - - id: trailing-whitespace - - id: check-case-conflict -- repo: local - hooks: - - id: black - name: black - entry: black - language: system - types: [python] - - id: flake8 - name: flake8 - entry: flake8 - language: system - types: [python] - - id: mypy - name: mypy - entry: mypy - language: system - types: [python] +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + args: [--unsafe] + - id: check-json + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-case-conflict +- repo: local + hooks: + - id: black + name: black + entry: black + language: system + types: [python] + - id: flake8 + name: flake8 + entry: flake8 + language: system + types: [python] + - id: mypy + name: mypy + entry: mypy + language: system + types: [python] diff --git a/pyproject.toml b/pyproject.toml index da81af72..05e535f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,31 +70,10 @@ dependencies = [ ] post-install-commands = ["pre-commit install"] [tool.hatch.envs.default.scripts] -precommit = "pre-commit run --all-files" - -[tool.hatch.envs.lint] -detached = true -dependencies = [ - "black>=24.3", - "flake8", - "Flake8-pyproject", -] -[tool.hatch.envs.lint.scripts] -all = [ - "black", - "flake8", -] +code-quality = "pre-commit run --all-files" # runs others via hooks black = "python -m black ." flake8 = "python -m flake8 ." - -[tool.hatch.envs.typecheck] -dependencies = [ - "mypy", - "types-protobuf", - "types-pytz", -] -[tool.hatch.envs.typecheck.scripts] -all = "python -m mypy ." +mypy = "python -m mypy ." [tool.hatch.envs.unit-tests] dependencies = [ @@ -105,7 +84,6 @@ dependencies = [ "pytest-xdist", ] extra-dependencies = [ - # TODO: remove `dbt-core` dependencies from unit tests "dbt-adapters @ git+https://github.com/dbt-labs/dbt-adapters.git", "dbt-common @ git+https://github.com/dbt-labs/dbt-common.git", "dbt-core @ git+https://github.com/dbt-labs/dbt-core.git#subdirectory=core",