From 28303061b170f21b48fbcaa3bc808c6f51a78acd Mon Sep 17 00:00:00 2001 From: Zlatko Bratkovic Date: Mon, 18 Dec 2023 21:12:44 +0100 Subject: [PATCH] BUILD/MINOR: ci: add check to see if go packages comply to --- .allowed_license_types | 1 + .github/workflows/actions.yml | 27 +++++++++++++++++++++++++++ .gitlab-ci.template.yml | 15 +++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 .allowed_license_types diff --git a/.allowed_license_types b/.allowed_license_types new file mode 100644 index 0000000..d8bba03 --- /dev/null +++ b/.allowed_license_types @@ -0,0 +1 @@ +MIT,BSD-2-Clause,BSD-3-Clause,Apache-2.0,ISC diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index c3f0ee8..fa09b6a 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -48,6 +48,33 @@ jobs: - name: Lint run: | make lint + license: + name: license-check + needs: ["generate"] + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version-file: 'go.mod' + - uses: actions/cache@v2 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: go-licenses install + run: go install github.com/google/go-licenses@latest + - name: Lint + run: | + PROJECT="$(go list -m)" + ALLOWED_LICENSES="$(<.allowed_license_types)" + go-licenses report --ignore "$PROJECT" . + go-licenses check --allowed_licenses="$ALLOWED_LICENSES" --ignore "$PROJECT" . tidy: name: go mod tidy needs: ["generate"] diff --git a/.gitlab-ci.template.yml b/.gitlab-ci.template.yml index 73be702..5de892b 100644 --- a/.gitlab-ci.template.yml +++ b/.gitlab-ci.template.yml @@ -29,6 +29,21 @@ lint: - make lint rules: - if: '$CI_PIPELINE_SOURCE == "parent_pipeline"' +license-check: + stage: lint + image: + name: $CI_REGISTRY_GO/golang:$GO_VERSION + entrypoint: [""] + tags: + - go + script: + - go install github.com/google/go-licenses@latest + - PROJECT="$(go list -m)" + - ALLOWED_LICENSES="$(<.allowed_license_types)" + - go-licenses report --ignore "$PROJECT" . + - go-licenses check --allowed_licenses="$ALLOWED_LICENSES" --ignore "$PROJECT" . + rules: + - if: '$CI_PIPELINE_SOURCE == "parent_pipeline"' tidy: stage: lint image: