From 076b2526c4e556725babc49d3f0dd5318737f3fa Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Fri, 29 Jul 2022 18:28:49 +0000 Subject: [PATCH 1/2] ci: revert skips of required checks These were putting certain PRs in an unmergeable state. --- .github/workflows/coder.yaml | 43 +---------------------- .github/workflows/prcontext/README.md | 7 ---- .github/workflows/prcontext/go.mod | 12 ------- .github/workflows/prcontext/go.sum | 16 --------- .github/workflows/prcontext/main.go | 39 -------------------- .github/workflows/prcontext/parse.go | 28 --------------- .github/workflows/prcontext/parse_test.go | 38 -------------------- 7 files changed, 1 insertion(+), 182 deletions(-) delete mode 100644 .github/workflows/prcontext/README.md delete mode 100644 .github/workflows/prcontext/go.mod delete mode 100644 .github/workflows/prcontext/go.sum delete mode 100644 .github/workflows/prcontext/main.go delete mode 100644 .github/workflows/prcontext/parse.go delete mode 100644 .github/workflows/prcontext/parse_test.go diff --git a/.github/workflows/coder.yaml b/.github/workflows/coder.yaml index 9bce6a892d276..cf25ce3c00d4e 100644 --- a/.github/workflows/coder.yaml +++ b/.github/workflows/coder.yaml @@ -34,7 +34,6 @@ jobs: runs-on: ubuntu-latest outputs: docs-only: ${{ steps.filter.outputs.docs_count == steps.filter.outputs.all_count }} - go: ${{ steps.filter.outputs.go }} sh: ${{ steps.filter.outputs.sh }} steps: - uses: actions/checkout@v3 @@ -49,10 +48,6 @@ jobs: - 'docs/**' # For testing: # - '.github/**' - go: - - "**.go" - - "**.mod" - - "**.sum" sh: - "**.sh" - id: debug @@ -63,36 +58,16 @@ jobs: debug-inputs: needs: - changes - - pr-context runs-on: ubuntu-latest steps: - id: log run: | echo "${{ toJSON(needs) }}" - echo "${{ contains(needs.pr-context.outputs.skips, 'test/go/postgres') }} " - echo "${{ contains(needs.pr-context.outputs.skips, 'test/e2e') }} " - - pr-context: - runs-on: ubuntu-latest - outputs: - skips: ${{ steps.pr-context.outputs.skips }} - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: "~1.18" - - id: pr-context - env: - GITHUB_CONTEXT: ${{ toJSON(github) }} - run: | - (cd .github/workflows/prcontext && go build) - ./.github/workflows/prcontext/prcontext style-lint-golangci: name: style/lint/golangci timeout-minutes: 5 needs: changes - if: needs.changes.outputs.go == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -109,7 +84,6 @@ jobs: timeout-minutes: 5 runs-on: ubuntu-latest needs: changes - if: needs.changes.outputs.sh == 'true' steps: - uses: actions/checkout@v3 - name: Run ShellCheck @@ -122,8 +96,6 @@ jobs: style-lint-typescript: name: "style/lint/typescript" timeout-minutes: 5 - needs: changes - if: needs.changes.outputs.docs-only == 'false' runs-on: ubuntu-latest steps: - name: Checkout @@ -207,8 +179,6 @@ jobs: style-fmt: name: "style/fmt" - needs: changes - if: needs.changes.outputs.docs-only == 'false' runs-on: ubuntu-latest timeout-minutes: 5 steps: @@ -241,8 +211,6 @@ jobs: test-go: name: "test/go" - needs: changes - if: needs.changes.outputs.docs-only == 'false' runs-on: ${{ matrix.os }} timeout-minutes: 20 strategy: @@ -328,12 +296,6 @@ jobs: test-go-postgres: name: "test/go/postgres" - needs: - - changes - - pr-context - if: > - needs.changes.outputs.docs-only == 'false' && - !contains(needs.pr-context.outputs.skips, 'test/go/postgres') runs-on: ubuntu-latest # This timeout must be greater than the timeout set by `go test` in # `make test-postgres` to ensure we receive a trace of running @@ -514,8 +476,6 @@ jobs: test-js: name: "test/js" - needs: changes - if: needs.changes.outputs.docs-only == 'false' runs-on: ubuntu-latest timeout-minutes: 20 steps: @@ -571,8 +531,7 @@ jobs: name: "test/e2e/${{ matrix.os }}" needs: - changes - - pr-context - if: needs.changes.outputs.docs-only == 'false' && !contains(needs.pr-context.outputs.skips, 'test/e2e') + if: needs.changes.outputs.docs-only == 'false' runs-on: ${{ matrix.os }} timeout-minutes: 20 strategy: diff --git a/.github/workflows/prcontext/README.md b/.github/workflows/prcontext/README.md deleted file mode 100644 index f3be624d1978e..0000000000000 --- a/.github/workflows/prcontext/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# prcontext - -`prcontext` is a simple Go program that extracts CI directives from PRs for a -more efficient merge cycle. - -Right now it only supports the `[ci-skip [job ...]]` directive. Since skips are -only possible within PRs, the full suite will still run on merge. diff --git a/.github/workflows/prcontext/go.mod b/.github/workflows/prcontext/go.mod deleted file mode 100644 index d34877bdad58b..0000000000000 --- a/.github/workflows/prcontext/go.mod +++ /dev/null @@ -1,12 +0,0 @@ -module github.com/coder/coder/.github/workflows/prcontext - -go 1.18 - -require github.com/coder/flog v1.0.0 - -require ( - github.com/fatih/color v1.13.0 // indirect - github.com/mattn/go-colorable v0.1.12 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect - golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 // indirect -) diff --git a/.github/workflows/prcontext/go.sum b/.github/workflows/prcontext/go.sum deleted file mode 100644 index d68ccc2a7496d..0000000000000 --- a/.github/workflows/prcontext/go.sum +++ /dev/null @@ -1,16 +0,0 @@ -github.com/coder/flog v1.0.0 h1:gqr4jYDQWYmsvFD0RV6Vs+SAj1Kbn0HGlV7UghfxP+8= -github.com/coder/flog v1.0.0/go.mod h1:UQlQvrkJBvnRGo69Le8E24Tcl5SJleAAR7gYEHzAmdQ= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/.github/workflows/prcontext/main.go b/.github/workflows/prcontext/main.go deleted file mode 100644 index f9c087c477b44..0000000000000 --- a/.github/workflows/prcontext/main.go +++ /dev/null @@ -1,39 +0,0 @@ -package main - -import ( - "encoding/json" - "fmt" - "os" - "strings" - - "github.com/coder/flog" -) - -// githubContext is structured as documented here: -// https://docs.github.com/en/actions/learn-github-actions/contexts#github-context. -type githubContext struct { - EventName string `json:"event_name"` - Event struct { - PullRequest struct { - Body string `json:"body"` - } `json:"pull_request"` - } `json:"event"` -} - -func main() { - var c githubContext - err := json.Unmarshal([]byte(os.Getenv("GITHUB_CONTEXT")), &c) - if err != nil { - flog.Fatal("decode stdin: %+v", err) - } - flog.Info("detected event %q", c.EventName) - if c.EventName != "pull_request" { - flog.Info("aborting since not Pull Request") - return - } - - _, _ = fmt.Printf("::group::{PR Body}\n%s\n::endgroup::\n", c.Event.PullRequest.Body) - - skips := parseBody(c.Event.PullRequest.Body) - _, _ = fmt.Printf("::echo::on\n::set-output name=skips::[%s]\n", strings.Join(skips, " ")) -} diff --git a/.github/workflows/prcontext/parse.go b/.github/workflows/prcontext/parse.go deleted file mode 100644 index 4d4155772c32f..0000000000000 --- a/.github/workflows/prcontext/parse.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "regexp" - "strings" -) - -const ciSkipPrefix = "ci-skip" - -var skipDirective = regexp.MustCompile(`\[` + ciSkipPrefix + ` ([\w-\/ ]+)]`) - -func parseBody(body string) (skips []string) { - matches := skipDirective.FindAllStringSubmatch(body, -1) - // flog.Info("matches: %+v", matches) - - var skipMatches []string - for i := range matches { - for j := range matches[i] { - v := matches[i][j] - // flog.Info("%q", v) - if !strings.Contains(v, ciSkipPrefix) { - skipMatches = append(skipMatches, strings.Split(v, " ")...) - } - } - } - - return skipMatches -} diff --git a/.github/workflows/prcontext/parse_test.go b/.github/workflows/prcontext/parse_test.go deleted file mode 100644 index 3ef63163a4948..0000000000000 --- a/.github/workflows/prcontext/parse_test.go +++ /dev/null @@ -1,38 +0,0 @@ -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) - } - }) - } -} From d52369734d6f151f3740fc59fcd2fa42af5afd78 Mon Sep 17 00:00:00 2001 From: Ammar Bandukwala Date: Fri, 29 Jul 2022 18:35:36 +0000 Subject: [PATCH 2/2] fixup! ci: revert skips of required checks --- .github/workflows/coder.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/coder.yaml b/.github/workflows/coder.yaml index cf25ce3c00d4e..fb41b3f1f2924 100644 --- a/.github/workflows/coder.yaml +++ b/.github/workflows/coder.yaml @@ -67,7 +67,6 @@ jobs: style-lint-golangci: name: style/lint/golangci timeout-minutes: 5 - needs: changes runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -83,7 +82,6 @@ jobs: name: style/lint/shellcheck timeout-minutes: 5 runs-on: ubuntu-latest - needs: changes steps: - uses: actions/checkout@v3 - name: Run ShellCheck