From 8ed50c90cd5747b37ce329c517f428a0e3677c6d Mon Sep 17 00:00:00 2001 From: Evan Cordell Date: Tue, 22 Aug 2023 17:06:05 -0400 Subject: [PATCH] add basic CI GHA config --- .github/dependabot.yml | 15 ++++++ .github/labeler.yml | 20 ++++++++ .github/workflows/build-test.yaml | 81 +++++++++++++++++++++++++++++++ .github/workflows/cla.yaml | 23 +++++++++ .github/workflows/labeler.yaml | 15 ++++++ magefiles/dev.go | 3 +- magefiles/test.go | 7 ++- 7 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/build-test.yaml create mode 100644 .github/workflows/cla.yaml create mode 100644 .github/workflows/labeler.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..0effb36 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +--- +version: 2 +updates: + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "monthly" + labels: + - "area/dependencies" + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "monthly" + labels: + - "area/dependencies" diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..bcfb531 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,20 @@ +--- +"area/cli": + - "cmd/**/*" +"area/core": + - "pkg/**/*" +"area/dependencies": + - "Dockerfile" + - "go.mod" + - "go.sum" +"area/docs": + - "CODE-OF-CONDUCT.md" + - "CONTRIBUTING.md" + - "DCO" + - "LICENSE" + - "README.md" +"area/tooling": + - "**/*_test.go" + - ".github/**/*" + - ".*" + - "Dockerfile*" diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml new file mode 100644 index 0000000..0f6e665 --- /dev/null +++ b/.github/workflows/build-test.yaml @@ -0,0 +1,81 @@ +--- +name: "Build & Test" +on: # yamllint disable-line rule:truthy + push: + branches: + - "main" + pull_request: + branches: + - "*" + merge_group: + types: + - "checks_requested" +env: + GO_VERSION: "~1.20.7" +jobs: + paths-filter: + runs-on: "ubuntu-latest" + outputs: + codechange: "${{ steps.code-filter.outputs.codechange }}" + steps: + - uses: "actions/checkout@v2" + - uses: "dorny/paths-filter@v2" + id: "code-filter" + with: + filters: | + codechange: + - ".github/workflows/build-test.yaml" + - "Dockerfile" + - "go.mod" + - "go.sum" + - "cmd/**" + - "magefiles/**" + - "pkg/**" + - "e2e/**" + - "internal/**" + build: + name: "Build Binary" + runs-on: "ubuntu-latest" + needs: "paths-filter" + if: | + needs.paths-filter.outputs.codechange == 'true' + steps: + - uses: "actions/checkout@v3" + - uses: "authzed/actions/setup-go@main" + with: + go-version: "${{ env.GO_VERSION }}" + - uses: "authzed/actions/go-build@main" + + unit: + name: "Unit" + runs-on: "ubuntu-latest-4-cores" + needs: "paths-filter" + if: | + needs.paths-filter.outputs.codechange == 'true' + steps: + - uses: "actions/checkout@v3" + - uses: "authzed/actions/setup-go@main" + with: + go-version: "${{ env.GO_VERSION }}" + - name: "Unit tests" + uses: "magefile/mage-action@v2" + with: + version: "latest" + args: "test:unit" + + e2e: + name: "e2e Tests" + runs-on: "ubuntu-latest-4-cores" + needs: "paths-filter" + if: | + needs.paths-filter.outputs.codechange == 'true' + steps: + - uses: "actions/checkout@v3" + - uses: "authzed/actions/setup-go@main" + with: + go-version: "${{ env.GO_VERSION }}" + - name: "Unit tests" + uses: "magefile/mage-action@v2" + with: + version: "latest" + args: "test:e2e" diff --git a/.github/workflows/cla.yaml b/.github/workflows/cla.yaml new file mode 100644 index 0000000..b11bbde --- /dev/null +++ b/.github/workflows/cla.yaml @@ -0,0 +1,23 @@ +--- +name: "CLA" +on: # yamllint disable-line rule:truthy + issue_comment: + types: + - "created" + pull_request_target: + types: + - "opened" + - "closed" + - "synchronize" + merge_group: + types: + - "checks_requested" +jobs: + cla: + name: "Check Signature" + runs-on: "ubuntu-latest" + steps: + - uses: "authzed/actions/cla-check@main" + with: + github_token: "${{ secrets.GITHUB_TOKEN }}" + cla_assistant_token: "${{ secrets.CLA_ASSISTANT_ACCESS_TOKEN }}" diff --git a/.github/workflows/labeler.yaml b/.github/workflows/labeler.yaml new file mode 100644 index 0000000..0f424ea --- /dev/null +++ b/.github/workflows/labeler.yaml @@ -0,0 +1,15 @@ +--- +name: "Pull Request Labeler" +on: # yamllint disable-line rule:truthy + pull_request_target: + merge_group: + types: + - "checks_requested" +jobs: + triage: + runs-on: "ubuntu-latest" + steps: + - uses: "actions/labeler@v3" + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" + sync-labels: true diff --git a/magefiles/dev.go b/magefiles/dev.go index d673135..ecf2db3 100644 --- a/magefiles/dev.go +++ b/magefiles/dev.go @@ -44,7 +44,8 @@ const ( generatedKubeConfigPath = "proxy.kubeconfig" ) -func (Dev) Bootstrap(ctx context.Context) error { +// Up brings up a dev cluster with the proxy installed +func (Dev) Up(ctx context.Context) error { var proxyHostPort int32 if _, err := os.Stat(kubeconfigPath); err != nil { proxyHostPort, err = GetFreePort("localhost") diff --git a/magefiles/test.go b/magefiles/test.go index 9837a3b..a21e76d 100644 --- a/magefiles/test.go +++ b/magefiles/test.go @@ -9,7 +9,12 @@ import ( type Test mg.Namespace -// Runs the end-to-end tests against a real apiserver +// Unit runs the unit tests +func (Test) Unit() error { + return RunSh("go", WithV())("test", "./...") +} + +// E2e runs the end-to-end tests against a real apiserver func (Test) E2e() error { return RunSh("go", Tool())( "run",