From 8a15f6d2703e0ba7c87cdd332353d0b48183574a Mon Sep 17 00:00:00 2001 From: Zach Wasserman Date: Thu, 26 Aug 2021 09:53:10 -0700 Subject: [PATCH] Add codecov to CI (#1824) This should cause codecov to run on all pull requests and all commits to main. Currently only doing coverage for Go files. --- .github/workflows/test-go.yaml | 47 ++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 32 ----------------------- .gitignore | 1 + Makefile | 2 +- 4 files changed, 49 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/test-go.yaml diff --git a/.github/workflows/test-go.yaml b/.github/workflows/test-go.yaml new file mode 100644 index 000000000..f7ff60357 --- /dev/null +++ b/.github/workflows/test-go.yaml @@ -0,0 +1,47 @@ +name: Go Tests + +on: + push: + branches: + - main + pull_request: + +jobs: + test-go: + strategy: + matrix: + os: [ubuntu-latest] + go-version: ['^1.16.0'] + runs-on: ${{ matrix.os }} + + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Checkout Code + uses: actions/checkout@v2 + + # Pre-starting dependencies here means they are ready to go when we need them. + - name: Start Infra Dependencies + # Use & to background this + run: docker-compose up -d mysql_test redis & + + # It seems faster not to cache Go dependencies + - name: Install Go Dependencies + run: make deps-go + + - name: Generate static files + run: | + export PATH=$PATH:~/go/bin + make generate-go + + - name: Run Go Tests + run: | + MYSQL_TEST=1 make test-go + + - name: Upload to Codecov + uses: codecov/codecov-action@v2 + with: + files: coverage.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 79bad42ad..2b70f5ed4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -143,36 +143,4 @@ jobs: run: | yarn prettier:check - test-go: - strategy: - matrix: - os: [ubuntu-latest] - go-version: ['^1.16.0'] - runs-on: ${{ matrix.os }} - - steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - name: Checkout Code - uses: actions/checkout@v2 - - # Pre-starting dependencies here means they are ready to go when we need them. - - name: Start Infra Dependencies - # Use & to background this - run: docker-compose up -d mysql_test redis & - - # It seems faster not to cache Go dependencies - - name: Install Go Dependencies - run: make deps-go - - - name: Generate static files - run: | - export PATH=$PATH:~/go/bin - make generate-go - - - name: Run Go Tests - run: | - MYSQL_TEST=1 make test-go diff --git a/.gitignore b/.gitignore index 20f75d9f0..d29462754 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ server/bindata/generated.go *.cover *.test *.log +coverage.txt # typescript generated test files tmp/ diff --git a/Makefile b/Makefile index b7b63413a..2b2fe3870 100644 --- a/Makefile +++ b/Makefile @@ -118,7 +118,7 @@ dump-test-schema: go run ./tools/dbutils ./server/datastore/mysql/schema.sql test-go: dump-test-schema - go test -tags full,fts5,netgo -parallel 8 ./... + go test -tags full,fts5,netgo -parallel 8 -coverprofile=coverage.txt -covermode=atomic ./... analyze-go: go test -tags full,fts5,netgo -race -cover ./...