Files
coder/.github/workflows/prcontext/main.go
T
Ammar Bandukwala 60de8d0279 ci: add skip directives for long tests (#3151)
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)
2022-07-24 14:33:58 -05:00

40 lines
940 B
Go

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, " "))
}