diff --git a/.github/workflows/PR-build.yml b/.github/workflows/PR-build.yml index 03a15b6c5f..8b8fa7e878 100644 --- a/.github/workflows/PR-build.yml +++ b/.github/workflows/PR-build.yml @@ -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 @@ -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 diff --git a/Makefile b/Makefile index b958a0e276..03e22d2f20 100644 --- a/Makefile +++ b/Makefile @@ -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