diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000000..64fda6154f2 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,56 @@ +name: Build +on: [push, pull_request] +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + target: + - linux-amd64 + - linux-386 + - darwin-amd64 + - windows-amd64 + - linux-arm + - linux-arm64 + - linux-ppc64le + - linux-s390x + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: "^1.16" + - env: + TARGET: ${{ matrix.target }} + run: | + echo "${TARGET}" + case "${TARGET}" in + linux-amd64) + ARCH=amd64 PASSES='build' ./test.sh + ;; + linux-386) + ARCH=386 PASSES='build' ./test.sh + ;; + darwin-amd64) + ARCH=amd64 GOOS=darwin GO_BUILD_FLAGS='-v -mod=readonly' ./build.sh + ;; + windows-amd64) + ARCH=amd64 GOOS=windows GO_BUILD_FLAGS='-v -mod=readonly' ./build.sh + ;; + linux-arm) + ARCH=arm GO_BUILD_FLAGS='-v -mod=readonly' ./build.sh + ;; + linux-arm64) + ARCH=arm64 GO_BUILD_FLAGS='-v -mod=readonly' ./build.sh + ;; + linux-ppc64le) + ARCH=ppc64le GO_BUILD_FLAGS='-v -mod=readonly' ./build.sh + ;; + linux-s390x) + ARCH=s390x GO_BUILD_FLAGS='-v -mod=readonly' ./build.sh + ;; + *) + echo "Failed to find target" + exit 1 + ;; + esac diff --git a/.github/workflows/static-analysis.yaml b/.github/workflows/static-analysis.yaml new file mode 100644 index 00000000000..8ebc820013f --- /dev/null +++ b/.github/workflows/static-analysis.yaml @@ -0,0 +1,29 @@ +name: Static Analysis +on: [push, pull_request] +jobs: + run: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + target: + - linux-amd64-fmt + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: "^1.16" + - run: date + - env: + TARGET: ${{ matrix.target }} + run: | + echo "${TARGET}" + case "${TARGET}" in + linux-amd64-fmt) + GOARCH=amd64 PASSES='fmt bom dep' ./test.sh + ;; + *) + echo "Failed to find target" + exit 1 + ;; + esac diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index cf63ec25a82..eec7ae95680 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -7,12 +7,10 @@ jobs: fail-fast: false matrix: target: - - linux-amd64-fmt - linux-amd64-integration-1-cpu - linux-amd64-integration-2-cpu - linux-amd64-integration-4-cpu - linux-amd64-unit-4-cpu-race - - all-build - linux-386-unit-1-cpu steps: - uses: actions/checkout@v2 @@ -23,11 +21,9 @@ jobs: - env: TARGET: ${{ matrix.target }} run: | - echo "${TARGET}" + mkdir "${TARGET}" + export JUNIT_REPORT_DIR=$(realpath ${TARGET}) case "${TARGET}" in - linux-amd64-fmt) - GOARCH=amd64 PASSES='fmt bom dep' ./test.sh - ;; linux-amd64-integration-1-cpu) GOARCH=amd64 CPU=1 PASSES='integration' RACE='false' ./test.sh ;; @@ -40,16 +36,6 @@ jobs: linux-amd64-unit-4-cpu-race) GOARCH=amd64 PASSES='unit' RACE='true' CPU='4' ./test.sh -p=2 ;; - all-build) - GOARCH=amd64 PASSES='build' ./test.sh - GOARCH=386 PASSES='build' ./test.sh - GO_BUILD_FLAGS='-v -mod=readonly' GOOS=darwin GOARCH=amd64 ./build.sh - GO_BUILD_FLAGS='-v -mod=readonly' GOOS=windows GOARCH=amd64 ./build.sh - GO_BUILD_FLAGS='-v -mod=readonly' GOARCH=arm ./build.sh - GO_BUILD_FLAGS='-v -mod=readonly' GOARCH=arm64 ./build.sh - GO_BUILD_FLAGS='-v -mod=readonly' GOARCH=ppc64le ./build.sh - GO_BUILD_FLAGS='-v -mod=readonly' GOARCH=s390x ./build.sh - ;; linux-386-unit-1-cpu) GOARCH=386 PASSES='unit' RACE='false' CPU='1' ./test -p=4 ;; @@ -58,3 +44,7 @@ jobs: exit 1 ;; esac + - uses: actions/upload-artifact@v2 + if: always() + with: + path: ./**/junit_*.xml diff --git a/scripts/test_lib.sh b/scripts/test_lib.sh index 6a27e0591b4..7c2d0403f4c 100644 --- a/scripts/test_lib.sh +++ b/scripts/test_lib.sh @@ -231,13 +231,8 @@ function produce_junit_xmlreport { local junit_xml_filename junit_xml_filename="${junit_filename_prefix}.xml" - if ! command -v gotestsum >/dev/null 2>&1; then - log_callout "gotestsum not found; installing now" - pushd "${ETCD_ROOT_DIR}/tools/mod" >/dev/null || return - GO111MODULE=on go install gotest.tools/gotestsum - popd >/dev/null || return - fi - gotestsum --junitfile "${junit_xml_filename}" --raw-command cat "${junit_filename_prefix}"*.stdout + # Ensure that gotestsum is run without cross-compiling + run_go_tool gotest.tools/gotestsum --junitfile "${junit_xml_filename}" --raw-command cat "${junit_filename_prefix}"*.stdout || exit 1 if [ "${VERBOSE}" != "1" ]; then rm "${junit_filename_prefix}"*.stdout fi @@ -360,7 +355,7 @@ function tool_exists { # Ensure gobin is available, as it runs majority of the tools if ! command -v "gobin" >/dev/null; then - run env GO111MODULE=off go get github.com/myitcv/gobin || exit 1 + GOARCH="" run env GO111MODULE=off go get github.com/myitcv/gobin || exit 1 fi # tool_get_bin [tool] - returns absolute path to a tool binary (or returns error) @@ -386,11 +381,11 @@ function tool_pkg_dir { # tool_get_bin [tool] function run_go_tool { local cmdbin - if ! cmdbin=$(tool_get_bin "${1}"); then + if ! cmdbin=$(GOARCH="" tool_get_bin "${1}"); then return 2 fi shift 1 - run "${cmdbin}" "$@" || return 2 + GOARCH="" run "${cmdbin}" "$@" || return 2 } # assert_no_git_modifications fails if there are any uncommited changes.