ci: setup reusable workflow for integration tests #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
pull_request: | |
branches: ['**'] | |
merge_group: | |
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: | |
integration-tests: | |
strategy: | |
fail-fast: false | |
matrix: | |
runs-on: [macos, ubuntu, windows] | |
go-version: ['1.21', '1.22', '1.23.0-rc.1'] | |
build-mode: [DRIVER] | |
include: | |
# Alternate build modes (only on ubuntu, latest go; to save CI time) | |
- runs-on: ubuntu | |
go-version: '1.22' | |
build-mode: TOOLEXEC | |
- runs-on: ubuntu | |
go-version: '1.22' | |
build-mode: GOFLAGS | |
runs-on: ${{ matrix.runs-on }}-latest | |
name: Integration tests (go${{ matrix.go-version }}, ${{ matrix.runs-on }}, ${{ matrix.build-mode }}) | |
steps: | |
- 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: | |
go-version: ${{ matrix.go-version }} | |
cache-dependency-path: "**/*.sum" | |
- name: Setup python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '>=3.9 <3.13' | |
cache: pip | |
cache-dependency-path: _integration-tests/utils/agent/requirements.txt | |
- name: Install python dependencies | |
run: pip install -r _integration-tests/utils/agent/requirements.txt | |
- name: Build orchestrion binary | |
run: go build -cover -covermode=atomic -coverpkg="./..." -o="bin/orchestrion.exe" . | |
- 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") | |
bin/orchestrion.exe go -C=_integration-tests test -shuffle=on ./... | |
;; | |
"TOOLEXEC") | |
go -C=_integration-tests test -shuffle=on -toolexec="${{ github.workspace }}/bin/orchestrion.exe toolexec" ./... | |
;; | |
"GOFLAGS") | |
export GOFLAGS="'-toolexec=${{ github.workspace }}/bin/orchestrion.exe toolexec' ${GOFLAGS}" | |
go -C=_integration-tests test -shuffle=on ./... | |
;; | |
*) | |
echo "Unknown build mode: ${{ matrix.build-mode }}" | |
exit 1 | |
;; | |
esac | |
env: | |
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' && 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' && 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' && github.event_name != 'workflow_call' | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
flags: go${{ steps.simple-go-version.outputs.version }},${{ runner.os }},${{ runner.arch }},integration | |
files: ./coverage/integration.out | |
name: Integration Tests (go${{ matrix.go-version }}, ${{ matrix.runs-on }}, ${{ matrix.build-mode }}) | |
# This is just a join point intended to simplify branch protection settings | |
complete: | |
runs-on: ubuntu-latest | |
needs: | |
- integration-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 | |