chore: set up GitHub Actions to verify build from sources
1 file changed
tree: ea5ed0cec20cc6b35c07737a1e2e1a55aa027876
  1. .github/
  2. cmd/
  3. test/
  4. util/
  5. .gitignore
  6. .licenserc.json
  7. go.mod
  8. go.sum
  9. LICENSE
  10. main.go
  11. Makefile
  12. README.md
README.md

license-checker

A CLI tool for checking license headers, which theoretically supports checking all types of files.

Install

git clone https://github.com/fgksgf/license-checker.git
cd license-checker
make

Usage

Usage: license-checker [flags]

license-checker walks the specified path recursively and checks 
if the specified files have the license header in the config file.

Usage:
  license-checker [flags]

Flags:
  -c, --config string   the config file (default ".licenserc.json")
  -h, --help            help for license-checker
  -l, --loose           loose mode
  -p, --path string     the path to check (default ".")
  -v, --verbose         verbose mode

Configuration

{
  // What to check in strict mode, the order of strings can NOT be changed arbitrarily
  "licenseStrict": [
    "Licensed to the Apache Software Foundation (ASF) under one or more",
    "contributor license agreements.  See the NOTICE file distributed with",
    "..."
  ],

  // What to check in loose mode, the order of strings can NOT be changed arbitrarily
  "licenseLoose": [
    "Apache License, Version 2.0"
  ],

  // license-checker will check *.java and *.go
  "targetFiles": [
    "java",
    "go"
  ],

  "exclude": {
    // license-checker will NOT check these files
    "files": [
      ".gitignore",
      "NOTICE",
      "LICENSE"
    ],

    // license-checker will NOT check files whose names with these extensions
    "extensions": [
      "md",
      "xml",
      "json"
    ],

    // license-checker will NOT check these directories
    "directories": [
      "bin",
      ".github"
    ]
  }
}

Test

bin/license-checker -p test -c test/.licenserc_for_test.json

[No Specified License]: test/include_test/without_license/testcase.go
[No Specified License]: test/include_test/without_license/testcase.graphql
[No Specified License]: test/include_test/without_license/testcase.java
[No Specified License]: test/include_test/without_license/testcase.py
[No Specified License]: test/include_test/without_license/testcase.sh
[No Specified License]: test/include_test/without_license/testcase.yaml
[No Specified License]: test/include_test/without_license/testcase.yml
Total check 14 files, success: 7, failure: 7