Skip to content

Commit

Permalink
Add data race test to PR build (#1450)
Browse files Browse the repository at this point in the history
  • Loading branch information
jefchien authored Dec 3, 2024
1 parent f3b333f commit 748073f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
22 changes: 21 additions & 1 deletion .github/workflows/PR-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-2019, windows-latest, macos-12]
os: [ubuntu-latest, windows-2019, windows-latest, macos-12]
include:
- os: ubuntu-latest
family: linux
Expand Down Expand Up @@ -138,3 +138,23 @@ jobs:
- name: Build
if: steps.cached_binaries.outputs.cache-hit != 'true' && needs.changes.outputs.build == 'true'
run: make amazon-cloudwatch-agent-${{ matrix.family }}

test-data-race:
needs: [lint, changes]
name: Test data race
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
if: needs.changes.outputs.build == 'true'
uses: actions/setup-go@v4
with:
go-version: ~1.22.2
cache: false

- name: Check out code
if: needs.changes.outputs.build == 'true'
uses: actions/checkout@v3

- name: Test data race
if: needs.changes.outputs.build == 'true'
run: make test-data-race
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,23 @@ lint: install-golangci-lint simple-lint
test:
CGO_ENABLED=0 go test -timeout 15m -coverprofile coverage.txt -failfast ./...

# List of existing packages with data races
# TODO: Fix each
PKG_WITH_DATA_RACE := extension/entitystore
PKG_WITH_DATA_RACE += extension/server
PKG_WITH_DATA_RACE += internal/publisher
PKG_WITH_DATA_RACE += internal/retryer
PKG_WITH_DATA_RACE += internal/tls
PKG_WITH_DATA_RACE += plugins/inputs/logfile
PKG_WITH_DATA_RACE += plugins/inputs/logfile/tail
PKG_WITH_DATA_RACE += plugins/outputs/cloudwatch
PKG_WITH_DATA_RACE += plugins/outputs/cloudwatchlogs
PKG_WITH_DATA_RACE += plugins/processors/awsapplicationsignals
PKG_WITH_DATA_RACE += plugins/processors/ec2tagger
PKG_WITH_DATA_RACE_PATTERN := $(shell echo '$(PKG_WITH_DATA_RACE)' | tr ' ' '|')
test-data-race:
CGO_ENABLED=1 go test -timeout 15m -race -parallel 4 $(shell go list ./... | grep -v -E '$(PKG_WITH_DATA_RACE_PATTERN)')

clean::
rm -rf release/ build/
rm -f CWAGENT_VERSION
Expand Down

0 comments on commit 748073f

Please sign in to comment.