Skip to content

Commit

Permalink
ci: setup reusable workflow for integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: Eliott Bouhana <[email protected]>
  • Loading branch information
eliottness committed Jul 11, 2024
1 parent 5130436 commit 19d8016
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ labels: enhancement
assignees: ''
---

<!--
<!--
Describe your desired feature below. Include any examples how you'd like to use the feature.
We also welcome you to let [Datadog support](http://docs.datadoghq.com/help/) know of any feature requests as they may be able to provide work-arounds for specific use-cases or increase the priority of a feature request.
-->
Original file line number Diff line number Diff line change
Expand Up @@ -6,72 +6,25 @@ on:
branches: ['main']
push:
branches: ['main']
workflow_dispatch:
inputs:
dd-trace-go-ref:
description: 'The ref to checkout dd-trace-go at'
required: false
type: string
default: main
workflow_call:
inputs:
dd-trace-go-ref:
type: string
required: true
description: 'The ref to checkout dd-trace-go at'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: 'stable'
cache-dependency-path: "**/*.sum"
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.52.2
skip-cache: true # actions/setup-go has already done this
- name: Verify license headers
run: go run tools/headercheck/header_check.go
- name: vet
run: go vet ./...
- name: Verify LICENSE-3rdparty.csv
run: ./tools/verify-licenses.sh
env:
TMPDIR: ${{ runner.temp }}

unit-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: ['1.21', '1.22', '1.23.0-rc.1']
name: Unit tests (go${{ matrix.go-version }})
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: "**/*.sum"
- name: Run unit tests
run: |-
mkdir -p coverage
go test -shuffle=on -cover -covermode=atomic -coverpkg=./... -coverprofile=${{ github.workspace }}/coverage/unit.out -race ./...
go -C _integration-tests test -shuffle=on -cover -covermode=atomic -coverpkg=./...,github.com/datadog/orchestrion/... -coverprofile=${{ github.workspace }}/coverage/integration.out -race ./...
- name: Determine simple go version
if: always() && github.event_name != 'merge_group'
id: simple-go-version
run: echo "::set-output name=version::${COMPLETE_VERSION:0:4}"
shell: bash
env:
COMPLETE_VERSION: ${{ matrix.go-version }}
- name: Upload coverage report
# We want this even if the tests failed
if: always() && github.event_name != 'merge_group'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: go${{ steps.simple-go-version.outputs.version }},${{ runner.os }},${{ runner.arch }},unit
files: ./coverage/unit.out,./coverage/integration.out
name: Unit Tests (go${{ matrix.go-version }})

integration-tests:
strategy:
fail-fast: false
Expand All @@ -90,8 +43,15 @@ jobs:
runs-on: ${{ matrix.runs-on }}-latest
name: Integration tests (go${{ matrix.go-version }}, ${{ matrix.runs-on }}, ${{ matrix.build-mode }})
steps:
- name: Checkout
- name: Checkout orchestrion
uses: actions/checkout@v4
- name: Checkout dd-trace-go
if: github.event_name == 'workflow_call'
uses: actions/checkout@v4
with:
path: dd-trace-go
repository: DataDog/dd-trace-go
ref: ${{ inputs.dd-trace-go-ref }}
- name: Setup go
uses: actions/setup-go@v5
with:
Expand All @@ -110,6 +70,12 @@ jobs:
- name: Run Integration Tests
shell: bash
run: |-
# run go mod edit if dd-trace-go is present
if [ -d dd-trace-go ]; then
bin/orchestrion.exe go -C=_integration-tests mod edit -replace=gopkg.in/DataDog/dd-trace-go.v1=../dd-trace-go
bin/orchestrion.exe go -C=_integration-tests mod tidy
fi
mkdir -p "${GOCOVERDIR}"
case "${{ matrix.build-mode }}" in
"DRIVER")
Expand All @@ -131,17 +97,17 @@ jobs:
GOCOVERDIR: ${{ github.workspace }}/coverage/raw
GOFLAGS: -tags=integration,buildtag # Globally set build tags (buildtag is used by the dd-span test)
- name: Consolidate coverage report
if: github.event_name != 'merge_group'
if: github.event_name != 'merge_group' && github.event_name != 'workflow_call'
run: go tool covdata textfmt -i ./coverage/raw -o ./coverage/integration.out
- name: Determine simple go version
if: github.event_name != 'merge_group'
if: github.event_name != 'merge_group' && github.event_name != 'workflow_call'
id: simple-go-version
run: echo "::set-output name=version::${COMPLETE_VERSION:0:4}"
shell: bash
env:
COMPLETE_VERSION: ${{ matrix.go-version }}
- name: Upload coverage report
if: github.event_name != 'merge_group'
if: github.event_name != 'merge_group' && github.event_name != 'workflow_call'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand All @@ -153,8 +119,6 @@ jobs:
complete:
runs-on: ubuntu-latest
needs:
- lint
- unit-tests
- integration-tests
if: '!cancelled()'
steps:
Expand Down
93 changes: 93 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Tests
on:
pull_request:
branches: ['**']
merge_group:
branches: ['main']
push:
branches: ['main']
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: 'stable'
cache-dependency-path: "**/*.sum"
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.52.2
skip-cache: true # actions/setup-go has already done this
- name: Verify license headers
run: go run tools/headercheck/header_check.go
- name: vet
run: go vet ./...
- name: Verify LICENSE-3rdparty.csv
run: ./tools/verify-licenses.sh
env:
TMPDIR: ${{ runner.temp }}

unit-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: ['1.21', '1.22', '1.23.0-rc.1']
name: Unit tests (go${{ matrix.go-version }})
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: "**/*.sum"
- name: Run unit tests
run: |-
mkdir -p coverage
go test -shuffle=on -cover -covermode=atomic -coverpkg=./... -coverprofile=${{ github.workspace }}/coverage/unit.out -race ./...
go -C _integration-tests test -shuffle=on -cover -covermode=atomic -coverpkg=./...,github.com/datadog/orchestrion/... -coverprofile=${{ github.workspace }}/coverage/integration.out -race ./...
- name: Determine simple go version
if: always() && github.event_name != 'merge_group'
id: simple-go-version
run: echo "::set-output name=version::${COMPLETE_VERSION:0:4}"
shell: bash
env:
COMPLETE_VERSION: ${{ matrix.go-version }}
- name: Upload coverage report
# We want this even if the tests failed
if: always() && github.event_name != 'merge_group'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: go${{ steps.simple-go-version.outputs.version }},${{ runner.os }},${{ runner.arch }},unit
files: ./coverage/unit.out,./coverage/integration.out
name: Unit Tests (go${{ matrix.go-version }})

# This is just a join point intended to simplify branch protection settings
complete:
runs-on: ubuntu-latest
needs:
- lint
- unit-tests
if: '!cancelled()'
steps:
- name: Done
if: needs.lint.result == 'success' && needs.unit-tests.result == 'success' && needs.integration-tests.result == 'success'
run: echo "OK"
- name: Done
if: needs.lint.result != 'success' || needs.unit-tests.result != 'success' || needs.integration-tests.result != 'success'
run: |-
echo "Failed!"
exit 1

0 comments on commit 19d8016

Please sign in to comment.