From 0489d6adec7dcc6dba28e02e9e33f9f08505ab06 Mon Sep 17 00:00:00 2001 From: Darren Kelly <107671032+darrenvechain@users.noreply.github.com> Date: Thu, 9 May 2024 15:49:02 +0100 Subject: [PATCH] add GHA to check for license (#731) * add GHA to check for license" * fix GHA * update license.yaml --- .github/workflows/license-check.yaml | 13 +++++++++++++ .github/workflows/on-master-commit.yaml | 9 +++++++-- .github/workflows/on-pull-request.yaml | 4 ++++ .licenserc.yaml | 20 ++++++++++++++++++++ Makefile | 5 +++++ thor/blocklist_test.go | 5 +++++ thor/fork_config_test.go | 5 +++++ thor/receipt_correction_test.go | 5 +++++ trie/derive_root_test.go | 5 +++++ 9 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/license-check.yaml create mode 100644 .licenserc.yaml diff --git a/.github/workflows/license-check.yaml b/.github/workflows/license-check.yaml new file mode 100644 index 000000000..8e1edd835 --- /dev/null +++ b/.github/workflows/license-check.yaml @@ -0,0 +1,13 @@ +name: License Check + +on: + workflow_call: + +jobs: + license-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: License Check + uses: apache/skywalking-eyes@v0.6.0 diff --git a/.github/workflows/on-master-commit.yaml b/.github/workflows/on-master-commit.yaml index af272c803..994907666 100644 --- a/.github/workflows/on-master-commit.yaml +++ b/.github/workflows/on-master-commit.yaml @@ -9,9 +9,13 @@ jobs: run-unit-tests: name: Run Unit Tests uses: ./.github/workflows/test.yaml - secrets: + secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + license-check: + name: License Check + uses: ./.github/workflows/license-check.yaml + lint: name: Lint uses: ./.github/workflows/lint-go.yaml @@ -43,6 +47,7 @@ jobs: - run-e2e-tests - generate-tags - lint + - license-check permissions: contents: read packages: write @@ -61,7 +66,7 @@ jobs: - generate-tags - lint - run-unit-tests - if: always() && (needs.publish-docker-image.result != 'success' || needs.run-unit-tests.result != 'success' || needs.lint.result != 'success' || needs.run-e2e-tests.result != 'success') + if: always() && (needs.publish-docker-image.result != 'success' || needs.run-unit-tests.result != 'success' || needs.lint.result != 'success' || needs.run-e2e-tests.result != 'success' || needs.license-check.result != 'success') runs-on: ubuntu-latest steps: - name: Notify Slack diff --git a/.github/workflows/on-pull-request.yaml b/.github/workflows/on-pull-request.yaml index ef9aef511..79dc2a5f4 100644 --- a/.github/workflows/on-pull-request.yaml +++ b/.github/workflows/on-pull-request.yaml @@ -16,6 +16,10 @@ jobs: secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + license-check: + name: License Check + uses: ./.github/workflows/license-check.yaml + run-e2e-tests: name: E2E Tests uses: ./.github/workflows/test-e2e.yaml diff --git a/.licenserc.yaml b/.licenserc.yaml new file mode 100644 index 000000000..1bd0fe869 --- /dev/null +++ b/.licenserc.yaml @@ -0,0 +1,20 @@ +# See: https://github.com/apache/skywalking-eyes +header: + license: + spdx-id: GPL-3.0-or-later + # This is the pattern used when running: + # docker run -it --rm -v $(pwd):/github/workspace apache/skywalking-eyes header check + pattern: | + Copyright(?: \(c\))? \b(19\d{2}|20\d{2})\b The (VeChainThor developers|go-ethereum Authors) + # This is content written to files when running: + # docker run -it --rm -v $(pwd):/github/workspace apache/skywalking-eyes header fix + content: | + Copyright (c) 2024 The VeChainThor developers + + Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying + file LICENSE or + paths: + - '**/*.go' + paths-ignore: + - 'builtin/gen/bindata.go' + - 'tracers/**/gen_*.go' diff --git a/Makefile b/Makefile index d2b5376f5..6d344245c 100644 --- a/Makefile +++ b/Makefile @@ -62,5 +62,10 @@ lint_command_check: lint: | go_version_check lint_command_check #@ Run 'golangci-lint' @golangci-lint run --config .golangci.yml +license-check: #@ Check license headers + @FILE_COUNT=$$(find . -type f -name '*.go' | wc -l); \ + echo "Checking license headers for all .go... $$FILE_COUNT files found"; \ + docker run -it --rm -v $$(pwd):/github/workspace apache/skywalking-eyes header check + .DEFAULT: @$(MAKE) help diff --git a/thor/blocklist_test.go b/thor/blocklist_test.go index 6ca4e875d..283a3e49c 100644 --- a/thor/blocklist_test.go +++ b/thor/blocklist_test.go @@ -1,3 +1,8 @@ +// Copyright (c) 2024 The VeChainThor developers + +// Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying +// file LICENSE or + package thor import "testing" diff --git a/thor/fork_config_test.go b/thor/fork_config_test.go index 3fb05b968..fd4916c28 100644 --- a/thor/fork_config_test.go +++ b/thor/fork_config_test.go @@ -1,3 +1,8 @@ +// Copyright (c) 2024 The VeChainThor developers + +// Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying +// file LICENSE or + package thor import ( diff --git a/thor/receipt_correction_test.go b/thor/receipt_correction_test.go index f261dd11b..ca2f12586 100644 --- a/thor/receipt_correction_test.go +++ b/thor/receipt_correction_test.go @@ -1,3 +1,8 @@ +// Copyright (c) 2024 The VeChainThor developers + +// Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying +// file LICENSE or + package thor import ( diff --git a/trie/derive_root_test.go b/trie/derive_root_test.go index c37deee28..3ade78cc1 100644 --- a/trie/derive_root_test.go +++ b/trie/derive_root_test.go @@ -1,3 +1,8 @@ +// Copyright (c) 2024 The VeChainThor developers + +// Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying +// file LICENSE or + package trie import (