Skip to content

Commit

Permalink
add github action (#16)
Browse files Browse the repository at this point in the history
* add github action
* master branch
* maybe fix
* switch go version
* go.sum
* code-gen script
* make the tests work without GOPATH
  • Loading branch information
EItanya authored Jul 12, 2021
1 parent 4688c2a commit 584c9e8
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 294 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: pull_request

on:
push:
branches:
- 'master'
pull_request: { }

jobs:
check-code-gen:
name: check-code-gen
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- run: |
git fetch --prune --unshallow
- name: Set up Go 1.16
uses: actions/setup-go@v1
with:
go-version: 1.16.3
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Protoc
uses: solo-io/setup-protoc@master
with:
version: '3.6.1'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check code gen
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: |
./ci/check-code-gen.sh
unit-tests:
name: unit-tests
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- run: |
git fetch --prune --unshallow
- name: Set up Go 1.16
uses: actions/setup-go@v1
with:
go-version: 1.16.3
- uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Protoc
uses: solo-io/setup-protoc@master
with:
version: '3.6.1'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Unit Tests
run: |
make update-deps run-tests
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ update-deps: mod-download
PATH=$(DEPSGOBIN):$$PATH go install github.com/envoyproxy/protoc-gen-validate
PATH=$(DEPSGOBIN):$$PATH go get -u github.com/golang/mock/gomock
PATH=$(DEPSGOBIN):$$PATH go install github.com/golang/mock/mockgen
PATH=$(DEPSGOBIN):$$PATH go install github.com/onsi/ginkgo/ginkgo


.PHONY: mod-download
Expand All @@ -51,3 +52,15 @@ $(OUTPUT_DIR)/.generated-code:
PATH=$(DEPSGOBIN):$$PATH goimports -w $(SUBDIRS)
PATH=$(DEPSGOBIN):$$PATH go mod tidy
PATH=$(DEPSGOBIN):$$PATH touch $@

# run all tests
# set TEST_PKG to run a specific test package
.PHONY: run-tests
run-tests:
ginkgo -r -failFast -trace $(GINKGOFLAGS) \
-ldflags=$(LDFLAGS) \
-gcflags=$(GCFLAGS) \
-progress \
-race \
-compilers=4 \
-skipPackage=$(SKIP_PACKAGES) $(TEST_PKG)
34 changes: 0 additions & 34 deletions cloudbuild-cache.yaml

This file was deleted.

61 changes: 1 addition & 60 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,5 @@ steps:

- name: gcr.io/cloud-builders/gsutil
entrypoint: 'bash'
args: ['-c', 'mkdir -p /go/pkg && cd /go/pkg && gsutil cat gs://$PROJECT_ID-cache/anyvendor/anyvendor-mod.tar.gz | tar -xzf -']
id: 'untar-mod-cache'
dir: &dir '/workspace/repo/anyvendor'

# prepare-workspace to set up the project so it can be built and tested
- name: 'gcr.io/$PROJECT_ID/prepare-go-workspace:0.2.2'
args:
- "--repo-owner"
- "solo-io"
- "--repo-name"
- anyvendor
- "--repo-sha"
- "$COMMIT_SHA"
- "--repo-output-dir"
- "repo"
env:
- 'GIT_SSH_CONFIG=FALSE'
id: 'prepare-workspace'

# download massive container in parallel
- name: 'gcr.io/$PROJECT_ID/go-mod-ginkgo:0.2.2'
entrypoint: 'bash'
dir: *dir
args: ['-c', 'ls']
waitFor: ['-']

# Installs go executables required by codegen tests
- name: 'gcr.io/$PROJECT_ID/go-mod-make:0.2.1'
args: ['update-deps']
waitFor: ['prepare-workspace']
id: 'update-deps'
dir: *dir

# check code gen for kubernetes custom resources, should be no diff
- name: 'gcr.io/$PROJECT_ID/go-mod-make:0.2.1'
entrypoint: 'bash'
args: ['ci/check-code-gen.sh']
env:
- 'PROJECT_ROOT=github.com/solo-io/anyvendor'
- 'TAGGED_VERSION=$TAG_NAME'
# waitFor: ['update-deps']
dir: *dir
id: 'check-code-and-docs-gen'


# e2e-ginkgo is produced from https://github.com/solo-io/cloud-builders/e2e-ginkgo
# sets up redis, consul, kubectl, go with required environment variables
# need to use the provided entrypoint
- name: 'gcr.io/$PROJECT_ID/go-mod-ginkgo:0.2.2'
args: ['-r', '-v', '-race', '-p', '-compilers=2']
dir: *dir
id: 'test'


timeout: 1500s
tags: ['anyvendor']
options:
machineType: 'N1_HIGHCPU_32'
volumes:
- name: 'gopath'
path: '/go'
id: 'ls'
23 changes: 11 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
module github.com/solo-io/anyvendor

go 1.13
go 1.16

require (
github.com/envoyproxy/protoc-gen-validate v0.4.1
github.com/golang/mock v1.4.4
github.com/golang/protobuf v1.4.3
github.com/envoyproxy/protoc-gen-validate v0.6.1
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.2
github.com/iancoleman/strcase v0.1.3 // indirect
github.com/lyft/protoc-gen-star v0.5.2 // indirect
github.com/lyft/protoc-gen-star v0.5.3 // indirect
github.com/mattn/go-zglob v0.0.3
github.com/onsi/ginkgo v1.11.0
github.com/onsi/gomega v1.8.1
github.com/rotisserie/eris v0.1.1
github.com/spf13/afero v1.5.1
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
golang.org/x/mod v0.4.1 // indirect
golang.org/x/net v0.0.0-20210119194325-5f4716e94777 // indirect
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/tools v0.1.0 // indirect
github.com/spf13/afero v1.6.0
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/tools v0.1.4 // indirect
google.golang.org/protobuf v1.27.1 // indirect
)
Loading

0 comments on commit 584c9e8

Please sign in to comment.