From 0b35e6f66e2748a12db8dee34d749c22b63bee51 Mon Sep 17 00:00:00 2001 From: Sam Xie Date: Thu, 12 Dec 2024 15:14:36 -0800 Subject: [PATCH] Fix CI cache issue (#395) --- .github/workflows/ci.yaml | 186 ++++++++++++++++---------------------- 1 file changed, 79 insertions(+), 107 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b877822f..0c9e6055 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,96 +13,74 @@ jobs: lint: runs-on: ubuntu-latest steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ env.DEFAULT_GO_VERSION }} - - name: Checkout Repo - uses: actions/checkout@v4 - - name: Setup Environment - run: | - echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV - echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - - name: Module cache - uses: actions/cache@v4 - 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@v4 - env: - cache-name: go-tools-cache - with: - path: ~/.tools - key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('./internal/tools/**') }} - - name: Run linters - run: make license-check lint - - name: Build - run: make build - - name: Check clean repository - run: make check-clean-work-tree + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.DEFAULT_GO_VERSION }} + 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('./internal/tools/**') }} + - name: Run linters + run: make license-check lint + - 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@v5 - with: - go-version: ${{ env.DEFAULT_GO_VERSION }} - - name: Checkout Repo - uses: actions/checkout@v4 - - name: Setup Environment - run: | - echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV - echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - - name: Module cache - uses: actions/cache@v4 - 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 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.DEFAULT_GO_VERSION }} + 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('./internal/tools/**') }} + - name: Run tests with race detector + run: make test-race test-coverage: runs-on: ubuntu-latest steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ env.DEFAULT_GO_VERSION }} - - name: Checkout Repo - uses: actions/checkout@v4 - - name: Setup Environment - run: | - echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV - echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - - name: Module cache - uses: actions/cache@v4 - 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@v4.6.0 - with: - file: ./coverage.txt - fail_ci_if_error: true - token: ${{ secrets.CODECOV_TOKEN }} - - name: Store coverage test output - uses: actions/upload-artifact@v4 - with: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.DEFAULT_GO_VERSION }} + 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('./internal/tools/**') }} + - 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.6.0 + with: + file: ./coverage.txt + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} + - name: Store coverage test output + uses: actions/upload-artifact@v4 + with: name: opentelemetry-go-test-output path: ${{ env.TEST_RESULTS }} @@ -117,30 +95,24 @@ jobs: # 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" + # Not a supported Go OS/architecture. + - os: macos-latest + arch: "386" runs-on: ${{ matrix.os }} steps: - - name: Install Go - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Checkout code - uses: actions/checkout@v4 - - 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@v4 - 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 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} + 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('./internal/tools/**') }} + - name: Run tests + env: + GOARCH: ${{ matrix.arch }} + run: make test-short