Skip to content

Commit

Permalink
BUILD/MINOR: ci: add check to see if go packages comply to
Browse files Browse the repository at this point in the history
  • Loading branch information
oktalz committed Dec 18, 2023
1 parent 67d880c commit 2830306
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions .allowed_license_types
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MIT,BSD-2-Clause,BSD-3-Clause,Apache-2.0,ISC
27 changes: 27 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
15 changes: 15 additions & 0 deletions .gitlab-ci.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 2830306

Please sign in to comment.