Skip to content

Commit

Permalink
Adding github actions for CI (#588)
Browse files Browse the repository at this point in the history
* Adding github actions for CI

Signed-off-by: Scott Nichols <snichols@vmware.com>

* remove golang 1.14+ t.Cleanup call.

Signed-off-by: Scott Nichols <snichols@vmware.com>

* break apart the style tests

Signed-off-by: Scott Nichols <snichols@vmware.com>

* Adding integration tests with github services

Signed-off-by: Scott Nichols <snichols@vmware.com>

* adding linting exceptions

Signed-off-by: Scott Nichols <snichols@vmware.com>

* go mod tidy

Signed-off-by: Scott Nichols <snichols@vmware.com>

* add ADV_HOST

Signed-off-by: Scott Nichols <snichols@vmware.com>

* natss has bumped to 0.18

Signed-off-by: Scott Nichols <snichols@vmware.com>

* run int test at 1.14 anf 1.15 go version

Signed-off-by: Scott Nichols <snichols@vmware.com>
  • Loading branch information
Scott Nichols authored Sep 28, 2020
1 parent f0303ff commit 68306c1
Show file tree
Hide file tree
Showing 20 changed files with 392 additions and 357 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/conformance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Conformance

on:
push:
branches: [ 'master', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]

jobs:

conformance:
name: CloudEvents
strategy:
matrix:
go-version: [1.13.x, 1.14.x, 1.15.x]
platform: [ubuntu-latest]

runs-on: ${{ matrix.platform }}

steps:

- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go

- name: Checkout code
uses: actions/checkout@v2

- name: Update git submodule
run: git submodule sync && git submodule update --init

- name: Build
run: ./hack/conformance-test.sh

33 changes: 33 additions & 0 deletions .github/workflows/go-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build

on:
push:
branches: [ 'master', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]

jobs:

build:
name: Build
strategy:
matrix:
go-version: [1.13.x, 1.14.x, 1.15.x]
platform: [ubuntu-latest]

runs-on: ${{ matrix.platform }}

steps:

- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go

- name: Checkout code
uses: actions/checkout@v2

- name: Build
run: ./hack/build-test.sh

40 changes: 40 additions & 0 deletions .github/workflows/go-format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Go Format

on:
push:
branches: [ 'master', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]

jobs:

format:
name: Format
runs-on: ubuntu-latest

steps:

- name: Setup Go 1.14.x
uses: actions/setup-go@v2
with:
go-version: 1.14.x
id: go

- name: Checkout code
uses: actions/checkout@v2

- name: Go Format
shell: bash
run: |
gofmt -s -w $(find -type f -name '*.go' -print)
- name: Verify
shell: bash
run: |
if [[ $(git diff-index --name-only HEAD --) ]]; then
echo "Found diffs in:"
git diff-index --name-only HEAD --
echo "${{ github.repository }} is out of style. Please run go fmt."
exit 1
fi
echo "${{ github.repository }} is formatted correctly."
37 changes: 37 additions & 0 deletions .github/workflows/go-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Code Style

on:
push:
branches: [ 'master', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]

jobs:

lint:
name: Lint
runs-on: ubuntu-latest

steps:

- name: Setup Go 1.14.x
uses: actions/setup-go@v2
with:
go-version: 1.14.x
id: go

- name: Checkout code
uses: actions/checkout@v2

- id: golangci_configuration
uses: andstor/file-existence-action@v1
with:
files: .golangci.yaml

- name: Go Lint on ./v2
if: steps.golangci_configuration.outputs.files_exists == 'true'
uses: golangci/golangci-lint-action@v2
with:
version: v1.29
working-directory: v2

32 changes: 32 additions & 0 deletions .github/workflows/go-unit-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Unit Test

on:
push:
branches: [ 'master', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]

jobs:

test:
name: Unit Test
strategy:
matrix:
go-version: [1.13.x, 1.14.x, 1.15.x]
platform: [ubuntu-latest]

runs-on: ${{ matrix.platform }}

steps:

- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go

- name: Checkout code
uses: actions/checkout@v2

- name: Test
run: ./hack/unit-test.sh
55 changes: 55 additions & 0 deletions .github/workflows/inclusive.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Inclusive

on:
push:
branches: [ 'master', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]

jobs:

language:
name: Language
runs-on: ubuntu-latest

steps:

- name: Checkout code
uses: actions/checkout@v2

# This is mostly copied from https://github.com/get-woke/woke-action-reviewdog/blob/main/entrypoint.sh
# since their action is not yet released under a stable version.
- name: Woke
shell: bash
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ github.token }}
WOKE_VERSION: v0.1.11
run: |
set -e
cd "${GITHUB_WORKSPACE}" || exit 1
TEMP_PATH="$(mktemp -d)"
PATH="${TEMP_PATH}:$PATH"
echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog'
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" 2>&1
echo '::endgroup::'
echo '::group:: Installing woke ... https://github.com/get-woke/woke'
curl -sfL https://raw.githubusercontent.com/get-woke/woke/main/install.sh | sh -s -- -b "${TEMP_PATH}" "${WOKE_VERSION}" 2>&1
echo '::endgroup::'
# Create a minimal .wokeignore if none already exist.
if [ ! -f .wokeignore ]; then
echo "vendor\nthird_party" > .wokeignore
fi
echo '::group:: Running woke with reviewdog 🐶 ...'
woke --output simple \
| reviewdog -efm="%f:%l:%c: %m" \
-name="woke" \
-reporter="github-pr-check" \
-filter-mode="added" \
-fail-on-error="true" \
-level="error" \
echo '::endgroup::'
70 changes: 70 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Integration Tests

on:
push:
branches: [ 'master', 'release-*' ]
pull_request:
branches: [ 'master', 'release-*' ]

jobs:

integration:
name: CloudEvents
strategy:
matrix:
go-version: [1.14.x, 1.15.x]
platform: [ubuntu-latest]

runs-on: ${{ matrix.platform }}

services:
kafka:
image: lensesio/fast-data-dev
env:
ADV_HOST: localhost
ports:
- 9091:9091
- 9092:9092

natss:
image: nats-streaming:0.18.0
ports:
- 4222:4222

amqp:
image: scholzj/qpid-dispatch
env:
QDROUTERD_CONFIG_OPTIONS: |
router {
mode: standalone
id: ZTg2NDQ0N2Q1YjU1OGE1N2NkNzY4NDFk
workerThreads: 4
}
log {
module: DEFAULT
enable: trace+
timestamp: true
}
listener {
role: normal
host: 0.0.0.0
port: amqp
saslMechanisms: ANONYMOUS
}
ports:
- 5672:5672

steps:

- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go

- name: Checkout code
uses: actions/checkout@v2

- name: Test
run: ./hack/integration-test.sh

12 changes: 12 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
run:
timeout: 5m

build-tags:
- conformance

linters:
enable:
- unconvert
- prealloc
disable:
- errcheck
20 changes: 20 additions & 0 deletions hack/build-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset

for gomodule in $(find . | grep "go\.mod" | awk '{gsub(/\/go.mod/,""); print $0}' | grep -v "./test" | grep -v "./conformance")
do
echo
echo --- Building $gomodule ---
echo
pushd $gomodule


tags="$(grep -I -r '// +build' . | cut -f3 -d' ' | sort | uniq | grep -v '^!' | tr '\n' ' ')"

echo "Building with tags: ${tags}"
go test -vet=off -tags "${tags}" -run=^$ ./... | grep -v "no test" || true

popd
done
2 changes: 1 addition & 1 deletion hack/integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fi
COVERPKG=$(go list ./... | grep -v /vendor | tr "\n" ",")
for gomodule in $(go list ./... | grep -v /cmd | grep -v /vendor)
do
go test -v -parallel 1 -timeout 120s -race -covermode=atomic -coverprofile=coverage.tmp -coverpkg "$COVERPKG" "$gomodule" 2>&1 | sed 's/ of statements in.*//; /warning: no packages being tested depend on matches for pattern /d'
go test -v -parallel 1 -timeout 10m -race -covermode=atomic -coverprofile=coverage.tmp -coverpkg "$COVERPKG" "$gomodule" 2>&1 | sed 's/ of statements in.*//; /warning: no packages being tested depend on matches for pattern /d'
tail -n +2 coverage.tmp >> $COVERAGE
done
rm coverage.tmp
Expand Down
3 changes: 3 additions & 0 deletions hack/unit-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ echo 'mode: atomic' > $COVERAGE

for gomodule in $(find . | grep "go\.mod" | awk '{gsub(/\/go.mod/,""); print $0}' | grep -v "./test" | grep -v "./conformance")
do
echo
echo --- Testing $gomodule ---
echo

pushd $gomodule
touch ./coverage.tmp
COVERPKG=$(go list ./... | grep -v /vendor | grep -v /test | tr "\n" ",")
Expand Down
18 changes: 6 additions & 12 deletions test/conformance/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,16 @@ replace github.com/cloudevents/sdk-go/protocol/nats/v2 => ../../protocol/nats/v2
replace github.com/cloudevents/sdk-go/protocol/kafka_sarama/v2 => ../../protocol/kafka_sarama/v2

require (
contrib.go.opencensus.io/exporter/prometheus v0.1.0
github.com/Azure/go-amqp v0.12.7
github.com/Shopify/sarama v1.25.0
github.com/cloudevents/sdk-go v1.2.0
github.com/cloudevents/sdk-go/protocol/amqp/v2 v2.0.0
github.com/cloudevents/sdk-go/protocol/kafka_sarama/v2 v2.0.0
github.com/cloudevents/sdk-go/protocol/nats/v2 v2.0.0
github.com/cloudevents/sdk-go/protocol/pubsub/v2 v2.0.0
github.com/cloudevents/sdk-go/protocol/stan/v2 v2.0.0
github.com/cloudevents/sdk-go/v2 v2.0.0
github.com/cucumber/godog v0.9.0
github.com/cucumber/messages-go/v10 v10.0.3
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/google/go-cmp v0.4.1
github.com/google/uuid v1.1.1
github.com/gorilla/mux v1.7.3
github.com/kelseyhightower/envconfig v1.4.0
github.com/stretchr/testify v1.5.1
go.opencensus.io v0.22.3
go.opencensus.io v0.22.3 // indirect
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 // indirect
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d // indirect
google.golang.org/protobuf v1.22.0 // indirect
)
Loading

0 comments on commit 68306c1

Please sign in to comment.