otelzap: Allow context injection via fields #10968
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: build_and_test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
env: | |
# path to where test results will be saved | |
TEST_RESULTS: /tmp/test-results | |
# Default version of Go to use by CI workflows. This should be the latest | |
# release of Go; developers likely use the latest release in development and | |
# we want to catch any bugs (e.g. lint errors, race detection) with this | |
# release before they are merged. The Go compatibility guarantees ensure | |
# backwards compatibility with the previous two minor releases and we | |
# explicitly test our code for these versions so keeping this at prior | |
# versions does not add value. | |
DEFAULT_GO_VERSION: "~1.22.3" | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 ## Needed for "Set tools/go.mod timestamp" step. | |
- name: Install Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.DEFAULT_GO_VERSION }} | |
check-latest: true | |
cache-dependency-path: "**/go.sum" | |
- name: Tools cache | |
uses: actions/cache@v4 | |
env: | |
cache-name: go-tools-cache | |
with: | |
path: .tools | |
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('./tools/**') }} | |
# The step below is needed to not rebuild all the build tools. | |
- name: Set tools/go.mod timestamp | |
run: | | |
filename="tools/go.mod" | |
unixtime=$(git log -1 --format="%at" -- "${filename}") | |
touchtime=$(date -d @$unixtime +'%Y%m%d%H%M.%S') | |
touch -t ${touchtime} "${filename}" | |
ls -la --time-style=full-iso "${filename}" | |
- name: Generate | |
run: make generate | |
- name: Run linters | |
run: make license-check lint vanity-import-check | |
- name: Build | |
run: make build | |
- name: Check clean repository | |
run: make check-clean-work-tree | |
test-race: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.DEFAULT_GO_VERSION }} | |
check-latest: true | |
cache-dependency-path: "**/go.sum" | |
- name: Run tests with race detector | |
run: make test-race | |
test-coverage: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.DEFAULT_GO_VERSION }} | |
check-latest: true | |
cache-dependency-path: "**/go.sum" | |
- name: Run coverage tests | |
run: | | |
make test-coverage | |
mkdir $TEST_RESULTS | |
cp coverage.out $TEST_RESULTS | |
cp coverage.txt $TEST_RESULTS | |
cp coverage.html $TEST_RESULTS | |
- name: Upload coverage report | |
uses: codecov/codecov-action@v4.4.1 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
with: | |
file: ./coverage.txt | |
fail_ci_if_error: true | |
verbose: true | |
- name: Store coverage test output | |
uses: actions/upload-artifact@v4 | |
with: | |
name: opentelemetry-go-contrib-test-output | |
path: ${{ env.TEST_RESULTS }} | |
compatibility-test: | |
strategy: | |
matrix: | |
go-version: ["~1.22.3", "~1.21.10"] | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
# GitHub Actions does not support arm* architectures on default | |
# runners. It is possible to accomplish this with a self-hosted runner | |
# if we want to add this in the future: | |
# https://docs.github.com/en/actions/hosting-your-own-runners/using-self-hosted-runners-in-a-workflow | |
arch: ["386", amd64] | |
exclude: | |
# Not a supported Go OS/architecture. | |
- os: macos-latest | |
arch: "386" | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.go-version }} | |
check-latest: true | |
cache-dependency-path: "**/go.sum" | |
- name: Run tests | |
env: | |
GOARCH: ${{ matrix.arch }} | |
run: make test-short | |
test-compatibility: | |
runs-on: ubuntu-latest | |
needs: [compatibility-test] | |
steps: | |
- name: Test if compatibility-test workflow passed | |
run: | | |
echo ${{ needs.compatibility-test.result }} | |
test ${{ needs.compatibility-test.result }} == "success" | |
integration: | |
strategy: | |
matrix: | |
target: [test-mongo-driver] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ env.DEFAULT_GO_VERSION }} | |
check-latest: true | |
cache-dependency-path: "**/go.sum" | |
- name: Run coverage tests ${{ matrix.target }} | |
env: | |
INTEGRATION: ${{ matrix.target }} | |
run: | | |
make ${{ matrix.target }} | |
mkdir -p $TEST_RESULTS | |
find . -name 'coverage.html' > "${TEST_RESULTS}/coverage.lst" | |
tar -n -cf - -T "${TEST_RESULTS}/coverage.lst" | tar -C "${TEST_RESULTS}" -xvf - | |
- name: Upload coverage report | |
uses: codecov/codecov-action@v4.4.1 | |
if: hashFiles('coverage.out') != '' | |
with: | |
file: ./coverage.out | |
fail_ci_if_error: true | |
verbose: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: Store coverage test output | |
uses: actions/upload-artifact@v4 | |
with: | |
name: opentelemetry-go-contrib-integration-test-output | |
path: ${{ env.TEST_RESULTS }} | |
test-integration: | |
runs-on: ubuntu-latest | |
needs: [integration] | |
steps: | |
- name: Test if integration workflow passed | |
run: | | |
echo ${{ needs.integration.result }} | |
test ${{ needs.integration.result }} == "success" |