Skip to content

chore: run test-go-pg on macOS and Windows in regular CI #17853

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

Merged
merged 6 commits into from
May 22, 2025
Merged
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
57 changes: 57 additions & 0 deletions .github/actions/setup-go-paths/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: "Setup Go Paths"
description: Overrides Go paths like GOCACHE and GOMODCACHE to use temporary directories.
outputs:
gocache:
description: "Value of GOCACHE"
value: ${{ steps.paths.outputs.gocache }}
gomodcache:
description: "Value of GOMODCACHE"
value: ${{ steps.paths.outputs.gomodcache }}
gopath:
description: "Value of GOPATH"
value: ${{ steps.paths.outputs.gopath }}
gotmp:
description: "Value of GOTMPDIR"
value: ${{ steps.paths.outputs.gotmp }}
cached-dirs:
description: "Go directories that should be cached between CI runs"
value: ${{ steps.paths.outputs.cached-dirs }}
runs:
using: "composite"
steps:
- name: Override Go paths
id: paths
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
with:
script: |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind using the script here, but you can accomplish the same with bash by echoing to GITHUB_ENV and GITHUB_OUTPUT: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to use the script to handle setting multi-line env variables. With bash, you have to be very careful with whitespace and indentation. It's error-prone.

const path = require('path');

// RUNNER_TEMP should be backed by a RAM disk on Windows if
// coder/setup-ramdisk-action was used
const runnerTemp = process.env.RUNNER_TEMP;
const gocacheDir = path.join(runnerTemp, 'go-cache');
const gomodcacheDir = path.join(runnerTemp, 'go-mod-cache');
const gopathDir = path.join(runnerTemp, 'go-path');
const gotmpDir = path.join(runnerTemp, 'go-tmp');

core.exportVariable('GOCACHE', gocacheDir);
core.exportVariable('GOMODCACHE', gomodcacheDir);
core.exportVariable('GOPATH', gopathDir);
core.exportVariable('GOTMPDIR', gotmpDir);

core.setOutput('gocache', gocacheDir);
core.setOutput('gomodcache', gomodcacheDir);
core.setOutput('gopath', gopathDir);
core.setOutput('gotmp', gotmpDir);

const cachedDirs = `${gocacheDir}\n${gomodcacheDir}`;
core.setOutput('cached-dirs', cachedDirs);

- name: Create directories
shell: bash
run: |
set -e
mkdir -p "$GOCACHE"
mkdir -p "$GOMODCACHE"
mkdir -p "$GOPATH"
mkdir -p "$GOTMPDIR"
32 changes: 8 additions & 24 deletions .github/actions/setup-go/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,26 @@ inputs:
use-preinstalled-go:
description: "Whether to use preinstalled Go."
default: "false"
use-temp-cache-dirs:
description: "Whether to use temporary GOCACHE and GOMODCACHE directories."
default: "false"
use-cache:
description: "Whether to use the cache."
default: "true"
runs:
using: "composite"
steps:
- name: Override GOCACHE and GOMODCACHE
shell: bash
if: inputs.use-temp-cache-dirs == 'true'
run: |
# cd to another directory to ensure we're not inside a Go project.
# That'd trigger Go to download the toolchain for that project.
cd "$RUNNER_TEMP"
# RUNNER_TEMP should be backed by a RAM disk on Windows if
# coder/setup-ramdisk-action was used
export GOCACHE_DIR="$RUNNER_TEMP""\go-cache"
export GOMODCACHE_DIR="$RUNNER_TEMP""\go-mod-cache"
export GOPATH_DIR="$RUNNER_TEMP""\go-path"
export GOTMP_DIR="$RUNNER_TEMP""\go-tmp"
mkdir -p "$GOCACHE_DIR"
mkdir -p "$GOMODCACHE_DIR"
mkdir -p "$GOPATH_DIR"
mkdir -p "$GOTMP_DIR"
go env -w GOCACHE="$GOCACHE_DIR"
go env -w GOMODCACHE="$GOMODCACHE_DIR"
go env -w GOPATH="$GOPATH_DIR"
go env -w GOTMPDIR="$GOTMP_DIR"
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: ${{ inputs.use-preinstalled-go == 'false' && inputs.version || '' }}
cache: ${{ inputs.use-cache }}

- name: Install gotestsum
shell: bash
run: go install gotest.tools/gotestsum@0d9599e513d70e5792bb9334869f82f6e8b53d4d # main as of 2025-05-15

- name: Install mtimehash
shell: bash
run: go install github.com/slsyy/mtimehash/cmd/mtimehash@a6b5da4ed2c4a40e7b805534b004e9fde7b53ce0 # v1.0.0

# It isn't necessary that we ever do this, but it helps
# separate the "setup" from the "run" times.
- name: go mod download
Expand Down
27 changes: 0 additions & 27 deletions .github/actions/setup-imdisk/action.yaml

This file was deleted.

Loading
Loading