-
Notifications
You must be signed in to change notification settings - Fork 1.4k
112 lines (98 loc) · 4.38 KB
/
Copy pathflake-go.yaml
File metadata and controls
112 lines (98 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: flake-go
on:
pull_request:
workflow_dispatch:
inputs:
base_sha:
description: "Base commit to diff against. Defaults to merge-base against origin/main."
required: false
type: string
head_sha:
description: "Head commit to analyze. Defaults to the checked out HEAD."
required: false
type: string
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
flake_go:
name: Flake Check
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || 'ubuntu-latest' }}
# This timeout must be greater than the Go test timeout set in `make test`
# (-timeout 25m) so we receive a goroutine trace before the runner kills
# the job. Mirrors the test-go-pg job in ci.yaml.
timeout-minutes: 30
steps:
- name: Harden Runner
uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.event.inputs.head_sha || github.sha }}
fetch-depth: 0
persist-credentials: false
- name: Set up Go
uses: ./.github/actions/setup-mise
with:
install-args: "go"
- name: Install Go mise tools
run: ./.github/scripts/retry.sh -- mise install --locked go:github.com/coder/whichtests go:gotest.tools/gotestsum
- name: Select changed tests
id: selector
shell: bash
run: |
set -euo pipefail
whichtests \
--repo-root . \
--github-actions \
--coalesce \
--out-matrix "$RUNNER_TEMP/flake-matrix.json"
- name: Set up Terraform
if: ${{ fromJSON(steps.selector.outputs.matrix).include[0] != null }}
uses: ./.github/actions/setup-mise
with:
install-args: "terraform"
# Exports EMBEDDED_PG_CACHE_DIR, which startBuiltinPostgres uses as a
# shared binary archive cache in tests.
- name: Setup Embedded Postgres Cache Paths
id: embedded-pg-cache
if: ${{ fromJSON(steps.selector.outputs.matrix).include[0] != null }}
uses: ./.github/actions/setup-embedded-pg-cache-paths
- name: Download Embedded Postgres Cache
id: download-embedded-pg-cache
if: ${{ fromJSON(steps.selector.outputs.matrix).include[0] != null }}
uses: ./.github/actions/embedded-pg-cache/download
with:
key-prefix: embedded-pg-${{ runner.os }}-${{ runner.arch }}
cache-path: ${{ steps.embedded-pg-cache.outputs.cached-dirs }}
- name: Run targeted Go flake checks
id: flake_check
if: ${{ fromJSON(steps.selector.outputs.matrix).include[0] != null }}
uses: ./.github/actions/test-go-pg
with:
postgres-version: "13"
test-parallelism-packages: "4"
test-parallelism-tests: "16"
test-count: "35"
test-packages: ${{ fromJSON(steps.selector.outputs.matrix).include[0].package }}
run-regex: ${{ fromJSON(steps.selector.outputs.matrix).include[0].run_regex }}
test-shuffle: "on"
gotestsum-json-file: default
# The upload action only saves on main, so this is a no-op for PRs.
# A workflow_dispatch run on main seeds the cache that PR runs restore.
- name: Upload Embedded Postgres Cache
if: ${{ fromJSON(steps.selector.outputs.matrix).include[0] != null }}
uses: ./.github/actions/embedded-pg-cache/upload
with:
cache-key: ${{ steps.download-embedded-pg-cache.outputs.cache-key }}
cache-path: "${{ steps.embedded-pg-cache.outputs.embedded-pg-cache }}"
- name: Publish Go test failure report
if: failure() && steps.flake_check.outcome == 'failure' && github.actor != 'dependabot[bot]' && runner.os == 'Linux' && (github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork)
uses: ./.github/actions/go-test-failure-report
with:
artifact-name: go-test-failures-${{ github.job }}-${{ github.sha }}