diff --git a/.github/workflows/multios-unit-tests.yml b/.github/workflows/multios-unit-tests.yml index 21e156c47e..dec2bb535b 100644 --- a/.github/workflows/multios-unit-tests.yml +++ b/.github/workflows/multios-unit-tests.yml @@ -18,6 +18,10 @@ on: go-version: required: true type: string + go-command: + required: false + type: string + default: 'go' runs-on: required: true type: string @@ -48,15 +52,20 @@ jobs: go-version: ${{ inputs.go-version }} check-latest: true cache: true + - name: Setup gotip if needed + if: inputs.go-version == 'gotip' + run: | + go install golang.org/dl/gotip@latest + gotip download - name: Install gotestsum - run: go install gotest.tools/gotestsum@latest + run: ${{ inputs.go-command }} install gotest.tools/gotestsum@latest - name: Mac OS Coreutils if: inputs.runs-on == 'macos-latest' run: brew install coreutils - name: "Runner ${{ matrix.runner-index }}: Test Core and Contrib (No Integration Tests)" shell: bash run: | - go list ./... | grep -v -e google.golang.org/api -e sarama -e confluent-kafka-go -e cmemprof | sort >packages.txt + ${{ inputs.go-command }} list ./... | grep -v -e google.golang.org/api -e sarama -e confluent-kafka-go -e cmemprof | sort >packages.txt gotestsum --junitfile ${REPORT} -- $(cat packages.txt) -v -coverprofile=coverage.txt -covermode=atomic -timeout 15m - name: Upload the results to Datadog CI App if: always() diff --git a/.github/workflows/smoke-tests.yml b/.github/workflows/smoke-tests.yml index f08cee958b..b4890a8a35 100644 --- a/.github/workflows/smoke-tests.yml +++ b/.github/workflows/smoke-tests.yml @@ -98,7 +98,7 @@ jobs: go-version: "stable" - name: Test contribs # It needs to run before "Test dd-trace-go" to avoid TestTelemetryEnabled tests to fail. - run: ./scripts/ci-test-contrib.sh smoke ${{ toJson(matrix.chunk) }} + run: ./scripts/ci-test-contrib.sh smoke ${{ toJson(matrix.chunk) }} "go" smoke-test-tracer: name: Test dd-trace-go diff --git a/.github/workflows/test-go-tip.yml b/.github/workflows/test-go-tip.yml new file mode 100644 index 0000000000..f8d822d213 --- /dev/null +++ b/.github/workflows/test-go-tip.yml @@ -0,0 +1,53 @@ +name: Go Tip + +on: + workflow_dispatch: # manually + schedule: + - cron: "0 0 * * 0" # run every Sunday at midnight UTC + pull_request: + branches: + - "hannahkm/go-tip-pipeline" # TODO: delete after testing + +jobs: + setup-gotip: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Set up a stable Go version + uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 + with: + go-version: 'latest' + + - name: Install gotip + run: | + go install golang.org/dl/gotip@latest + gotip download + + unit-integration-tests: + needs: setup-gotip + strategy: + matrix: + go-version: [ "gotip" ] + fail-fast: false + uses: ./.github/workflows/unit-integration-tests.yml + with: + go-version: ${{ matrix.go-version }} + go-command: "gotip" + ref: ${{ github.ref }} + secrets: inherit + + multios-unit-tests: + needs: setup-gotip + strategy: + matrix: + runs-on: [ macos-latest, windows-latest, ubuntu-latest ] + go-version: [ "gotip" ] + fail-fast: false + uses: ./.github/workflows/multios-unit-tests.yml + with: + go-version: ${{ matrix.go-version }} + go-command: "gotip" + runs-on: ${{ matrix.runs-on }} + ref: ${{ github.ref }} + secrets: inherit diff --git a/.github/workflows/unit-integration-tests.yml b/.github/workflows/unit-integration-tests.yml index a390d17c8b..d402c5ee38 100644 --- a/.github/workflows/unit-integration-tests.yml +++ b/.github/workflows/unit-integration-tests.yml @@ -6,6 +6,10 @@ on: go-version: required: true type: string + go-command: + required: false + type: string + default: 'go' ref: description: 'The branch to run the workflow on' required: true @@ -36,9 +40,14 @@ jobs: uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 with: go-version: ${{ inputs.go-version }} + - name: Setup gotip if needed + if: inputs.go-version == 'gotip' + run: | + go install golang.org/dl/gotip@latest + gotip download - name: Copyright run: | - go run ./scripts/checkcopyright.go + ${{ inputs.go-command }} run ./scripts/checkcopyright.go generate: runs-on: ubuntu-latest @@ -111,12 +120,18 @@ jobs: uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 with: ref: ${{ inputs.ref || github.ref }} + + - name: Setup gotip if needed + if: inputs.go-version == 'gotip' + run: | + go install golang.org/dl/gotip@latest + gotip download - name: Compute Matrix id: matrix run: |- echo -n "matrix=" >> "${GITHUB_OUTPUT}" - go run ./scripts/ci-contrib-matrix.go >> "${GITHUB_OUTPUT}" + ${{ inputs.go-command }} run ./scripts/ci-contrib-matrix.go >> "${GITHUB_OUTPUT}" test-contrib-matrix: needs: set-up @@ -276,6 +291,12 @@ jobs: with: ref: ${{ inputs.ref || github.ref }} + - name: Setup gotip if needed + if: inputs.go-version == 'gotip' + run: | + go install golang.org/dl/gotip@latest + gotip download + - name: Setup Go uses: ./.github/actions/setup-go with: @@ -284,7 +305,7 @@ jobs: - name: Test Contrib if: always() run: | - ./scripts/ci-test-contrib.sh default ${{ toJson(matrix.chunk) }} + ./scripts/ci-test-contrib.sh default ${{ toJson(matrix.chunk) }} ${{ inputs.go-command }} test-contrib: needs: diff --git a/scripts/ci-test-contrib.sh b/scripts/ci-test-contrib.sh index 5bbe502795..2fe22c7152 100755 --- a/scripts/ci-test-contrib.sh +++ b/scripts/ci-test-contrib.sh @@ -6,14 +6,28 @@ set +e # It is run by the GitHub Actions CI workflow defined in # .github/workflows/unit-integration-tests.yml. +# Arguments are as follows: +# $1 = 'smoke' indicates that we should run smoke tests. Use any other string value to indicate that +# we should not be running smoke tests. +# $2 = CONTRIBS gives a set of contrib directories that we should be testing. If you want to test all +# contribs, you should leave this parameter empty. +# $3 = go-command indicates what go command we should be running. This should have a default value of 'go', +# but can be set to 'gotip' for Go tip testing. + [[ -d ./contrib ]] || exit 0 -if [ $# -eq 2 ]; then +if [ $# -ne 3 ]; then + echo "$0 expects to receive three arguments: 'smoke' , 'CONTRIBS', 'go-command'" + exit 1 +fi + +# default values, which may be overwritten if our `CONTRIBS` argument is set +CONTRIBS=$(find ./contrib -mindepth 2 -type f -name go.mod -exec dirname {} \;) +INSTRUMENTATION_SUBMODULES=$(find ./instrumentation -mindepth 2 -type f -name go.mod -exec dirname {} \;) + +if [ -n "$2" ]; then CONTRIBS="$2" INSTRUMENTATION_SUBMODULES="" -else - CONTRIBS=$(find ./contrib -mindepth 2 -type f -name go.mod -exec dirname {} \;) - INSTRUMENTATION_SUBMODULES=$(find ./instrumentation -mindepth 2 -type f -name go.mod -exec dirname {} \;) fi report_error=0 @@ -22,7 +36,7 @@ for contrib in $CONTRIBS; do echo "Testing contrib module: $contrib" contrib_id=$(echo $contrib | sed 's/^\.\///g;s/[\/\.]/_/g') cd $contrib - [[ "$1" = "smoke" ]] && go get -u -t ./... + [[ "$1" = "smoke" ]] && $3 get -u -t ./... gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report-$contrib_id.xml -- ./... -v -race -coverprofile=coverage-$contrib_id.txt -covermode=atomic [[ $? -ne 0 ]] && report_error=1 cd - @@ -32,7 +46,7 @@ for mod in $INSTRUMENTATION_SUBMODULES; do echo "Testing instrumentation submodule: $mod" mod_id=$(echo $mod | sed 's/^\.\///g;s/[\/\.]/_/g') cd $mod - [[ "$1" = "smoke" ]] && go get -u -t ./... + [[ "$1" = "smoke" ]] && $3 get -u -t ./... gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report-$mod_id.xml -- ./... -v -race -coverprofile=coverage-$mod_id.txt -covermode=atomic [[ $? -ne 0 ]] && report_error=1 cd -