Files
coder/scripts/release/main_internal_test.go
T
Nick Vigilante 28cf704f27 chore: update references to the relocated install docs paths (#30380)
The Install docs moved into the five-phase spine in #29304, but several
references outside `docs/` still point at the pre-move URLs.
`docs/redirects.json` is empty, so those URLs 404 rather than
forwarding.
The release note generators are the user-visible ones: every generated
release note links `coder.com/docs/install/releases` and
`coder.com/docs/install/upgrade`.

| Reference | Was | Now |
|---|---|---|
| Release schedule links in release notes | `/docs/install/releases` |
`/docs/reference/releases` |
| Upgrade link in release notes | `/docs/install/upgrade` |
`/docs/install/operate/upgrade` |
| README sizing link |
`/docs/admin/infrastructure/validated-architectures` |
`/docs/install/plan/sizing` |
| Provisioner tag table comments | `docs/admin/provisioners/index.md` |
`docs/install/operate/provisioners/index.md` |
| FAQ provenance comment | `docs/admin/licensing/index.md` |
`docs/install/prepare/licensing.md` |
| ESR 2.24-2.29 upgrade table | `/docs/admin/provisioners` |
`/docs/install/operate/provisioners` |
| Helm provisioner README, `NOTES.txt`, and `values.yaml` |
`/docs/admin/provisioners` | `/docs/install/operate/provisioners` |
| Helm Coder chart README | `/docs/install/kubernetes` |
`/docs/install/server/kubernetes` |
| `workspace-tags` example README |
`/docs/admin/provisioners#external-provisioners` |
`/docs/install/operate/provisioners#types-of-provisioners` |
| `kubernetes-envbox` example README |
`/docs/admin/infrastructure/architecture#agents` |
`/docs/install/plan/architecture#agents` |

`scripts/releaser/docs.go` was already updated in #29304; this covers
what that pass missed.

Two notes on anchors:

- The `#external-provisioners` anchor was already dead before #29304, so
it now points at `#types-of-provisioners`, the section covering
external, organization-scoped, and user-scoped provisioners.
- Every other anchor was verified to still exist on its new page.

One link left alone: `provisionerd/provisionerd.go` references
`docs/admin/provisioners.md` through a pinned-commit GitHub permalink,
which still resolves and shouldn't be rewritten.

## Verification

- `go test ./scripts/release/...` passes, including the release note
golden strings.
- `go build ./scripts/releaser/` succeeds.
- `make pre-commit` passes.
- Markdown table padding reflowed with `markdown-table-formatter`;
`markdownlint` reports no new findings.

<sub>Opened by Coder Agents on behalf of @nickvigilante.</sub>
2026-10-05 22:28:54 +00:00

184 lines
4.9 KiB
Go

package main
import (
"context"
"path/filepath"
"testing"
"time"
"github.com/google/go-cmp/cmp"
"github.com/spf13/afero"
"github.com/stretchr/testify/require"
)
func Test_removeMainlineBlurb(t *testing.T) {
t.Parallel()
tests := []struct {
name string
body string
want string
}{
{
name: "NoMainlineBlurb",
body: `## Changelog
### Chores
- Add support for additional Azure Instance Identity RSA Certificates (#13028) (@kylecarbs)
Compare: [` + "`" + `v2.10.1...v2.10.2` + "`" + `](https://github.com/coder/coder/compare/v2.10.1...v2.10.2)
## Container image
- ` + "`" + `docker pull ghcr.io/coder/coder:v2.10.2` + "`" + `
## Install/upgrade
Refer to our docs to [install](https://coder.com/docs/install) or [upgrade](https://coder.com/docs/install/operate/upgrade) Coder, or use a release asset below.
`,
want: `## Changelog
### Chores
- Add support for additional Azure Instance Identity RSA Certificates (#13028) (@kylecarbs)
Compare: [` + "`" + `v2.10.1...v2.10.2` + "`" + `](https://github.com/coder/coder/compare/v2.10.1...v2.10.2)
## Container image
- ` + "`" + `docker pull ghcr.io/coder/coder:v2.10.2` + "`" + `
## Install/upgrade
Refer to our docs to [install](https://coder.com/docs/install) or [upgrade](https://coder.com/docs/install/operate/upgrade) Coder, or use a release asset below.
`,
},
{
name: "WithMainlineBlurb",
body: `## Changelog
> [!NOTE]
> This is a mainline Coder release. We advise enterprise customers without a staging environment to install our [latest stable release](https://github.com/coder/coder/releases/latest) while we refine this version. Learn more about our [Release Schedule](https://coder.com/docs/reference/releases).
### Chores
- Add support for additional Azure Instance Identity RSA Certificates (#13028) (@kylecarbs)
Compare: [` + "`" + `v2.10.1...v2.10.2` + "`" + `](https://github.com/coder/coder/compare/v2.10.1...v2.10.2)
## Container image
- ` + "`" + `docker pull ghcr.io/coder/coder:v2.10.2` + "`" + `
## Install/upgrade
Refer to our docs to [install](https://coder.com/docs/install) or [upgrade](https://coder.com/docs/install/operate/upgrade) Coder, or use a release asset below.
`,
want: `## Changelog
### Chores
- Add support for additional Azure Instance Identity RSA Certificates (#13028) (@kylecarbs)
Compare: [` + "`" + `v2.10.1...v2.10.2` + "`" + `](https://github.com/coder/coder/compare/v2.10.1...v2.10.2)
## Container image
- ` + "`" + `docker pull ghcr.io/coder/coder:v2.10.2` + "`" + `
## Install/upgrade
Refer to our docs to [install](https://coder.com/docs/install) or [upgrade](https://coder.com/docs/install/operate/upgrade) Coder, or use a release asset below.
`,
},
{
name: "EntireQuotedBlurbIsRemoved",
body: `## Changelog
> [!NOTE]
> This is a mainline Coder release. We advise enterprise customers without a staging environment to install our [latest stable release](https://github.com/coder/coder/releases/latest) while we refine this version. Learn more about our [Release Schedule](https://coder.com/docs/reference/releases).
> This is an extended note.
> This is another extended note.
### Best release yet!
Enjoy.
`,
want: `## Changelog
### Best release yet!
Enjoy.
`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
if diff := cmp.Diff(removeMainlineBlurb(tt.body), tt.want); diff != "" {
require.Fail(t, "removeMainlineBlurb() mismatch (-want +got):\n%s", diff)
}
})
}
}
func Test_addStableSince(t *testing.T) {
t.Parallel()
date := time.Date(2024, time.April, 23, 0, 0, 0, 0, time.UTC)
body := "## Changelog"
want := "> ## Stable (since April 23, 2024)\n\n## Changelog"
got := addStableSince(date, body)
if diff := cmp.Diff(want, got); diff != "" {
require.Fail(t, "addStableSince() mismatch (-want +got):\n%s", diff)
}
// Test that it doesn't add twice.
got = addStableSince(date, got)
if diff := cmp.Diff(want, got); diff != "" {
require.Fail(t, "addStableSince() mismatch (-want +got):\n%s", diff, "addStableSince() should not add twice")
}
}
func Test_release_autoversion(t *testing.T) {
t.Parallel()
ctx := context.Background()
dir := filepath.Join("testdata", "autoversion")
fs := afero.NewCopyOnWriteFs(afero.NewOsFs(), afero.NewMemMapFs())
r := releaseCommand{
fs: afero.NewBasePathFs(fs, dir),
}
err := r.autoversion(ctx, "mainline", "v2.11.1")
require.NoError(t, err)
err = r.autoversion(ctx, "stable", "v2.9.4")
require.NoError(t, err)
files, err := filepath.Glob(filepath.Join(dir, "docs", "*.md"))
require.NoError(t, err)
for _, file := range files {
t.Run(file, func(t *testing.T) {
t.Parallel()
got, err := afero.ReadFile(fs, file)
require.NoError(t, err)
want, err := afero.ReadFile(fs, file+".golden")
require.NoError(t, err)
if diff := cmp.Diff(string(got), string(want)); diff != "" {
require.Failf(t, "mismatch (-want +got):\n%s", diff)
}
})
}
}