Skip to content

pre-commit integration #2185

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions