mirror of
https://github.com/anchore/grype
synced 2024-11-10 06:34:13 +00:00
add basic pipeline
This commit is contained in:
parent
35486c148c
commit
a3d1451833
2 changed files with 116 additions and 5 deletions
111
.circleci/config.yml
Normal file
111
.circleci/config.yml
Normal file
|
@ -0,0 +1,111 @@
|
|||
version: 2.1
|
||||
|
||||
jobs:
|
||||
run-static-analysis:
|
||||
parameters:
|
||||
version:
|
||||
type: string
|
||||
docker:
|
||||
- image: circleci/golang:<< parameters.version >>
|
||||
environment:
|
||||
GO111MODULE: "on"
|
||||
# 1CPU / 2GB RAM
|
||||
resource_class: small
|
||||
steps:
|
||||
|
||||
- checkout
|
||||
|
||||
- restore_cache:
|
||||
keys:
|
||||
- go-<< parameters.version >>-{{ checksum "go.sum" }}-{{ checksum "Makefile" }}
|
||||
|
||||
- run: make bootstrap
|
||||
|
||||
- save_cache:
|
||||
key: go-<< parameters.version >>-{{ checksum "go.sum" }}-{{ checksum "Makefile" }}
|
||||
paths:
|
||||
- "/go/pkg/mod"
|
||||
- ".tmp"
|
||||
|
||||
- run:
|
||||
name: run static analysis
|
||||
command: make lint
|
||||
|
||||
run-tests:
|
||||
parameters:
|
||||
version:
|
||||
type: string
|
||||
docker:
|
||||
- image: circleci/golang:<< parameters.version >>
|
||||
environment:
|
||||
GO111MODULE: "on"
|
||||
# 1CPU / 2GB RAM
|
||||
resource_class: small
|
||||
steps:
|
||||
|
||||
- checkout
|
||||
|
||||
- restore_cache:
|
||||
keys:
|
||||
- go-<< parameters.version >>-{{ checksum "go.sum" }}-{{ checksum "Makefile" }}
|
||||
|
||||
- run: make bootstrap
|
||||
|
||||
- save_cache:
|
||||
key: go-<< parameters.version >>-{{ checksum "go.sum" }}-{{ checksum "Makefile" }}
|
||||
paths:
|
||||
- "/go/pkg/mod"
|
||||
- ".tmp"
|
||||
|
||||
- setup_remote_docker:
|
||||
version: 18.06.0-ce
|
||||
|
||||
- run:
|
||||
name: enable docker client
|
||||
command: |
|
||||
# all of this to enable "circleci local execute ..." cli commands for /var/run/docker.sock
|
||||
mkdir -p ${HOME}/.local/bin
|
||||
cat \<< EOF > ${HOME}/.local/bin/docker
|
||||
#!/bin/bash
|
||||
set -xue
|
||||
sudo -E ${HOME}/.local/bin/docker.bin \$@
|
||||
EOF
|
||||
sudo mv /usr/bin/docker ${HOME}/.local/bin/docker.bin
|
||||
chmod 755 ${HOME}/.local/bin/docker
|
||||
|
||||
- run:
|
||||
name: run unit tests
|
||||
command: make unit
|
||||
|
||||
# TODO: uncomment me when there are integration tests
|
||||
|
||||
# - run:
|
||||
# name: build hash key for tar cache
|
||||
# command: find integration/test-fixtures/image-* -type f -exec md5sum {} + | awk '{print $1}' | sort | md5sum | tee integration/test-fixtures/tar-cache.key
|
||||
|
||||
# - restore_cache:
|
||||
# keys:
|
||||
# - integration-test-tar-cache-{{ checksum "integration/test-fixtures/tar-cache.key" }}
|
||||
# - run:
|
||||
# name: run integration tests
|
||||
# command: |
|
||||
# docker version
|
||||
# make integration
|
||||
|
||||
# - save_cache:
|
||||
# key: integration-test-tar-cache-{{ checksum "integration/test-fixtures/tar-cache.key" }}
|
||||
# paths:
|
||||
# - "integration/test-fixtures/tar-cache"
|
||||
|
||||
workflows:
|
||||
"Static Analysis & All Tests":
|
||||
jobs:
|
||||
- run-static-analysis:
|
||||
name: "Static Analysis"
|
||||
version: "latest"
|
||||
- run-tests:
|
||||
name: "Unit & Integration Tests (go-1.13)"
|
||||
version: "1.13"
|
||||
- run-tests:
|
||||
name: "Unit & Integration Tests (go-latest)"
|
||||
version: "latest"
|
10
Makefile
10
Makefile
|
@ -1,9 +1,9 @@
|
|||
TEMPDIR = ./.tmp
|
||||
LINTCMD = $(TEMPDIR)/golangci-lint run --tests=false --config .golangci.yaml
|
||||
BOLD := $(shell tput bold)
|
||||
PURPLE := $(shell tput setaf 5)
|
||||
GREEN := $(shell tput setaf 2)
|
||||
RESET := $(shell tput sgr0)
|
||||
BOLD := $(shell tput -T linux bold)
|
||||
PURPLE := $(shell tput -T linux setaf 5)
|
||||
GREEN := $(shell tput -T linux setaf 2)
|
||||
RESET := $(shell tput -T linux sgr0)
|
||||
TITLE := $(BOLD)$(PURPLE)
|
||||
SUCCESS := $(BOLD)$(GREEN)
|
||||
|
||||
|
@ -40,7 +40,7 @@ lint-fix:
|
|||
|
||||
unit:
|
||||
@printf '$(TITLE)Running unit tests$(RESET)\n'
|
||||
go test --race ./...
|
||||
go test ./...
|
||||
|
||||
coverage:
|
||||
@printf '$(TITLE)Running unit tests + coverage$(RESET)\n'
|
||||
|
|
Loading…
Reference in a new issue