Skip to content

[WIP] create a ci pipeline for gotip testing #3637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/workflows/multios-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/test-go-tip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Go Tip

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Code Vulnerability

No explicit permissions set for at the workflow level (...read more)

Check the permissions granted to jobs

Datadog’s GitHub organization defines default permissions for the GITHUB_TOKEN to be restricted (contents:read, metadata:read and packages:read).

Your repository may require different setup, but please consider defining permissions for each job following the least privilege principle to restrict the impact of a possible compromission.

You can find the list of all possible permissions in Workflow syntax for GitHub Actions - GitHub Docs. Please note they can be defined at the job or the workflow level.

View in Datadog  Leave us feedback  Documentation


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
27 changes: 24 additions & 3 deletions .github/workflows/unit-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand 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:
Expand All @@ -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:
Expand Down
26 changes: 20 additions & 6 deletions scripts/ci-test-contrib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 -
Expand All @@ -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 -
Expand Down
Loading