Skip to content

Commit

Permalink
chore(makefile): add Makefile (aquasecurity#256)
Browse files Browse the repository at this point in the history
* chore(makefile): add Makefile

* chore(ci): use make

* chore(makefile): add clean

* chore(makefile): fix test commands

* chore(ci): split tests into the unit test and the integration test
  • Loading branch information
knqyf263 authored Nov 6, 2019
1 parent 8ea2e8c commit 4f92d29
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ jobs:
fi
- run:
name: Test
command: go test ./...
command: make test
- run:
name: Integration Test
command: make test-integration
release:
<<: *defaults
steps:
Expand Down
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
VERSION := $(shell git describe --tags)
LDFLAGS=-ldflags "-s -w -X=main.version=$(VERSION)"

GOPATH=$(shell go env GOPATH)
GOBIN=$(GOPATH)/bin

u := $(if $(update),-u)

.PHONY: deps
deps:
go get ${u} -d
go mod tidy

$(GOBIN)/golangci-lint:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(GOBIN) v1.21.0

.PHONY: test
test:
go test -v -short ./...

integration/testdata/fixtures/*.tar.gz:
git clone https://github.com/aquasecurity/trivy-test-images.git integration/testdata/fixtures

.PHONY: test-integration
test-integration: integration/testdata/fixtures/*.tar.gz
go test -v -tags=integration ./integration/...

.PHONY: lint
lint: $(GOBIN)/golangci-lint
$(GOBIN)/golangci-lint run

.PHONY: build
build:
go build $(LDFLAGS) ./cmd/trivy

.PHONY: install
install:
go install $(LDFLAGS) ./cmd/trivy

.PHONY: clean
clean:
rm -rf integration/testdata/fixtures/
2 changes: 2 additions & 0 deletions integration/tar_input_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build integration

package integration_test

import (
Expand Down
Loading

0 comments on commit 4f92d29

Please sign in to comment.