ci: upload coverage once (#7690)

This commit is contained in:
Marko 2020-10-27 16:46:57 +01:00 committed by GitHub
parent e306a852ff
commit db09e51613
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 71 additions and 256 deletions

View File

@ -7,8 +7,6 @@ coverage:
precision: 2
round: down
range: 70...100
notify:
after_n_builds: 4
status:
# Learn more at https://docs.codecov.io/docs/commit-status

View File

@ -57,46 +57,41 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.15
- name: Display go version
run: go version
- name: Create a file with all the pkgs
run: go list ./... > pkgs.txt
- name: Split pkgs into 4 files
run: split -n l/4 --additional-suffix=.txt ./pkgs.txt
run: split -d -n l/4 pkgs.txt pkgs.txt.part.
# cache multiple
- uses: actions/upload-artifact@v2
with:
name: "${{ github.sha }}-aa"
path: ./xaa.txt
name: "${{ github.sha }}-00"
path: ./pkgs.txt.part.00
- uses: actions/upload-artifact@v2
with:
name: "${{ github.sha }}-ab"
path: ./xab.txt
name: "${{ github.sha }}-01"
path: ./pkgs.txt.part.01
- uses: actions/upload-artifact@v2
with:
name: "${{ github.sha }}-ac"
path: ./xac.txt
name: "${{ github.sha }}-02"
path: ./pkgs.txt.part.02
- uses: actions/upload-artifact@v2
with:
name: "${{ github.sha }}-ad"
path: ./xad.txt
name: "${{ github.sha }}-03"
path: ./pkgs.txt.part.03
test-coverage-run-1:
tests:
runs-on: ubuntu-latest
needs: split-test-files
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
part: ["00", "01", "02", "03"]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
PATTERNS: |
**/**.go
@ -104,11 +99,46 @@ jobs:
go.sum
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-aa"
name: "${{ github.sha }}-${{ matrix.part }}"
if: env.GIT_DIFF
- name: test & coverage report creation
run: |
cat xaa.txt | xargs go test -mod=readonly -timeout 15m -coverprofile=coverage.txt -covermode=atomic -tags='norace ledger test_ledger_mock'
cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='norace ledger test_ledger_mock'
if: env.GIT_DIFF
- uses: actions/upload-artifact@v2
with:
name: "${{ github.sha }}-${{ matrix.part }}-coverage"
path: ./${{ matrix.part }}profile.out
upload-coverage-report:
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v2
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-00-coverage"
if: env.GIT_DIFF
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-01-coverage"
if: env.GIT_DIFF
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-02-coverage"
if: env.GIT_DIFF
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-03-coverage"
if: env.GIT_DIFF
- run: |
cat ./*profile.out | grep -v "mode: atomic" >> coverage.txt
if: env.GIT_DIFF
- name: filter out DONTCOVER
run: |
@ -121,24 +151,24 @@ jobs:
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
if: env.GIT_DIFF
- uses: codecov/codecov-action@v1.0.14
- uses: codecov/codecov-action@v1.0.13
with:
file: ./coverage.txt
if: env.GIT_DIFF
test-coverage-run-2:
test-race:
runs-on: ubuntu-latest
needs: split-test-files
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
part: ["00", "01", "02", "03"]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
PATTERNS: |
**/**.go
@ -146,235 +176,20 @@ jobs:
go.sum
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-ab"
name: "${{ github.sha }}-${{ matrix.part }}"
if: env.GIT_DIFF
- name: test & coverage report creation
run: |
cat xab.txt | xargs go test -mod=readonly -timeout 15m -coverprofile=coverage.txt -covermode=atomic -tags='norace ledger test_ledger_mock'
if: env.GIT_DIFF
- name: filter out DONTCOVER
run: |
excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')"
excludelist+=" $(find ./ -type f -name '*.pb.go')"
excludelist+=" $(find ./ -type f -path './tests/mocks/*.go')"
for filename in ${excludelist}; do
filename=$(echo $filename | sed 's/^./github.com\/cosmos\/cosmos-sdk/g')
echo "Excluding ${filename} from coverage report..."
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
if: env.GIT_DIFF
- uses: codecov/codecov-action@v1.0.14
with:
file: ./coverage.txt
if: env.GIT_DIFF
test-coverage-run-3:
runs-on: ubuntu-latest
needs: split-test-files
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-ac"
if: env.GIT_DIFF
- name: test & coverage report creation
run: |
cat xac.txt | xargs go test -mod=readonly -timeout 15m -coverprofile=coverage.txt -covermode=atomic -tags='norace ledger test_ledger_mock'
if: env.GIT_DIFF
- name: filter out DONTCOVER
run: |
excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')"
excludelist+=" $(find ./ -type f -name '*.pb.go')"
excludelist+=" $(find ./ -type f -path './tests/mocks/*.go')"
for filename in ${excludelist}; do
filename=$(echo $filename | sed 's/^./github.com\/cosmos\/cosmos-sdk/g')
echo "Excluding ${filename} from coverage report..."
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
if: env.GIT_DIFF
- uses: codecov/codecov-action@v1.0.14
with:
file: ./coverage.txt
if: env.GIT_DIFF
test-coverage-run-4:
runs-on: ubuntu-latest
needs: split-test-files
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-ad"
if: env.GIT_DIFF
- name: test & coverage report creation
run: |
cat xad.txt | xargs go test -mod=readonly -timeout 15m -coverprofile=coverage.txt -covermode=atomic -tags='norace ledger test_ledger_mock'
if: env.GIT_DIFF
- name: filter out DONTCOVER
run: |
excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER')"
excludelist+=" $(find ./ -type f -name '*.pb.go')"
excludelist+=" $(find ./ -type f -path './tests/mocks/*.go')"
for filename in ${excludelist}; do
filename=$(echo $filename | sed 's/^./github.com\/cosmos\/cosmos-sdk/g')
echo "Excluding ${filename} from coverage report..."
sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt
done
if: env.GIT_DIFF
- uses: codecov/codecov-action@v1.0.14
with:
file: ./coverage.txt
if: env.GIT_DIFF
test-race-1:
runs-on: ubuntu-latest
needs: split-test-files
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-aa"
if: env.GIT_DIFF
- name: Run tests with race detector
run: cat xaa.txt | xargs go test -mod=readonly -json -timeout 30m -race -tags='cgo ledger test_ledger_mock' > xaa-race-output.txt
cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -race -tags='cgo ledger test_ledger_mock' > ${{ matrix.part }}-race-output.txt
if: env.GIT_DIFF
- uses: actions/upload-artifact@v2
with:
name: "${{ github.sha }}-aa-race-output"
path: ./xaa-race-output.txt
test-race-2:
runs-on: ubuntu-latest
needs: split-test-files
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-ab"
if: env.GIT_DIFF
- name: Run tests with race detector
run: cat xab.txt | xargs go test -mod=readonly -json -timeout 30m -race -tags='cgo ledger test_ledger_mock' > xab-race-output.txt
if: env.GIT_DIFF
- uses: actions/upload-artifact@v2
with:
name: "${{ github.sha }}-ab-race-output"
path: ./xab-race-output.txt
test-race-3:
runs-on: ubuntu-latest
needs: split-test-files
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-ac"
if: env.GIT_DIFF
- name: Run tests with race detector
run: cat xac.txt | xargs go test -mod=readonly -json -timeout 30m -race -tags='cgo ledger test_ledger_mock' > xac-race-output.txt
if: env.GIT_DIFF
- uses: actions/upload-artifact@v2
with:
name: "${{ github.sha }}-ac-race-output"
path: ./xac-race-output.txt
test-race-4:
runs-on: ubuntu-latest
needs: split-test-files
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: 1.15
- name: Display go version
run: go version
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-ad"
if: env.GIT_DIFF
- name: Run tests with race detector
run: cat xad.txt | xargs go test -mod=readonly -json -timeout 30m -race -tags='cgo ledger test_ledger_mock' > xad-race-output.txt
if: env.GIT_DIFF
- uses: actions/upload-artifact@v2
with:
name: "${{ github.sha }}-ad-race-output"
path: ./xad-race-output.txt
name: "${{ github.sha }}-${{ matrix.part }}-race-output"
path: ./${{ matrix.part }}-race-output.txt
race-detector-report:
runs-on: ubuntu-latest
needs: [test-race-1, test-race-2, test-race-3, test-race-4, install-tparse]
needs: [test-race, install-tparse]
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
@ -387,19 +202,19 @@ jobs:
go.sum
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-aa-race-output"
name: "${{ github.sha }}-00-race-output"
if: env.GIT_DIFF
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-ab-race-output"
name: "${{ github.sha }}-01-race-output"
if: env.GIT_DIFF
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-ac-race-output"
name: "${{ github.sha }}-02-race-output"
if: env.GIT_DIFF
- uses: actions/download-artifact@v2
with:
name: "${{ github.sha }}-ad-race-output"
name: "${{ github.sha }}-03-race-output"
if: env.GIT_DIFF
- uses: actions/cache@v2.1.2
with:
@ -407,7 +222,7 @@ jobs:
key: ${{ runner.os }}-go-tparse-binary
if: env.GIT_DIFF
- name: Generate test report (go test -race)
run: cat xa*-race-output.txt | ~/go/bin/tparse
run: cat ./*-race-output.txt | ~/go/bin/tparse
if: env.GIT_DIFF
liveness-test:

View File

@ -23,8 +23,10 @@ func NewVersionCommand() *cobra.Command {
return nil
}
var bz []byte
var err error
var (
bz []byte
err error
)
output, _ := cmd.Flags().GetString(cli.OutputFlag)
switch strings.ToLower(output) {