Skip to content

pre-commit integration #2185

@juftin

Description

@juftin

Description

For a work project, we have a need of automating running a Taskfile task whenever a particular file changes and we want to automate this with pre-commit. Since there isn't an official Taskfile pre-commit hook I opted to write my own - I figured that I'd share in case this is a use case that Task would like to officially support:

# yaml-language-server: $schema=https://json.schemastore.org/pre-commit-config.json

repos:
  - repo: local
    hooks:
      - id: airflow-lockfile-update
        name: airflow-lockfile-update
        language: golang
        pass_filenames: false
        files: airflow/pyproject.toml
        entry: task
        args: ["--dir", "airflow", "update-requirements"]
        additional_dependencies:
          - "github.com/go-task/task/v3/cmd/task@v3.42.1"

Here's what this would look like if it were officially supported:

# yaml-language-server: $schema=https://json.schemastore.org/pre-commit-config.json

repos:
  - repo: https://github.com/go-task/task
    rev: v3.42.1
    hooks:
      - id: task
        files: airflow/pyproject.toml
        args: ["--dir", "airflow", "update-requirements"]

If this is something that looks useful I'd be happy to contribute - it would require a .pre-commit-hooks.yaml to be placed at the root of the repo:

# yaml-language-server: $schema=https://json.schemastore.org/pre-commit-hooks.json

- id: task
  name: task
  description: Runs a task on your project
  language: golang
  entry: task
  pass_filenames: false
  require_serial: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    state: needs triageWaiting to be triaged by a maintainer.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions