mirror of
https://github.com/coder/coder.git
synced 2026-06-05 14:08:20 +00:00
60de8d0279
This PR introduces many CI optimizations: 1. The `[ci-skip]` PR body directive to skip the Postgres and end to end tests 2. Improved caching that cuts the Go test matrix in half 3. Increasing Go test parallelism for ~20% gains 4. Enable caching in webpack (4x frontend build)
39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
func Test_parseBody_basic(t *testing.T) {
|
|
parseBody(`
|
|
This is a test PR.
|
|
|
|
[ci-skip postgres windows]
|
|
`)
|
|
}
|
|
|
|
func Test_parseBody(t *testing.T) {
|
|
type args struct {
|
|
body string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
args args
|
|
wantSkips []string
|
|
}{
|
|
{"no directive", args{"test pr 123\n\n"}, nil},
|
|
{"single dir single skip", args{"test pr [ci-skip dog] 123\n\n"}, []string{"dog"}},
|
|
{"double dir double skip", args{"test pr [ci-skip dog] [ci-skip cat] 123\n\n"}, []string{"dog", "cat"}},
|
|
{"single dir double skip", args{"test pr [ci-skip test/go/postgres cat] 123\n\n"}, []string{"test/go/postgres", "cat"}},
|
|
{"confuse", args{"ci ci [ci-skip] dog [ci-skip test/go/postgres test/e2e/ubuntu-latest] 123\n\n"}, []string{"test/go/postgres", "test/e2e/ubuntu-latest"}},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if gotSkips := parseBody(tt.args.body); !reflect.DeepEqual(gotSkips, tt.wantSkips) {
|
|
t.Errorf("parseBody() = %v, want %v", gotSkips, tt.wantSkips)
|
|
}
|
|
})
|
|
}
|
|
}
|