Giter Site home page Giter Site logo

checkmake's Introduction

checkmake

Build Status Coverage Status Code Climate Packagecloud MIT license

Overview

checkmake is an experimental tool for linting and checking Makefiles. It may not do what you want it to.

Usage

% checkmake Makefile

% checkmake Makefile foo.mk bar.mk baz.mk

% checkmake --help
checkmake.

Usage:
checkmake [--debug|--config=<configPath>] <makefile>...
checkmake -h | --help
checkmake --version

Options:
-h --help               Show this screen.
--version               Show version.
--debug                 Enable debug mode
--config=<configPath>   Configuration file to read
--list-rules            List registered rules

% checkmake fixtures/missing_phony.make

      RULE                 DESCRIPTION             LINE NUMBER

  minphony        Missing required phony target    0
                  "all"
  minphony        Missing required phony target    0
                  "test"
  phonydeclared   Target "all" should be           18
                  declared PHONY.

Docker usage

Build the image, or pull it:

docker build --build-arg BUILDER_NAME='Your Name' --build-arg [email protected] . -t checker

Then run it with your Makefile attached, below is an example of it assuming the Makefile is in your current working directory:

docker run -v "$PWD"/Makefile:/Makefile checker

pre-commit usage

This repo includes a pre-commit hook, which you may choose to use in your own repos. Simply add a .pre-commit-config.yaml to your repo's top-level directory

repos:
-   repo: https://github.com/mrtazz/checkmake.git
    # Or another commit hash or version
    rev: 0.2.2
    hooks:
    # Use this hook to let pre-commit build checkmake in its sandbox
    -   id: checkmake
    # OR Use this hook to use a pre-installed checkmark executable
    # -   id: checkmake-system

There are two hooks available:

  • checkmake (Recommended)

    pre-commit will set up a Go environment from scratch to compile and run checkmake. See the pre-commit golang plugin docs for more information.

  • checkmake-system

    pre-commit will look for checkmake on your PATH. This hook requires you to install checkmake separately, e.g. with your package manager or a prebuilt binary release. Only recommended if it's permissible to require all repository users install checkmake manually.

Then, run pre-commit as usual as a part of git commit or explicitly, for example:

pre-commit run --all-files

pre-commit in GitHub Actions

You may also choose to run this as a GitHub Actions workflow. To do this, add a .github/workflows/pre-commit.yml workflow to your repo:

name: pre-commit

on:
  pull_request:
    branches:
      - master
      - main
    paths:
      - '.pre-commit-config.yaml'
      - '.pre-commit-hooks.yaml'
      - 'Makefile'
      - 'makefile'
      - 'GNUmakefile'
      - '**.mk'
      - '**.make'
  push:
    paths:
      - '.pre-commit-config.yaml'
      - '.pre-commit-hooks.yaml'
      - 'Makefile'
      - 'makefile'
      - 'GNUmakefile'
      - '**.mk'
      - '**.make'

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-python@v3
    - name: Set up Go 1.17
      uses: actions/setup-go@v2
      with:
        go-version: 1.17
      id: go
    - uses: pre-commit/[email protected]

Installation

Requirements

The pandoc document converter utility is required to run checkmate. You can find out if you have it via which pandoc. Install pandoc if the command was not found.

With Go

With go 1.16 or higher:

go install github.com/mrtazz/checkmake/cmd/checkmake@latest
checkmake Makefile

Or alternatively, run it directly:

go run github.com/mrtazz/checkmake/cmd/checkmake@latest Makefile

Packages

There are packages for linux up on packagecloud.io or build it yourself with the steps below.

Build

To build checkmake you will need to have golang installed. Once you have Go installed, you can simply clone the repo and build the binary and man page yourself with the following commands.

git clone https://github.com/mrtazz/checkmake
cd checkmake
make

Use in CI

MegaLinter

checkmake is natively embedded within MegaLinter

To install it, run npx mega-linter-runner --install (requires Node.js)

Inspiration

This is totally inspired by an idea by Dan Buch.

checkmake's People

Contributors

ashmckenzie avatar christian-weiss avatar colindean avatar fdegier avatar haysclark avatar jimmywan avatar joakimr-axis avatar jonzeolla avatar mrtazz avatar nvuillam avatar peterdavehello avatar silverwind avatar stephengroat-dd avatar trinitronx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.