From 3b8eda2226115ff11cd7c3e9f1cb1ae873d546dd Mon Sep 17 00:00:00 2001 From: Elichai Turkel Date: Wed, 17 Feb 2021 18:59:42 +0200 Subject: [PATCH] go test race detector in github actions at cron job (#1534) Co-authored-by: Ori Newman --- .github/workflows/go-race.yml | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/go-race.yml diff --git a/.github/workflows/go-race.yml b/.github/workflows/go-race.yml new file mode 100644 index 000000000..6f029b32c --- /dev/null +++ b/.github/workflows/go-race.yml @@ -0,0 +1,48 @@ +name: Go-Race + +on: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +jobs: + race_test: + runs-on: ubuntu-20.04 + strategy: + matrix: + branch: [ master, latest ] + name: Race detection on ${{ matrix.branch }} + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: 1.15 + + - name: Set scheduled branch name + shell: bash + if: github.event_name == 'schedule' + run: | + if [ "${{ matrix.branch }}" == "master" ]; then + echo "run_on=master" >> $GITHUB_ENV + fi + if [ "${{ matrix.branch }}" == "latest" ]; then + branch=$(git branch -r | grep 'v\([0-9]\+\.\)\([0-9]\+\.\)\([0-9]\+\)-dev' | sort -Vr | head -1 | xargs) + echo "run_on=${branch}" >> $GITHUB_ENV + fi + + - name: Set manual branch name + shell: bash + if: github.event_name == 'workflow_dispatch' + run: echo "run_on=${{ github.ref }}" >> $GITHUB_ENV + + - name: Test with race detector + shell: bash + run: | + git checkout "${{ env.run_on }}" + git status + go test -race ./...