Skip to content

chore: update CI runners #17326

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

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
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
67 changes: 50 additions & 17 deletions .github/actions/setup-imdisk/action.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,60 @@
name: "Setup ImDisk"
name: "Setup OSFMount"
if: runner.os == 'Windows'
description: |
Sets up the ImDisk toolkit for Windows and creates a RAM disk on drive R:.
Installs OSFmount for Windows and creates a RAM disk on drive R:.
runs:
using: "composite"
steps:
- name: Download ImDisk
- name: Install OSFMount
if: runner.os == 'Windows'
shell: bash
shell: powershell -NoProfile -Command "& '{0}'"
run: |
mkdir imdisk
cd imdisk
curl -L -o files.cab https://github.com/coder/imdisk-artifacts/raw/92a17839ebc0ee3e69be019f66b3e9b5d2de4482/files.cab
curl -L -o install.bat https://github.com/coder/imdisk-artifacts/raw/92a17839ebc0ee3e69be019f66b3e9b5d2de4482/install.bat
cd ..

- name: Install ImDisk
shell: cmd
run: |
cd imdisk
install.bat /silent
$ErrorActionPreference = "Stop"

$path = "$($env:TEMP)\osfmount.exe"
& curl.exe `
--progress-bar `
--show-error `
--fail `
--location `
--output $path `
$env:OSFMOUNT_URL
if ($LASTEXITCODE -ne 0) { throw "Failed to download osfmount.exe" }
if ((Get-FileHash $path -Algorithm SHA256).Hash -ne $env:OSFMOUNT_SHA256) {
throw "Failed to verify osfmount.exe"
}

# We can't just use -Wait here or it will block when the installer
# launches the GUI afterwards, and there's no way to turn that off.
$proc = Start-Process -FilePath $path -ArgumentList "/SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART" -PassThru
$proc.WaitForExit()
if ($proc.ExitCode -ne 0) { throw "Failed to install osfmount.exe" }

# Close the GUI and delete the installer.
Get-Process -Name "OSFMount" -ErrorAction SilentlyContinue | Stop-Process -Force
Remove-Item $path
env:
OSFMOUNT_URL: https://storage.googleapis.com/coder-osfmount-binaries/osfmount-v3.1.1003.exe
OSFMOUNT_SHA256: 9fe0738b7c2d29a7414e67f53aea359f3801d1c37b44f1b4fed5d02cb7536369

- name: Create RAM Disk
shell: cmd
shell: powershell -NoProfile -Command "& '{0}'"
run: |
imdisk -a -s 4096M -m R: -p "/fs:ntfs /q /y"
$ErrorActionPreference = "Stop"

# List disks before creating the RAM disk.
$before = Get-Disk

# Create the uninitialized disk.
& "C:\Program Files\OSFmount\OSFMount.com" -a -t vm -s 48G -o physical
if ($LASTEXITCODE -ne 0) { throw "Failed to create RAM disk" }

# List disks after creating the RAM disk and find the new one.
$after = Get-Disk
$newDisk = ($after | Where-Object { $before.Number -notcontains $_.Number })
if (!$newDisk) { throw "Failed to find new RAM disk" }

# Initialize the disk, create a simple volume and format it NTFS.
Initialize-Disk -Number $newDisk.Number -PartitionStyle GPT -Confirm:$false
$partition = New-Partition -DiskNumber $newDisk.Number -UseMaximumSize -DriveLetter R
Format-Volume -Partition $partition -FileSystem NTFS -NewFileSystemLabel "RAMDisk" -Confirm:$false
107 changes: 55 additions & 52 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ 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-32' || matrix.os }}
needs: changes
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
timeout-minutes: 20
Expand All @@ -340,6 +340,55 @@ jobs:
with:
fetch-depth: 1

- name: Setup ImDisk
if: runner.os == 'Windows' && github.repository_owner == 'coder'
uses: ./.github/actions/setup-imdisk

- name: Setup Windows paths
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = "Stop"

# Copy RUNNER_TEMP to the ramdisk. We can't delete the contents
# because it contains some important files for the workflow.
$runnerTemp = "R:\tmp"
New-Item -ItemType Directory -Path $runnerTemp -Force
Copy-Item -Path "$($env:RUNNER_TEMP)\*" -Destination $runnerTemp -Force -Recurse
# Move to .old so we don't need to waste I/O deleting it.
Move-Item -Path $env:RUNNER_TEMP -Destination "$($env:RUNNER_TEMP).old" -Force
# Create a symbolic link from the old path to the new path. You can't
# just update RUNNER_TEMP because it gets overridden by the runner.
New-Item -ItemType SymbolicLink -Path $env:RUNNER_TEMP -Target $runnerTemp -Force
Write-Output "RUNNER_TEMP: $env:RUNNER_TEMP -> $((Get-Item $env:RUNNER_TEMP).Target)"
ls $env:RUNNER_TEMP

# Move the toolcache directory to .old since the current contents
# don't matter.
$toolCache = "R:\toolcache"
Move-Item -Path $env:RUNNER_TOOL_CACHE -Destination "$($env:RUNNER_TOOL_CACHE).old" -Force
New-Item -ItemType Directory -Path $toolCache -Force
# RUNNER_TOOL_CACHE also gets overridden by the runner, so symlink.
New-Item -ItemType SymbolicLink -Path $env:RUNNER_TOOL_CACHE -Target $toolCache -Force
Write-Output "RUNNER_TOOL_CACHE: $env:RUNNER_TOOL_CACHE -> $((Get-Item $env:RUNNER_TOOL_CACHE).Target)"
ls $env:RUNNER_TOOL_CACHE

# Update the GOPATH to the ramdisk. We don't care about the contents
# since we haven't installed anything yet.
"GOPATH=R:\go" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"R:\go\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Verify windows paths
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
Write-Output "RUNNER_TEMP: $env:RUNNER_TEMP"
Write-Output "RUNNER_TEMP symlink target: $((Get-Item $env:RUNNER_TEMP).Target)"
Write-Output "RUNNER_TOOL_CACHE: $env:RUNNER_TOOL_CACHE"
Write-Output "RUNNER_TOOL_CACHE symlink target: $((Get-Item $env:RUNNER_TOOL_CACHE).Target)"
Write-Output "GOPATH: $env:GOPATH"

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

Expand Down Expand Up @@ -370,59 +419,13 @@ jobs:
gotestsum --junitfile="gotests.xml" --jsonfile="gotests.json" \
--packages="./..." -- $PARALLEL_FLAG -short -failfast

- 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 }}

# 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.
test-cli:
runs-on: ${{ 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 }}
needs: changes
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
strategy:
matrix:
os:
- macos-latest
- windows-2022
steps:
- name: Harden Runner
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
with:
egress-policy: audit

- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 1

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

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

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

- name: Test CLI
env:
TS_DEBUG_DISCO: "true"
LC_CTYPE: "en_US.UTF-8"
LC_ALL: "en_US.UTF-8"
shell: bash
shell: pwsh
run: |
# By default Go will use the number of logical CPUs, which
# is a fine default.
PARALLEL_FLAG=""

make test-cli
ls R:\go
ls R:\go\pkg
ls R:\go\pkg\mod

- name: Upload test stats to Datadog
timeout-minutes: 1
Expand Down
Loading