Skip to content

Commit

Permalink
Fix build and cleanup test to ensure clean state for release (#747)
Browse files Browse the repository at this point in the history
A few files were left around preventing goreleaser from working.
The following changes were made:
 - kubectl removed from deps since we didnt use it any more
 - kind binary was downloaded instead of using go get. This way
we dont end up with creating go.mod and go.sum files and we also
pin the version and prevent changes if they update/break
 - Updated a test to use and cleanup a tmp directory

Signed-off-by: John Schnake <[email protected]>
  • Loading branch information
johnSchnake authored Jun 14, 2019
1 parent 439de5f commit 6d02613
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Dockerfile-arm64
*.tar.gz
*.tar

# kubectl which is downloaded for testing in CI
kubectl
# kind is downloaded for testing in CI
kind

# coverage profile
coverage.txt
Expand Down
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ script:
- ./travis-ci.sh

before_install:
# Download and install Kind and kubectl
- GO111MODULE=on go get sigs.k8s.io/kind
- kind create cluster --config kind-config.yaml
- export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl

# Download and install Kind
- curl -L https://github.com/kubernetes-sigs/kind/releases/download/v0.3.0/kind-linux-amd64 --output kind && chmod +x kind
- ./kind create cluster --config kind-config.yaml
- export KUBECONFIG="$(./kind get kubeconfig-path --name="kind")"

before_deploy:
# Install gcloud cli here so it gets cached
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,6 @@ clean:
done

deploy_kind:
kind load docker-image $(REGISTRY)/$(TARGET):$(IMAGE_VERSION) || true
# FIXME: This assumes kind is in cwd; intended to work with our other CI scripts and
# is a bit wonky for general use.
./kind load docker-image $(REGISTRY)/$(TARGET):$(IMAGE_VERSION) || true
9 changes: 8 additions & 1 deletion pkg/plugin/aggregation/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"crypto/rand"
"crypto/tls"
"crypto/x509"
"io/ioutil"
"math/big"
"os"
"testing"
"time"

Expand Down Expand Up @@ -118,7 +120,12 @@ func TestRunAndMonitorPlugin(t *testing.T) {
}
for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
a := NewAggregator(".", tc.expectedResults)
tmpDir, err := ioutil.TempDir("", "sonobuoy-test")
if err != nil {
t.Fatalf("Failed to make temp directory: %v", err)
}
defer os.RemoveAll(tmpDir)
a := NewAggregator(tmpDir, tc.expectedResults)
ctx, cancel := context.WithCancel(context.Background())

fclient := fake.NewSimpleClientset()
Expand Down
15 changes: 14 additions & 1 deletion travis-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,22 @@ echo "|---- Creating new Sonobuoy run/waiting for results..."
./sonobuoy run --image-pull-policy=IfNotPresent -m Quick --wait

outFile=$(./sonobuoy retrieve)
results=$(./sonobuoy e2e $outFile)

set +e
results=$(./sonobuoy e2e $outFile)
e2eCode=$?
echo $results
set -e

if [ $e2eCode -ne 0 ]; then
echo "Error getting results from tarball"
sonobuoy status
sonobuoy logs
mkdir results; tar xzf $outFile -C results
find results
find results/plugins -exec cat {} \;
exit $e2eCode
fi

if echo $results | grep --quiet "failed tests: 0"; then
echo "|---- Success!"
Expand Down

0 comments on commit 6d02613

Please sign in to comment.