forked from chainguard-dev/actions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
81 lines (70 loc) · 2.4 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Copyright 2022 Chainguard, Inc.
# SPDX-License-Identifier: Apache-2.0
name: 'boilerplate'
description: |
This action runs a tool over the files in the working tree
to check for boilerplate license headers.
inputs:
extension:
description: |
The file extension (no '.') for files to match.
required: true
default: go
language:
description: |
The human-readable language name (matching extension)
required: true
default: Go
boilerplate-directory:
description: |
The directory in which to look for `boilerplate.{extension}.txt` files.
required: true
default: ./hack/boilerplate
exclude:
description: |
Regular expression of paths to exclude.
required: false
default: ((vendor|third_party)/|.pb(.gw)?.go|.generated.go)
runs:
using: "composite"
steps:
# Go is an implementation detail of this action (go get below)
# TODO(mattmoor): Cut a release of `boilerplate-check` we can use instead.
- name: Set up Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: '1.22'
check-latest: true
cache: false
- uses: reviewdog/action-setup@1d18b2938261447f64c39f831d7395e90ef5a40e # v1.2.1
with:
reviewdog_version: latest
- name: Install Tools
shell: bash
run: |
cd "$(mktemp -d)"
echo '::group:: Installing boilerplate-check ... https://github.com/mattmoor/boilerplate-check'
go install github.com/mattmoor/boilerplate-check/cmd/boilerplate-check@latest
echo '::endgroup::'
- name: check boilerplate
shell: bash
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
run: |
set -e
cd "${GITHUB_WORKSPACE}" || exit 1
echo '::group:: Running github.com/mattmoor/boilerplate-check for ${{ inputs.language }} with reviewdog 🐶 ...'
# Don't fail because of boilerplate-check
set +o pipefail
boilerplate-check check \
--boilerplate ${{ inputs.boilerplate-directory }}/boilerplate.${{ inputs.extension }}.txt \
--file-extension ${{ inputs.extension }} \
--exclude "${{ inputs.exclude }}" |
reviewdog -efm="%A%f:%l: %m" \
-efm="%C%.%#" \
-name="${{ inputs.language }} headers" \
-reporter="github-pr-check" \
-filter-mode="diff_context" \
-fail-on-error="true" \
-level="error"
echo '::endgroup::'