Skip to content

Unit Tests

Unit Tests #678

Workflow file for this run

name: Unit Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '0 6 * * *'
permissions:
actions: write # Needed for skip-duplicate-jobs job
contents: read
jobs:
# Special job which automatically cancels old runs for the same branch, prevents runs for the
# same file set which has already passed, etc.
pre_job:
name: Skip Duplicate Jobs Pre Job
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@f75f66ce1886f00957d99748a42c724f4330bdcf # v5.3.1
with:
cancel_others: 'true'
github_token: ${{ github.token }}
build:
strategy:
# keep in sync with https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/.github/workflows/build-and-test.yml#L237
matrix:
go: ['1.21', '1.22']
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
needs: pre_job
if: ${{ needs.pre_job.outputs.should_skip != 'true' || github.ref_name == 'main' }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: true
cache-dependency-path: |
go.sum
- name: Run go mod vendor
run: |
go mod vendor
- name: Code tests
timeout-minutes: 15
run: |
make test
- name: Run Tests Many Times
timeout-minutes: 30
# Run test multiple times to check for flaky tests
if: github.ref_name == 'main'
run: |
make test-many-times COUNT=2