Skip to content

Commit

Permalink
add etcd test analyzer build and integrate into measure-test-flakines…
Browse files Browse the repository at this point in the history
…s workflow

Signed-off-by: Chao Chen <[email protected]>
  • Loading branch information
chaochn47 committed Mar 20, 2023
1 parent 30abf17 commit c9dad59
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/measure-test-flakiness.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Measure Test Flakiness

on:
schedule:
- cron: "0 0 * * 0"
- cron: "0 0 * * 0" # run every Sunday at midnight

permissions: read-all

Expand All @@ -12,6 +12,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- run: "./scripts/measure-test-flakiness.sh"
env:
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./scripts/measure-test-flakiness.sh
GOARCH=amd64 ./scripts/build_etcd_test_analyzer.sh
bin/etcd-test-analyzer run -token $GITHUB_TOKEN -max-age=168h -workflow Tests -branch main
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ build:
tools:
GO_BUILD_FLAGS="${GO_BUILD_FLAGS} -v" ./scripts/build_tools.sh

TEMP_TEST_ANALYZER_DIR=/tmp/etcd-test-analyzer
bin/etcd-test-analyzer: $(TEMP_TEST_ANALYZER_DIR)/*
GO_BUILD_FLAGS="${GO_BUILD_FLAGS} -v" ./scripts/build_etcd_test_analyzer.sh

$(TEMP_TEST_ANALYZER_DIR)/*:
pushd /tmp; git clone "https://github.com/endocrimes/etcd-test-analyzer.git"; popd

# Tests

GO_TEST_FLAGS?=
Expand Down
8 changes: 8 additions & 0 deletions scripts/build_etcd_test_analyzer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail

source ./scripts/test_lib.sh
source ./scripts/build_lib.sh

run_build etcd_test_analyzer_build
23 changes: 23 additions & 0 deletions scripts/build_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ source ./scripts/test_lib.sh

GIT_SHA=$(git rev-parse --short HEAD || echo "GitNotFound")
VERSION_SYMBOL="${ROOT_MODULE}/api/v3/version.GitSHA"
GO_LDFLAGS="${GO_LDFLAGS:-"-s -w"}"
GOOS="${GOOS:-"linux"}"
GOARCH="${GOARCH:-"amd64"}"
BINDIR="${BINDIR:-"bin"}"

# Set GO_LDFLAGS="-s" for building without symbols for debugging.
# shellcheck disable=SC2206
Expand Down Expand Up @@ -80,6 +84,25 @@ tools_build() {
done
}

etcd_test_analyzer_build() {
out="bin"
tool="etcd-test-analyzer"
dst="${PWD}/${out}/${tool}"
if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi
pushd /tmp || return 1
if [[ ! -d "$tool" ]]; then
git clone "https://github.com/endocrimes/$tool.git"
fi
cd "$tool" || return 1
echo "Building" "'${tool}'" "to" "'${dst}'"...
# shellcheck disable=SC2086
run env GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" CGO_ENABLED=0 go build ${GO_BUILD_FLAGS} \
-trimpath \
-installsuffix=cgo \
-o="${dst}" || return 2
popd || return 1
}

run_build() {
echo Running "$1"
if $1; then
Expand Down

0 comments on commit c9dad59

Please sign in to comment.