Merge pull request #182 from thepetk/ft/update_license_header #733
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Validate PRs | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Go environment | |
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0 | |
with: | |
go-version: 1.19 | |
id: go | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
- name: Check go mod status | |
run: | | |
make gomod_tidy | |
if [[ ! -z $(git status -s) ]] | |
then | |
echo "Go mod state is not clean" | |
git diff "$GITHUB_SHA" | |
exit 1 | |
fi | |
- name: Build Binary | |
run: make bin | |
- name: Check format | |
run: | | |
make gofmt | |
if [[ ! -z $(git status -s) ]] | |
then | |
echo "not well formatted sources are found : $(git status -s)" | |
exit 1 | |
fi | |
- name: Check license | |
run: | | |
go install github.com/google/addlicense@latest | |
git reset HEAD --hard | |
make check_license | |
if [[ $? != 0 ]] | |
then | |
echo "not well formatted sources are found:" | |
git --no-pager diff | |
exit 1 | |
fi | |
- name: Run Go Tests | |
run: make test | |
- name: Run Gosec Security Scanner | |
run: | | |
go install github.com/securego/gosec/v2/cmd/[email protected] | |
make gosec | |
if [[ $? != 0 ]] | |
then | |
echo "gosec scanner failed to run " | |
exit 1 | |
fi | |
- name: Upload SARIF file | |
uses: github/codeql-action/upload-sarif@v2 | |
with: | |
# Path to SARIF file relative to the root of the repository | |
sarif_file: gosec.sarif | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 |