Skip to content

Commit a3020fc

Browse files
committed
Merge branch 'main' into jon/glue
2 parents 6d3c103 + d2c1562 commit a3020fc

File tree

79 files changed

+1721
-310
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1721
-310
lines changed

.github/workflows/ci.yaml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ jobs:
223223
./actionlint -color -shellcheck= -ignore "set-output"
224224
shell: bash
225225

226+
- name: Check for unstaged files
227+
run: |
228+
rm -f ./actionlint ./typos
229+
./scripts/check_unstaged.sh
230+
shell: bash
231+
226232
gen:
227233
timeout-minutes: 8
228234
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
@@ -460,7 +466,7 @@ jobs:
460466
api-key: ${{ secrets.DATADOG_API_KEY }}
461467

462468
test-go-race:
463-
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
469+
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
464470
needs: changes
465471
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
466472
timeout-minutes: 25
@@ -481,9 +487,13 @@ jobs:
481487
- name: Setup Terraform
482488
uses: ./.github/actions/setup-tf
483489

490+
# We run race tests with reduced parallelism because they use more CPU and we were finding
491+
# instances where tests appear to hang for multiple seconds, resulting in flaky tests when
492+
# short timeouts are used.
493+
# c.f. discussion on https://github.com/coder/coder/pull/15106
484494
- name: Run Tests
485495
run: |
486-
gotestsum --junitfile="gotests.xml" -- -race ./...
496+
gotestsum --junitfile="gotests.xml" -- -race -parallel 4 -p 4 ./...
487497
488498
- name: Upload test stats to Datadog
489499
timeout-minutes: 1
@@ -549,19 +559,19 @@ jobs:
549559
working-directory: site
550560

551561
test-e2e:
552-
runs-on: ${{ github.repository_owner == 'coder' && (matrix.variant.enterprise && 'depot-ubuntu-22.04' || 'depot-ubuntu-22.04-4') || 'ubuntu-latest' }}
553562
# test-e2e fails on 2-core 8GB runners, so we use the 4-core 16GB runner
563+
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || 'ubuntu-latest' }}
554564
needs: changes
555565
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
556566
timeout-minutes: 20
557567
strategy:
558568
fail-fast: false
559569
matrix:
560570
variant:
561-
- enterprise: false
571+
- premium: false
562572
name: test-e2e
563-
- enterprise: true
564-
name: test-e2e-enterprise
573+
- premium: true
574+
name: test-e2e-premium
565575
name: ${{ matrix.variant.name }}
566576
steps:
567577
- name: Harden Runner
@@ -590,38 +600,35 @@ jobs:
590600
- run: pnpm playwright:install
591601
working-directory: site
592602

593-
# Run tests that don't require an enterprise license without an enterprise license
603+
# Run tests that don't require a premium license without a premium license
594604
- run: pnpm playwright:test --forbid-only --workers 1
595-
if: ${{ !matrix.variant.enterprise }}
605+
if: ${{ !matrix.variant.premium }}
596606
env:
597607
DEBUG: pw:api
598608
working-directory: site
599609

600-
# Run all of the tests with an enterprise license
610+
# Run all of the tests with a premium license
601611
- run: pnpm playwright:test --forbid-only --workers 1
602-
if: ${{ matrix.variant.enterprise }}
612+
if: ${{ matrix.variant.premium }}
603613
env:
604614
DEBUG: pw:api
605-
CODER_E2E_ENTERPRISE_LICENSE: ${{ secrets.CODER_E2E_ENTERPRISE_LICENSE }}
606-
CODER_E2E_REQUIRE_ENTERPRISE_TESTS: "1"
615+
CODER_E2E_LICENSE: ${{ secrets.CODER_E2E_LICENSE }}
616+
CODER_E2E_REQUIRE_PREMIUM_TESTS: "1"
607617
working-directory: site
608-
# Temporarily allow these to fail so that I can gather data about which
609-
# tests are failing.
610-
continue-on-error: true
611618

612619
- name: Upload Playwright Failed Tests
613620
if: always() && github.actor != 'dependabot[bot]' && runner.os == 'Linux' && !github.event.pull_request.head.repo.fork
614621
uses: actions/upload-artifact@604373da6381bf24206979c74d06a550515601b9 # v4.4.1
615622
with:
616-
name: failed-test-videos${{ matrix.variant.enterprise && '-enterprise' || '-agpl' }}
623+
name: failed-test-videos${{ matrix.variant.premium && '-premium' || '' }}
617624
path: ./site/test-results/**/*.webm
618625
retention-days: 7
619626

620627
- name: Upload pprof dumps
621628
if: always() && github.actor != 'dependabot[bot]' && runner.os == 'Linux' && !github.event.pull_request.head.repo.fork
622629
uses: actions/upload-artifact@604373da6381bf24206979c74d06a550515601b9 # v4.4.1
623630
with:
624-
name: debug-pprof-dumps${{ matrix.variant.enterprise && '-enterprise' || '-agpl' }}
631+
name: debug-pprof-dumps${{ matrix.variant.premium && '-premium' || '' }}
625632
path: ./site/test-results/**/debug-pprof-*.txt
626633
retention-days: 7
627634

.github/workflows/pr-deploy.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,6 @@ jobs:
4444
with:
4545
egress-policy: audit
4646

47-
- name: Harden Runner
48-
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
49-
with:
50-
egress-policy: audit
51-
52-
- name: Harden Runner
53-
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
54-
with:
55-
egress-policy: audit
56-
5747
- name: Checkout
5848
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
5949

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ test-postgres-docker:
817817

818818
# Make sure to keep this in sync with test-go-race from .github/workflows/ci.yaml.
819819
test-race:
820-
$(GIT_FLAGS) gotestsum --junitfile="gotests.xml" -- -race -count=1 ./...
820+
$(GIT_FLAGS) gotestsum --junitfile="gotests.xml" -- -race -count=1 -parallel 4 -p 4 ./...
821821
.PHONY: test-race
822822

823823
test-tailnet-integration:

cli/create.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ type prepWorkspaceBuildArgs struct {
370370
LastBuildParameters []codersdk.WorkspaceBuildParameter
371371
SourceWorkspaceParameters []codersdk.WorkspaceBuildParameter
372372

373-
PromptBuildOptions bool
374-
BuildOptions []codersdk.WorkspaceBuildParameter
373+
PromptEphemeralParameters bool
374+
EphemeralParameters []codersdk.WorkspaceBuildParameter
375375

376376
PromptRichParameters bool
377377
RichParameters []codersdk.WorkspaceBuildParameter
@@ -405,8 +405,8 @@ func prepWorkspaceBuild(inv *serpent.Invocation, client *codersdk.Client, args p
405405
resolver := new(ParameterResolver).
406406
WithLastBuildParameters(args.LastBuildParameters).
407407
WithSourceWorkspaceParameters(args.SourceWorkspaceParameters).
408-
WithPromptBuildOptions(args.PromptBuildOptions).
409-
WithBuildOptions(args.BuildOptions).
408+
WithPromptEphemeralParameters(args.PromptEphemeralParameters).
409+
WithEphemeralParameters(args.EphemeralParameters).
410410
WithPromptRichParameters(args.PromptRichParameters).
411411
WithRichParameters(args.RichParameters).
412412
WithRichParametersFile(parameterFile).

cli/parameter.go

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ import (
1515

1616
// workspaceParameterFlags are used by commands processing rich parameters and/or build options.
1717
type workspaceParameterFlags struct {
18-
promptBuildOptions bool
19-
buildOptions []string
18+
promptEphemeralParameters bool
19+
20+
ephemeralParameters []string
2021

2122
richParameterFile string
2223
richParameters []string
@@ -26,23 +27,39 @@ type workspaceParameterFlags struct {
2627
}
2728

2829
func (wpf *workspaceParameterFlags) allOptions() []serpent.Option {
29-
options := append(wpf.cliBuildOptions(), wpf.cliParameters()...)
30+
options := append(wpf.cliEphemeralParameters(), wpf.cliParameters()...)
3031
options = append(options, wpf.cliParameterDefaults()...)
3132
return append(options, wpf.alwaysPrompt())
3233
}
3334

34-
func (wpf *workspaceParameterFlags) cliBuildOptions() []serpent.Option {
35+
func (wpf *workspaceParameterFlags) cliEphemeralParameters() []serpent.Option {
3536
return serpent.OptionSet{
37+
// Deprecated - replaced with ephemeral-parameter
3638
{
3739
Flag: "build-option",
3840
Env: "CODER_BUILD_OPTION",
3941
Description: `Build option value in the format "name=value".`,
40-
Value: serpent.StringArrayOf(&wpf.buildOptions),
42+
UseInstead: []serpent.Option{{Flag: "ephemeral-parameter"}},
43+
Value: serpent.StringArrayOf(&wpf.ephemeralParameters),
4144
},
45+
// Deprecated - replaced with prompt-ephemeral-parameters
4246
{
4347
Flag: "build-options",
4448
Description: "Prompt for one-time build options defined with ephemeral parameters.",
45-
Value: serpent.BoolOf(&wpf.promptBuildOptions),
49+
UseInstead: []serpent.Option{{Flag: "prompt-ephemeral-parameters"}},
50+
Value: serpent.BoolOf(&wpf.promptEphemeralParameters),
51+
},
52+
{
53+
Flag: "ephemeral-parameter",
54+
Env: "CODER_EPHEMERAL_PARAMETER",
55+
Description: `Set the value of ephemeral parameters defined in the template. The format is "name=value".`,
56+
Value: serpent.StringArrayOf(&wpf.ephemeralParameters),
57+
},
58+
{
59+
Flag: "prompt-ephemeral-parameters",
60+
Env: "CODER_PROMPT_EPHEMERAL_PARAMETERS",
61+
Description: "Prompt to set values of ephemeral parameters defined in the template. If a value has been set via --ephemeral-parameter, it will not be prompted for.",
62+
Value: serpent.BoolOf(&wpf.promptEphemeralParameters),
4663
},
4764
}
4865
}

cli/parameterresolver.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ type ParameterResolver struct {
2929
richParameters []codersdk.WorkspaceBuildParameter
3030
richParametersDefaults map[string]string
3131
richParametersFile map[string]string
32-
buildOptions []codersdk.WorkspaceBuildParameter
32+
ephemeralParameters []codersdk.WorkspaceBuildParameter
3333

34-
promptRichParameters bool
35-
promptBuildOptions bool
34+
promptRichParameters bool
35+
promptEphemeralParameters bool
3636
}
3737

3838
func (pr *ParameterResolver) WithLastBuildParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver {
@@ -50,8 +50,8 @@ func (pr *ParameterResolver) WithRichParameters(params []codersdk.WorkspaceBuild
5050
return pr
5151
}
5252

53-
func (pr *ParameterResolver) WithBuildOptions(params []codersdk.WorkspaceBuildParameter) *ParameterResolver {
54-
pr.buildOptions = params
53+
func (pr *ParameterResolver) WithEphemeralParameters(params []codersdk.WorkspaceBuildParameter) *ParameterResolver {
54+
pr.ephemeralParameters = params
5555
return pr
5656
}
5757

@@ -75,8 +75,8 @@ func (pr *ParameterResolver) WithPromptRichParameters(promptRichParameters bool)
7575
return pr
7676
}
7777

78-
func (pr *ParameterResolver) WithPromptBuildOptions(promptBuildOptions bool) *ParameterResolver {
79-
pr.promptBuildOptions = promptBuildOptions
78+
func (pr *ParameterResolver) WithPromptEphemeralParameters(promptEphemeralParameters bool) *ParameterResolver {
79+
pr.promptEphemeralParameters = promptEphemeralParameters
8080
return pr
8181
}
8282

@@ -128,16 +128,16 @@ nextRichParameter:
128128
resolved = append(resolved, richParameter)
129129
}
130130

131-
nextBuildOption:
132-
for _, buildOption := range pr.buildOptions {
131+
nextEphemeralParameter:
132+
for _, ephemeralParameter := range pr.ephemeralParameters {
133133
for i, r := range resolved {
134-
if r.Name == buildOption.Name {
135-
resolved[i].Value = buildOption.Value
136-
continue nextBuildOption
134+
if r.Name == ephemeralParameter.Name {
135+
resolved[i].Value = ephemeralParameter.Value
136+
continue nextEphemeralParameter
137137
}
138138
}
139139

140-
resolved = append(resolved, buildOption)
140+
resolved = append(resolved, ephemeralParameter)
141141
}
142142
return resolved
143143
}
@@ -209,8 +209,8 @@ func (pr *ParameterResolver) verifyConstraints(resolved []codersdk.WorkspaceBuil
209209
return templateVersionParametersNotFound(r.Name, templateVersionParameters)
210210
}
211211

212-
if tvp.Ephemeral && !pr.promptBuildOptions && findWorkspaceBuildParameter(tvp.Name, pr.buildOptions) == nil {
213-
return xerrors.Errorf("ephemeral parameter %q can be used only with --build-options or --build-option flag", r.Name)
212+
if tvp.Ephemeral && !pr.promptEphemeralParameters && findWorkspaceBuildParameter(tvp.Name, pr.ephemeralParameters) == nil {
213+
return xerrors.Errorf("ephemeral parameter %q can be used only with --prompt-ephemeral-parameters or --ephemeral-parameter flag", r.Name)
214214
}
215215

216216
if !tvp.Mutable && action != WorkspaceCreate {
@@ -231,7 +231,7 @@ func (pr *ParameterResolver) resolveWithInput(resolved []codersdk.WorkspaceBuild
231231
firstTimeUse := pr.isFirstTimeUse(tvp.Name)
232232
promptParameterOption := pr.isLastBuildParameterInvalidOption(tvp)
233233

234-
if (tvp.Ephemeral && pr.promptBuildOptions) ||
234+
if (tvp.Ephemeral && pr.promptEphemeralParameters) ||
235235
(action == WorkspaceCreate && tvp.Required) ||
236236
(action == WorkspaceCreate && !tvp.Ephemeral) ||
237237
(action == WorkspaceUpdate && promptParameterOption) ||

0 commit comments

Comments
 (0)