Skip to content

Commit 63f8912

Browse files
committed
testing checks
1 parent 8b6450d commit 63f8912

File tree

6 files changed

+133
-14
lines changed

6 files changed

+133
-14
lines changed

.github/workflows/check-testing.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
on:
2+
pull_request:
3+
types: ["opened", "synchronize", "reopened"]
4+
5+
jobs:
6+
checkerator:
7+
runs-on: ubuntu-latest
8+
name: checkerator-test
9+
steps:
10+
- uses: docker://gcr.io/kubebuilder/checkerator:test-7
11+
with:
12+
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/main.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
on:
2-
pull_request:
3-
types: [opened, closed, reopened, edited, synchronize]
4-
5-
jobs:
6-
pr_checks:
7-
runs-on: ubuntu-latest
8-
name: verify emoji
9-
steps:
10-
- uses: actions/checkout@v2
11-
- name: verify
12-
uses: ./hack/release
13-
env:
14-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1+
on:
2+
pull_request:
3+
types: [opened, closed, reopened, edited, synchronize]
4+
5+
jobs:
6+
pr_checks:
7+
runs-on: ubuntu-latest
8+
name: verify emoji
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: verify
12+
uses: ./hack/release
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

hack/actions-helpers/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM golang:1.13 as build
2+
3+
RUN mkdir /build
4+
WORKDIR /build
5+
COPY checkerator.go go.mod go.sum /build/
6+
RUN CGO_ENABLED=0 go build -o checkerator .
7+
8+
FROM gcr.io/distroless/static
9+
COPY --from=build /build/checkerator /
10+
ENTRYPOINT ["/checkerator"]

hack/actions-helpers/checkerator.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package main
2+
3+
import (
4+
"os"
5+
"context"
6+
"log"
7+
"net/http"
8+
"io/ioutil"
9+
"encoding/json"
10+
11+
"github.com/google/go-github/v29/github"
12+
"golang.org/x/oauth2"
13+
)
14+
15+
func tokenClientFor(ctx context.Context, token string) *http.Client {
16+
tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token})
17+
return oauth2.NewClient(ctx, tokenSource)
18+
}
19+
20+
func main() {
21+
ctx := context.Background()
22+
23+
// load the event data
24+
ghEvt := os.Getenv("GITHUB_EVENT_NAME")
25+
if ghEvt == "" {
26+
log.Fatal("unable to figure out event that triggered this execution (check GITHUB_EVENT_NAME)")
27+
}
28+
ghEvtDataPath := os.Getenv("GITHUB_EVENT_PATH")
29+
if ghEvtDataPath == "" {
30+
log.Fatal("unable to figure out path to GitHub event data (check GITHUB_EVENT_PATH)")
31+
}
32+
33+
rawEventData, err := ioutil.ReadFile(ghEvtDataPath)
34+
if err != nil {
35+
log.Fatalf("unable to read GitHub event data: %v", err)
36+
}
37+
var eventData github.Event
38+
if err := json.Unmarshal(rawEventData, &eventData); err != nil {
39+
log.Fatalf("unable to unmarshal GitHub event data: %v", err)
40+
}
41+
42+
// set up the client
43+
ghToken := os.Getenv("INPUT_GITHUB_TOKEN")
44+
if ghToken == "" {
45+
log.Fatal("no GitHub access token defined (specify INPUT_GITHUB_TOKEN via `with: {github_token: <the secret syntax>}`)")
46+
}
47+
_ = github.NewClient(tokenClientFor(ctx, ghToken))
48+
49+
if eventData.Type == nil {
50+
log.Fatal("GitHub event data didn't list a type:\n%s", string(rawEventData))
51+
}
52+
switch *eventData.Type {
53+
case "check_suite":
54+
log.Printf("check suite:\n%s", rawEventData)
55+
case "check_run":
56+
log.Printf("check run:\n%s", rawEventData)
57+
case "pull_request":
58+
log.Printf("pull request:\n%s", rawEventData)
59+
// TODO
60+
default:
61+
log.Fatalf("unknown event type %q in GitHub event data", *eventData.Type)
62+
}
63+
}

hack/actions-helpers/go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module sigs.k8s.io/controller-runtime/hack/actions-helpers
2+
3+
go 1.13
4+
5+
require (
6+
github.com/google/go-github v17.0.0+incompatible
7+
github.com/google/go-github/v29 v29.0.3
8+
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
9+
)

hack/actions-helpers/go.sum

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
2+
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
3+
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
4+
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
5+
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
6+
github.com/google/go-github/v29 v29.0.3 h1:IktKCTwU//aFHnpA+2SLIi7Oo9uhAzgsdZNbcAqhgdc=
7+
github.com/google/go-github/v29 v29.0.3/go.mod h1:CHKiKKPHJ0REzfwc14QMklvtHwCveD0PxlMjLlzAM5E=
8+
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
9+
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
10+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
11+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
12+
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
13+
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
14+
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
15+
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
16+
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
17+
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
18+
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
19+
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw=
20+
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
21+
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
22+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
23+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
24+
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
25+
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=

0 commit comments

Comments
 (0)