Add github build & test actions
Signed-off-by: Casey Callendrello <cdc@redhat.com>
This commit is contained in:
parent
336ba52542
commit
25704f9372
69
.github/workflows/test.yaml
vendored
Normal file
69
.github/workflows/test.yaml
vendored
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
---
|
||||||
|
name: test
|
||||||
|
|
||||||
|
on: ["push", "pull_request"]
|
||||||
|
|
||||||
|
env:
|
||||||
|
GO_VERSION: "1.14"
|
||||||
|
LINUX_ARCHES: "amd64 386 arm arm64 s390x mips64le ppc64le"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build all linux architectures
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: setup go
|
||||||
|
uses: actions/setup-go@v1
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Build on all supported architectures
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
for arch in ${LINUX_ARCHES}; do
|
||||||
|
echo "Building for arch $arch"
|
||||||
|
GOARCH=$arch ./build_linux.sh
|
||||||
|
rm bin/*
|
||||||
|
done
|
||||||
|
|
||||||
|
test-linux:
|
||||||
|
name: Run tests on Linux amd64
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: setup go
|
||||||
|
uses: actions/setup-go@v1
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install test binaries
|
||||||
|
env:
|
||||||
|
GO111MODULE: off
|
||||||
|
run: |
|
||||||
|
go get github.com/containernetworking/cni/cnitool
|
||||||
|
go get github.com/mattn/goveralls
|
||||||
|
go get github.com/modocache/gover
|
||||||
|
|
||||||
|
- name: test
|
||||||
|
run: PATH=$PATH:$(go env GOPATH)/bin COVERALLS=1 ./test_linux.sh
|
||||||
|
|
||||||
|
- name: Send coverage to coveralls
|
||||||
|
env:
|
||||||
|
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
PATH=$PATH:$(go env GOPATH)/bin
|
||||||
|
gover
|
||||||
|
goveralls -coverprofile=gover.coverprofile -service=github
|
||||||
|
|
||||||
|
test-win:
|
||||||
|
name: Build and run tests on Windows
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- name: setup go
|
||||||
|
uses: actions/setup-go@v1
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: test
|
||||||
|
run: bash ./test_windows.sh
|
@ -1,21 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
cd $(dirname "$0")
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
if [ "$(uname)" == "Darwin" ]; then
|
if [ "$(uname)" == "Darwin" ]; then
|
||||||
export GOOS="${GOOS:-linux}"
|
export GOOS="${GOOS:-linux}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ORG_PATH="github.com/containernetworking"
|
|
||||||
export REPO_PATH="${ORG_PATH}/plugins"
|
|
||||||
|
|
||||||
if [ ! -h gopath/src/${REPO_PATH} ]; then
|
|
||||||
mkdir -p gopath/src/${ORG_PATH}
|
|
||||||
ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255
|
|
||||||
fi
|
|
||||||
|
|
||||||
export GOPATH=${PWD}/gopath
|
|
||||||
export GO="${GO:-go}"
|
|
||||||
export GOFLAGS="${GOFLAGS} -mod=vendor"
|
export GOFLAGS="${GOFLAGS} -mod=vendor"
|
||||||
|
|
||||||
mkdir -p "${PWD}/bin"
|
mkdir -p "${PWD}/bin"
|
||||||
@ -25,9 +15,9 @@ PLUGINS="plugins/meta/* plugins/main/* plugins/ipam/*"
|
|||||||
for d in $PLUGINS; do
|
for d in $PLUGINS; do
|
||||||
if [ -d "$d" ]; then
|
if [ -d "$d" ]; then
|
||||||
plugin="$(basename "$d")"
|
plugin="$(basename "$d")"
|
||||||
if [ $plugin != "windows" ]; then
|
if [ "${plugin}" != "windows" ]; then
|
||||||
echo " $plugin"
|
echo " $plugin"
|
||||||
$GO build -o "${PWD}/bin/$plugin" "$@" "$REPO_PATH"/$d
|
${GO:-go} build -o "${PWD}/bin/$plugin" "$@" ./"$d"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -1,25 +1,15 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
cd $(dirname "$0")
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
ORG_PATH="github.com/containernetworking"
|
|
||||||
export REPO_PATH="${ORG_PATH}/plugins"
|
|
||||||
|
|
||||||
export GOPATH=$(mktemp -d)
|
|
||||||
mkdir -p ${GOPATH}/src/${ORG_PATH}
|
|
||||||
trap "{ rm -rf $GOPATH; }" EXIT
|
|
||||||
ln -s ${PWD} ${GOPATH}/src/${REPO_PATH} || exit 255
|
|
||||||
|
|
||||||
export GO="${GO:-go}"
|
export GO="${GO:-go}"
|
||||||
export GOOS=windows
|
export GOOS=windows
|
||||||
export GOFLAGS="${GOFLAGS} -mod=vendor"
|
export GOFLAGS="${GOFLAGS} -mod=vendor"
|
||||||
echo $GOFLAGS
|
echo "$GOFLAGS"
|
||||||
|
|
||||||
PLUGINS=$(cat plugins/windows_only.txt)
|
PLUGINS=$(cat plugins/windows_only.txt | dos2unix )
|
||||||
for d in $PLUGINS; do
|
for d in $PLUGINS; do
|
||||||
if [ -d "$d" ]; then
|
plugin="$(basename "$d").exe"
|
||||||
plugin="$(basename "$d").exe"
|
echo "building $plugin"
|
||||||
echo " $plugin"
|
$GO build -o "${PWD}/bin/$plugin" "$@" ./"${d}"
|
||||||
$GO build -o "${PWD}/bin/$plugin" "$@" "$REPO_PATH"/$d
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
# switch into the repo root directory
|
# switch into the repo root directory
|
||||||
cd "$(dirname $0)"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
# Build all plugins before testing
|
# Build all plugins before testing
|
||||||
source ./build_linux.sh
|
source ./build_linux.sh
|
||||||
@ -15,7 +15,7 @@ source ./build_linux.sh
|
|||||||
echo "Running tests"
|
echo "Running tests"
|
||||||
|
|
||||||
function testrun {
|
function testrun {
|
||||||
sudo -E bash -c "umask 0; cd ${GOPATH}/src; PATH=${GOROOT}/bin:$(pwd)/bin:${PATH} go test $@"
|
sudo -E bash -c "umask 0; PATH=${GOPATH}/bin:$(pwd)/bin:${PATH} go test $@"
|
||||||
}
|
}
|
||||||
|
|
||||||
COVERALLS=${COVERALLS:-""}
|
COVERALLS=${COVERALLS:-""}
|
||||||
@ -26,36 +26,30 @@ else
|
|||||||
echo "without coverage profile generation..."
|
echo "without coverage profile generation..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PKG=${PKG:-$(cd ${GOPATH}/src/${REPO_PATH}; go list ./... | xargs echo)}
|
PKG=${PKG:-$(go list ./... | xargs echo)}
|
||||||
|
|
||||||
# coverage profile only works per-package
|
|
||||||
i=0
|
i=0
|
||||||
for t in ${PKG}; do
|
for t in ${PKG}; do
|
||||||
if [ -n "${COVERALLS}" ]; then
|
if [ -n "${COVERALLS}" ]; then
|
||||||
COVERFLAGS="-covermode set -coverprofile ${i}.coverprofile"
|
COVERFLAGS="-covermode set -coverprofile ${i}.coverprofile"
|
||||||
fi
|
fi
|
||||||
|
echo "${t}"
|
||||||
testrun "${COVERFLAGS:-""} ${t}"
|
testrun "${COVERFLAGS:-""} ${t}"
|
||||||
i=$((i+1))
|
i=$((i+1))
|
||||||
done
|
done
|
||||||
|
|
||||||
# Submit coverage information
|
|
||||||
if [ -n "${COVERALLS}" ]; then
|
|
||||||
gover
|
|
||||||
goveralls -service=travis-ci -coverprofile=gover.coverprofile
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Checking gofmt..."
|
echo "Checking gofmt..."
|
||||||
fmtRes=$(go fmt $PKG)
|
fmtRes=$(go fmt $PKG)
|
||||||
if [ -n "${fmtRes}" ]; then
|
if [ -n "${fmtRes}" ]; then
|
||||||
echo -e "go fmt checking failed:\n${fmtRes}"
|
echo -e "go fmt checking failed:\n${fmtRes}"
|
||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Checking govet..."
|
echo "Checking govet..."
|
||||||
vetRes=$(go vet $PKG)
|
vetRes=$(go vet $PKG)
|
||||||
if [ -n "${vetRes}" ]; then
|
if [ -n "${vetRes}" ]; then
|
||||||
echo -e "govet checking failed:\n${vetRes}"
|
echo -e "govet checking failed:\n${vetRes}"
|
||||||
exit 255
|
exit 255
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run the pkg/ns tests as non root user
|
# Run the pkg/ns tests as non root user
|
||||||
|
@ -3,12 +3,18 @@
|
|||||||
# Run CNI plugin tests.
|
# Run CNI plugin tests.
|
||||||
#
|
#
|
||||||
set -e
|
set -e
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
source ./build_windows.sh
|
source ./build_windows.sh
|
||||||
|
|
||||||
echo "Running tests"
|
echo "Running tests"
|
||||||
|
|
||||||
PLUGINS=$(cat plugins/windows_only.txt | tr '\n' ' ')
|
PKGS="./pkg/hns/..."
|
||||||
GINKGO_FLAGS="-p -r --randomizeAllSpecs --randomizeSuites --failOnPending --progress pkg/hns $PLUGINS"
|
|
||||||
|
|
||||||
bash -c "cd ${GOPATH}/src/${REPO_PATH}; PATH='${GOROOT}/bin:$(pwd)/bin:${PATH}' ginkgo ${GINKGO_FLAGS}"
|
PLUGINS=$(cat plugins/windows_only.txt | dos2unix )
|
||||||
|
for d in $PLUGINS; do
|
||||||
|
PKGS="$PKGS ./$d/..."
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "testing packages $PKGS"
|
||||||
|
go test -v $PKGS -ginkgo.randomizeAllSpecs -ginkgo.failOnPending -ginkgo.progress
|
||||||
|
Loading…
x
Reference in New Issue
Block a user