Skip to content

Commit

Permalink
BUILD/MINOR: ci: add check to see if go packages have correct licenses
Browse files Browse the repository at this point in the history
  • Loading branch information
oktalz committed Dec 19, 2023
1 parent 941d3cc commit a1e5395
Show file tree
Hide file tree
Showing 3 changed files with 47 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 @@ -77,6 +77,33 @@ jobs:
with:
file_or_dir: .
config_file: .yamllint.yml
license:
name: license-check
needs: ["generate-specification","generate-models"]
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: Check Licenses
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-specification","generate-models"]
Expand Down
19 changes: 19 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ tidy:

lint:
stage: lint
needs: ["build"]
image:
name: $CI_REGISTRY_GO/golang:$GO_VERSION
entrypoint: [""]
Expand All @@ -103,6 +104,24 @@ lint:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'

license-check:
stage: lint
needs: ["build"]
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 == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'push'

lint-commit-msg:
stage: lint
needs: ["build"]
Expand Down

0 comments on commit a1e5395

Please sign in to comment.