Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add govulncheck #164

Merged
merged 1 commit into from Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/govulncheck.yml
@@ -0,0 +1,31 @@
name: Check for Go vulnerabilities
# Runs https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck to proactively
# check for vulnerabilities in code packages if there were any changes made to
# any Go code or dependencies.
#
# Run `make vulncheck` from the root of the repo to run this workflow locally.
on:
pull_request:
push:
branches:
- main
- release/**

jobs:
govulncheck:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: "1.18"
- uses: actions/checkout@v3
- uses: technote-space/get-diff-action@v6
with:
PATTERNS: |
**/*.go
go.mod
go.sum
Makefile
- name: govulncheck
run: make vulncheck
if: "env.GIT_DIFF != ''"
17 changes: 14 additions & 3 deletions Makefile
@@ -1,37 +1,48 @@
GOPATH ?= $(shell go env GOPATH)
BUILD_DIR ?= ./build
.PHONY: build build-tm-load-test build-tm-outage-sim-server \
build-linux build-tm-load-test-linux build-tm-outage-sim-server-linux \
test lint clean
.DEFAULT_GOAL := build
BUILD_FLAGS ?= -mod=readonly

build: build-tm-load-test build-tm-outage-sim-server
.PHONY: build

build-tm-load-test:
@go build $(BUILD_FLAGS) \
-ldflags "-X github.com/informalsystems/tm-load-test/pkg/loadtest.cliVersionCommitID=`git rev-parse --short HEAD`" \
-o $(BUILD_DIR)/tm-load-test ./cmd/tm-load-test/main.go
.PHONY: build-tm-load-test

build-tm-outage-sim-server:
@go build $(BUILD_FLAGS) -o $(BUILD_DIR)/tm-outage-sim-server ./cmd/tm-outage-sim-server/main.go
.PHONY: built-tm-outage-sim-server

build-linux: build-tm-load-test-linux build-tm-outage-sim-server-linux
.PHONY: build-linux

build-tm-load-test-linux:
GOOS=linux GOARCH=amd64 $(MAKE) build-tm-load-test
.PHONY: build-tm-load-test-linux

build-tm-outage-sim-server-linux:
GOOS=linux GOARCH=amd64 $(MAKE) build-tm-outage-sim-server
.PHONY: build-tm-outage-sim-server-linux

test:
go test -cover -race ./...
.PHONY: test

bench:
go test -bench="Benchmark" -run="notests" ./...
.PHONY: bench

lint:
golangci-lint run ./...
.PHONY: lint

clean:
rm -rf $(BUILD_DIR)
.PHONY: clean

vulncheck:
@go run golang.org/x/vuln/cmd/govulncheck@latest ./...
.PHONY: vulncheck