Skip to content

chore: persist go build cache between CI runs on Windows #17614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions .github/actions/setup-go/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,42 @@ inputs:
version:
description: "The Go version to use."
default: "1.24.2"
build-cache-path:
description: "The path to the build cache."
default: ""
required: false
cache:
description: "Whether to cache the build cache."
default: "true"
runs:
using: "composite"
steps:
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: ${{ inputs.version }}
cache: ${{ inputs.cache }}
# - name: Install gotestsum and mtimehash
# shell: bash
# run: |
# export BUILD_CACHE_PATH=${{ inputs.build-cache-path }}
# if [ -n "${BUILD_CACHE_PATH}" ]; then
# mkdir -p "${BUILD_CACHE_PATH}"
# export GOCACHE="${BUILD_CACHE_PATH}/build"
# export GOMODCACHE="${BUILD_CACHE_PATH}/mod"
# fi
# go install gotest.tools/gotestsum@latest
# go install github.com/slsyy/mtimehash/cmd/mtimehash@latest

- name: Install gotestsum
shell: bash
run: go install gotest.tools/gotestsum@latest

# It isn't necessary that we ever do this, but it helps
# separate the "setup" from the "run" times.
- name: go mod download
shell: bash
run: go mod download -x
# # It isn't necessary that we ever do this, but it helps
# # separate the "setup" from the "run" times.
# - name: go mod download
# shell: bash
# run: |
# export BUILD_CACHE_PATH=${{ inputs.build-cache-path }}
# if [ -n "${BUILD_CACHE_PATH}" ]; then
# mkdir -p "${BUILD_CACHE_PATH}"
# export GOCACHE="${BUILD_CACHE_PATH}/build"
# export GOMODCACHE="${BUILD_CACHE_PATH}/mod"
# fi
# go mod download -x
6 changes: 6 additions & 0 deletions .github/actions/setup-tf/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ runs:
using: "composite"
steps:
- name: Install Terraform
if: ${{ runner.os != 'Windows' }}
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_version: 1.11.4
terraform_wrapper: false
- name: Install Terraform on Windows
if: ${{ runner.os == 'Windows' }}
shell: bash
run: |
choco install terraform --version=1.11.4 -y
6 changes: 5 additions & 1 deletion .github/actions/test-cache/upload/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ inputs:
required: true
# This path is defined in testutil/cache.go
default: "~/.cache/coderv2-test"
override-condition:
description: "Override condition"
required: false
default: "false"
runs:
using: "composite"
steps:
- name: Upload test cache
if: ${{ github.ref == 'refs/heads/main' }}
if: ${{ github.ref == 'refs/heads/main' || inputs.override-condition == 'true' }}
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ${{ inputs.cache-path }}
Expand Down
97 changes: 15 additions & 82 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,45 +236,6 @@ jobs:
with:
fetch-depth: 1

- name: Setup Node
uses: ./.github/actions/setup-node

- name: Setup Go
uses: ./.github/actions/setup-go

- name: Setup sqlc
uses: ./.github/actions/setup-sqlc

- name: Setup Terraform
uses: ./.github/actions/setup-tf

- name: go install tools
uses: ./.github/actions/setup-go-tools

- name: Install Protoc
run: |
mkdir -p /tmp/proto
pushd /tmp/proto
curl -L -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v23.4/protoc-23.4-linux-x86_64.zip
unzip protoc.zip
cp -r ./bin/* /usr/local/bin
cp -r ./include /usr/local/bin/include
popd

- name: make gen
run: |
# Remove golden files to detect discrepancy in generated files.
make clean/golden-files
# Notifications require DB, we could start a DB instance here but
# let's just restore for now.
git checkout -- coderd/notifications/testdata/rendered-templates
# no `-j` flag as `make` fails with:
# coderd/rbac/object_gen.go:1:1: syntax error: package statement must be first
make --output-sync -B gen

- name: Check for unstaged files
run: ./scripts/check_unstaged.sh

fmt:
needs: changes
if: needs.changes.outputs.offlinedocs-only == 'false' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
Expand Down Expand Up @@ -313,10 +274,10 @@ jobs:
run: ./scripts/check_unstaged.sh

test-go:
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'depot-macos-latest' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-16-cores' || matrix.os }}
runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'depot-macos-latest' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'depot-windows-2022-4' || matrix.os }}
needs: changes
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
timeout-minutes: 20
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
Expand All @@ -335,54 +296,26 @@ jobs:
with:
fetch-depth: 1

# Sets up the ImDisk toolkit for Windows and creates a RAM disk on drive R:.
- name: Setup ImDisk
if: runner.os == 'Windows'
uses: ./.github/actions/setup-imdisk

- name: Setup Go
uses: ./.github/actions/setup-go

- name: Setup Terraform
uses: ./.github/actions/setup-tf

- name: Download Test Cache
id: download-cache
uses: ./.github/actions/test-cache/download
with:
key-prefix: test-go-${{ runner.os }}-${{ runner.arch }}
version: "1.23.8"
cache: false

- name: Test with Mock Database
id: test
- name: Wush
if: runner.os == 'Windows'
shell: bash
run: |
# if macOS, install google-chrome for scaletests. As another concern,
# should we really have this kind of external dependency requirement
# on standard CI?
if [ "${{ matrix.os }}" == "macos-latest" ]; then
brew install google-chrome
fi
curl -L -o wush.zip https://github.com/coder/wush/releases/download/v0.4.1/wush_0.4.1_windows_amd64.zip
unzip -o wush.zip

# By default Go will use the number of logical CPUs, which
# is a fine default.
PARALLEL_FLAG=""

# macOS will output "The default interactive shell is now zsh"
# intermittently in CI...
if [ "${{ matrix.os }}" == "macos-latest" ]; then
touch ~/.bash_profile && echo "export BASH_SILENCE_DEPRECATION_WARNING=1" >> ~/.bash_profile
fi
export TS_DEBUG_DISCO=true
gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" \
--packages="./..." -- $PARALLEL_FLAG -short -failfast

- name: Upload Test Cache
uses: ./.github/actions/test-cache/upload
with:
cache-key: ${{ steps.download-cache.outputs.cache-key }}

- name: Upload test stats to Datadog
timeout-minutes: 1
continue-on-error: true
uses: ./.github/actions/upload-datadog
if: success() || failure()
with:
api-key: ${{ secrets.DATADOG_API_KEY }}
chmod +x wush.exe
./wush.exe serve

# We don't run the full test-suite for Windows & MacOS, so we just run the CLI tests on every PR.
# We run the test suite in test-go-pg, including CLI.
Expand Down
2 changes: 2 additions & 0 deletions cli/gitssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ func TestGitSSH(t *testing.T) {
t.Run("Dial", func(t *testing.T) {
t.Parallel()

fmt.Println("Dial")

ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()

Expand Down
Loading