ci: revert skips of required checks (#3303)

These were putting certain PRs in an unmergeable state.
This commit is contained in:
Ammar Bandukwala
2022-07-29 18:49:51 +00:00
committed by GitHub
parent d12e6b394f
commit 29eccbe4da
7 changed files with 1 additions and 184 deletions
+1 -44
View File
@@ -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,15 @@ 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
@@ -108,8 +82,6 @@ jobs:
name: style/lint/shellcheck
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 +94,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 +177,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 +209,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 +294,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 +474,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 +529,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:
-7
View File
@@ -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.
-12
View File
@@ -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
)
-16
View File
@@ -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=
-39
View File
@@ -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, " "))
}
-28
View File
@@ -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
}
-38
View File
@@ -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)
}
})
}
}