Skip to content

Commit

Permalink
add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthpun committed Feb 1, 2024
1 parent 702e796 commit eade02d
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: Run tests
run: |
make install-tools
make generate
make test
make coverage
make check-tidy
make check-headers
make check-schema
- name: Upload coverage report
uses: codecov/codecov-action@v1
with:
file: ./coverage.txt
flags: unittests

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: generate
run: make generate
- uses: golangci/[email protected]
with:
version: v1.52.2
args: --timeout=3m
21 changes: 20 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@ generate-schema:
check-schema:
go run ./cmd/flow-schema/flow-schema.go --verify=true ./schema.json

.PHONY: check-tidy
check-tidy:
go mod tidy

.PHONY: check-headers
check-headers:
@./check-headers.sh

.PHONY: generate
generate: install-tools
go generate ./...
go generate ./...

.PHONY: coverage
coverage:
ifeq ($(COVER), true)
# file has to be called index.html
gocov convert $(COVER_PROFILE) > cover.json
./cover-summary.sh
gocov-html cover.json > index.html
# coverage.zip will automatically be picked up by teamcity
gozip -c coverage.zip index.html
endif
8 changes: 8 additions & 0 deletions check-headers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

files=$(find . -name \*.go -type f -print0 | xargs -0 grep -L -E '(Licensed under the Apache License)|(Code generated (from|by))')
if [ -n "$files" ]; then
echo "Missing license header in:"
echo "$files"
exit 1
fi

0 comments on commit eade02d

Please sign in to comment.