mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-14 10:13:10 +02:00
c39e625cdf
* Drop support for Go 1.18 * Add changes to changelog * Add PR number
162 lines
5.2 KiB
YAML
162 lines
5.2 KiB
YAML
name: ci
|
|
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.20"
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Install Go
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: ${{ env.DEFAULT_GO_VERSION }}
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v3
|
|
- name: Setup Environment
|
|
run: |
|
|
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
|
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
|
- name: Module cache
|
|
uses: actions/cache@v3
|
|
env:
|
|
cache-name: go-mod-cache
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }}
|
|
- name: Tools cache
|
|
uses: actions/cache@v3
|
|
env:
|
|
cache-name: go-tools-cache
|
|
with:
|
|
path: ~/.tools
|
|
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('./internal/tools/**') }}
|
|
- name: Run linters
|
|
run: make dependabot-check 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: Install Go
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: ${{ env.DEFAULT_GO_VERSION }}
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v3
|
|
- name: Setup Environment
|
|
run: |
|
|
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
|
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
|
- name: Module cache
|
|
uses: actions/cache@v3
|
|
env:
|
|
cache-name: go-mod-cache
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }}
|
|
- name: Run tests with race detector
|
|
run: make test-race
|
|
|
|
test-coverage:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Install Go
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: ${{ env.DEFAULT_GO_VERSION }}
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v3
|
|
- name: Setup Environment
|
|
run: |
|
|
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
|
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
|
- name: Module cache
|
|
uses: actions/cache@v3
|
|
env:
|
|
cache-name: go-mod-cache
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/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@v3.1.1
|
|
with:
|
|
file: ./coverage.txt
|
|
fail_ci_if_error: true
|
|
verbose: true
|
|
- name: Store coverage test output
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: opentelemetry-go-test-output
|
|
path: ${{ env.TEST_RESULTS }}
|
|
|
|
compatibility-test:
|
|
strategy:
|
|
matrix:
|
|
go-version: ["1.20", 1.19]
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
# GitHub Actions does not support arm* architectures on default
|
|
# runners. It is possible to acomplish 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: Install Go
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: ${{ matrix.go-version }}
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
- name: Setup Environment
|
|
run: |
|
|
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
|
|
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
|
|
shell: bash
|
|
- name: Module cache
|
|
uses: actions/cache@v3
|
|
env:
|
|
cache-name: go-mod-cache
|
|
with:
|
|
path: ~/go/pkg/mod
|
|
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/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 passed
|
|
run: |
|
|
echo ${{ needs.compatibility-test.result }}
|
|
test ${{ needs.compatibility-test.result }} == "success"
|