1name: ci 2on: 3 push: 4 branches: 5 - main 6 pull_request: 7env: 8 # Path to where test results will be saved. 9 TEST_RESULTS: /tmp/test-results 10 # Default minimum version of Go to support. 11 DEFAULT_GO_VERSION: 1.14 12jobs: 13 lint: 14 runs-on: ubuntu-latest 15 steps: 16 - name: Install Go 17 uses: actions/setup-go@v2.1.3 18 with: 19 go-version: ${{ env.DEFAULT_GO_VERSION }} 20 - name: Checkout Repo 21 uses: actions/checkout@v2 22 - name: Setup Environment 23 run: | 24 echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV 25 echo "$(go env GOPATH)/bin" >> $GITHUB_PATH 26 - name: Module cache 27 uses: actions/cache@v2.1.5 28 env: 29 cache-name: go-mod-cache 30 with: 31 path: ~/go/pkg/mod 32 key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }} 33 - name: Tools cache 34 uses: actions/cache@v2.1.5 35 env: 36 cache-name: go-tools-cache 37 with: 38 path: ~/.tools 39 key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('./internal/tools/**') }} 40 - name: Run linters 41 run: make dependabot-check license-check lint 42 - name: Build 43 run: make examples build 44 - name: Check clean repository 45 run: make check-clean-work-tree 46 47 test-race: 48 runs-on: ubuntu-latest 49 steps: 50 - name: Install Go 51 uses: actions/setup-go@v2.1.3 52 with: 53 go-version: ${{ env.DEFAULT_GO_VERSION }} 54 - name: Checkout Repo 55 uses: actions/checkout@v2 56 - name: Setup Environment 57 run: | 58 echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV 59 echo "$(go env GOPATH)/bin" >> $GITHUB_PATH 60 - name: Module cache 61 uses: actions/cache@v2.1.5 62 env: 63 cache-name: go-mod-cache 64 with: 65 path: ~/go/pkg/mod 66 key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }} 67 - name: Run tests with race detector 68 run: make test-race 69 70 test-coverage: 71 runs-on: ubuntu-latest 72 steps: 73 - name: Install Go 74 uses: actions/setup-go@v2.1.3 75 with: 76 go-version: ${{ env.DEFAULT_GO_VERSION }} 77 - name: Checkout Repo 78 uses: actions/checkout@v2 79 - name: Setup Environment 80 run: | 81 echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV 82 echo "$(go env GOPATH)/bin" >> $GITHUB_PATH 83 - name: Module cache 84 uses: actions/cache@v2.1.5 85 env: 86 cache-name: go-mod-cache 87 with: 88 path: ~/go/pkg/mod 89 key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }} 90 - name: Run coverage tests 91 run: | 92 make test-coverage 93 mkdir $TEST_RESULTS 94 cp coverage.out $TEST_RESULTS 95 cp coverage.txt $TEST_RESULTS 96 cp coverage.html $TEST_RESULTS 97 - name: Upload coverage report 98 uses: codecov/codecov-action@v1 99 with: 100 file: ./coverage.txt 101 fail_ci_if_error: true 102 verbose: true 103 - name: Store coverage test output 104 uses: actions/upload-artifact@v2 105 with: 106 name: opentelemetry-go-test-output 107 path: ${{ env.TEST_RESULTS }} 108 109 compatibility-test: 110 strategy: 111 matrix: 112 go-version: [1.15, 1.14] 113 os: [ubuntu-latest, macos-latest, windows-latest] 114 # GitHub Actions does not support arm* architectures on default 115 # runners. It is possible to acomplish this with a self-hosted runner 116 # if we want to add this in the future: 117 # https://docs.github.com/en/actions/hosting-your-own-runners/using-self-hosted-runners-in-a-workflow 118 arch: ["386", amd64] 119 exclude: 120 # Not a supported Go OS/architecture. 121 - os: macos-latest 122 arch: "386" 123 runs-on: ${{ matrix.os }} 124 steps: 125 - name: Install Go 126 uses: actions/setup-go@v2.1.3 127 with: 128 go-version: ${{ matrix.go-version }} 129 - name: Checkout code 130 uses: actions/checkout@v2 131 - name: Setup Environment 132 run: | 133 echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV 134 echo "$(go env GOPATH)/bin" >> $GITHUB_PATH 135 shell: bash 136 - name: Module cache 137 uses: actions/cache@v2.1.5 138 env: 139 cache-name: go-mod-cache 140 with: 141 path: ~/go/pkg/mod 142 key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }} 143 - name: Run tests 144 env: 145 GOARCH: ${{ matrix.arch }} 146 run: make test-short 147