Feature - Include e2e tests for docker

Included e2e tests for docker.
Included .Dockerignore to ignore files.
Included Docker build in the Makefile.
This commit is contained in:
naveen 2021-02-24 14:46:41 -05:00 committed by Naveen
parent cab29a2747
commit a7174d8ad7
3 changed files with 41 additions and 1 deletions

12
.Dockerignore Normal file
View File

@ -0,0 +1,12 @@
# Ignore everything
**
# Allow files and directories
!go.mod
!go.sum
!main.go
!/pkg/**
!/roundtripper/**
!/cmd/**
!/checks/**
!/checker/**

View File

@ -5,7 +5,8 @@ on:
types: [ok-to-test-command]
name: Integration tests
env:
IMAGE_NAME: scorecard
jobs:
integration-trusted:
runs-on: ubuntu-latest
@ -92,6 +93,27 @@ jobs:
ginkgo --focus="E2E TEST:executable|E2E TEST:blob" ./...
fi
- name: Build docker image
run: docker build . --file Dockerfile --tag $IMAGE_NAME
- name: Test docker image
env:
GITHUB_AUTH_TOKEN: ${{ secrets.GH_AUTH_TOKEN }}
run: |
if [[ ! -v GITHUB_AUTH_TOKEN ]]; then
echo "GITHUB_AUTH_TOKEN is not set, skip test"
exit 1
elif [[ -z "$GITHUB_AUTH_TOKEN" ]]; then
echo "GITHUB_AUTH_TOKEN is set to the empty string, skip test"
exit 1
else
go get github.com/onsi/ginkgo/ginkgo@v1.14.2
go mod download
mkdir -p bin
docker run -e GITHUB_AUTH_TOKEN=$GITHUB_AUTH_TOKEN $IMAGE_NAME --show-details --repo=https://github.com/ossf/scorecard --metadata=openssf --format json > ./bin/results.json
ginkgo -p -v --focus="E2E TEST:executable" ./...
fi
- name: find comment
if: ${{ always() }}
uses: peter-evans/find-comment@v1

View File

@ -1,6 +1,7 @@
SHELL := /bin/bash
GOBIN ?= $(GOPATH)/bin
GINKGO ?= $(GOBIN)/ginkgo
IMAGE_NAME = scorecard
.PHONY: help
help: ## Display this help
@ -77,3 +78,8 @@ verify-go-mod: ## Verify the go modules
go mod tidy && \
go mod verify
./hack/tree-status
.PHONY: dockerbuild
dockerbuild: ## Runs docker build
$(call ndef, GITHUB_AUTH_TOKEN)
docker build . --file Dockerfile --tag $(IMAGE_NAME)