From 5966935cfb74672d1b43b13c826c73ac0f604c1b Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 10 Feb 2022 14:57:03 +1100 Subject: [PATCH] Fix and add caching to gotip CI actions --- .github/actions/go-common/action.yml | 45 +++++++++++++++++++++------- .github/workflows/go.yml | 1 + 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/.github/actions/go-common/action.yml b/.github/actions/go-common/action.yml index af07fe26..29780b04 100644 --- a/.github/actions/go-common/action.yml +++ b/.github/actions/go-common/action.yml @@ -8,16 +8,6 @@ runs: uses: actions/setup-go@v2 with: go-version: ${{ matrix.go-version }} - - name: Install gotip - if: matrix.go-version == 'tip' - run: | - git clone --depth=1 https://go.googlesource.com/go "$HOME/gotip" - cd "$HOME/gotip/src" - ./make.bash - echo "GOROOT=$HOME/gotip" >> "$GITHUB_ENV" - echo "$(go env GOPATH)/bin:$PATH" >> "$GITHUB_PATH" - echo "$HOME/gotip/bin:$PATH" >> "$GITHUB_PATH" - env - uses: actions/cache@v2 with: path: | @@ -33,4 +23,39 @@ runs: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ github.job }}- ${{ runner.os }}-go-${{ matrix.go-version }}- ${{ runner.os }}-go- + - run: | + echo GOTIP_REVISION="`git ls-remote https://github.com/golang/go refs/heads/master | cut -f1`" >> "$GITHUB_ENV" + echo GOTIP_PATH="$HOME/gotip" >> "$GITHUB_ENV" + if: matrix.go-version == 'tip' + shell: bash + - uses: actions/cache@v2 + if: matrix.go-version == 'tip' + with: + path: | + ${{ env.GOTIP_PATH }} + # The build varies by OS (and arch, but I haven't bothered to add that yet.) We always want + # the latest snapshot that works for us, the revision is only used to store differentiate + # builds. + key: gotip-ls-remote-${{ runner.os }}-${{ env.GOTIP_REVISION }} + restore-keys: | + gotip-ls-remote-${{ runner.os }}-${{ env.GOTIP_REVISION }} + gotip-ls-remote-${{ runner.os }}- + gotip-env-home-${{ runner.os }}- + gotip-${{ runner.os }}- + - name: Install gotip + if: matrix.go-version == 'tip' + run: | + git clone --depth=1 https://go.googlesource.com/go "$GOTIP_PATH" || true + cd "$GOTIP_PATH" + git pull + echo "GOROOT=$GOTIP_PATH" >> "$GITHUB_ENV" + echo "$(go env GOPATH)/bin:$PATH" >> "$GITHUB_PATH" + echo "$GOTIP_PATH/bin:$PATH" >> "$GITHUB_PATH" + echo "anacrolix.built:" $(cat anacrolix.built) + [[ -x bin/go && `git rev-parse HEAD` == `cat anacrolix.built` ]] && exit + cd src + ./make.bash || exit + git rev-parse HEAD > ../anacrolix.built + env + shell: bash diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 988ade17..6e5642e3 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -5,6 +5,7 @@ on: [push, pull_request] jobs: test: + timeout-minutes: 10 runs-on: ubuntu-latest strategy: matrix: