From 782127334615ed5d07573fb67f6a2a4a9d096316 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Sun, 22 Oct 2023 13:52:54 -0400 Subject: [PATCH 01/16] Re-enable FOSSA scan and add CODECOV Signed-off-by: Matt Lord --- .github/workflows/static_checks_etc.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/static_checks_etc.yml b/.github/workflows/static_checks_etc.yml index 34714d00256..e9d423eabcb 100644 --- a/.github/workflows/static_checks_etc.yml +++ b/.github/workflows/static_checks_etc.yml @@ -33,6 +33,12 @@ jobs: if: steps.skip-workflow.outputs.skip-workflow == 'false' uses: actions/checkout@v3 + - name: Run FOSSA scan and upload build data + if: steps.skip-workflow.outputs.skip-workflow == 'false' + uses: fossa-contrib/fossa-action@v2 + with: + fossa-api-key: ${{secrets.fossaApiKey}} + - name: Check for changes in Go files if: steps.skip-workflow.outputs.skip-workflow == 'false' uses: frouioui/paths-filter@main @@ -214,3 +220,10 @@ jobs: echo "$output" echo "" exit 1 + + - name: Upload coverage reports to Codecov + timeout-minutes: 30 + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + From c661af585c17f5462705972e0e6d1db5c354a8ce Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Sun, 22 Oct 2023 13:56:57 -0400 Subject: [PATCH 02/16] Add codecov badge Signed-off-by: Matt Lord --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6f021141aca..c5bdb88d2ab 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.vitess/vitess-jdbc/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.vitess/vitess-jdbc) [![codebeat badge](https://codebeat.co/badges/51c9a056-1103-4522-9a9c-dc623821ea87)](https://codebeat.co/projects/github-com-youtube-vitess) +[![Coverage Status](https://codecov.io/gh/vitessio/vitess/branch/main/graph/badge.svg)](https://codecov.io/gh/vitessio/vitess) [![Go Report Card](https://goreportcard.com/badge/vitess.io/vitess)](https://goreportcard.com/report/vitess.io/vitess) [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fvitessio%2Fvitess.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fvitessio%2Fvitess?ref=badge_shield) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/1724/badge)](https://bestpractices.coreinfrastructure.org/projects/1724) From ca8d73a0c18f776b67232719742e1d6c6896a235 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Sun, 22 Oct 2023 14:12:25 -0400 Subject: [PATCH 03/16] Only run both on merges to main Signed-off-by: Matt Lord --- .github/workflows/static_checks_etc.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/static_checks_etc.yml b/.github/workflows/static_checks_etc.yml index e9d423eabcb..f4690c7d55f 100644 --- a/.github/workflows/static_checks_etc.yml +++ b/.github/workflows/static_checks_etc.yml @@ -34,7 +34,7 @@ jobs: uses: actions/checkout@v3 - name: Run FOSSA scan and upload build data - if: steps.skip-workflow.outputs.skip-workflow == 'false' + if: github.ref == 'refs/heads/main' uses: fossa-contrib/fossa-action@v2 with: fossa-api-key: ${{secrets.fossaApiKey}} @@ -222,6 +222,7 @@ jobs: exit 1 - name: Upload coverage reports to Codecov + if: github.ref == 'refs/heads/main' timeout-minutes: 30 uses: codecov/codecov-action@v3 env: From e6b1a141af9380f8f1e82e533c5c3c815d755aa1 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Sun, 22 Oct 2023 17:55:57 -0400 Subject: [PATCH 04/16] Changes form testing in my fork Signed-off-by: Matt Lord --- .github/workflows/codecov.yml | 132 ++++++++++++++++++++++++ .github/workflows/static_checks_etc.yml | 13 +-- Makefile | 5 +- 3 files changed, 139 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/codecov.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 00000000000..bda14f70cef --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,132 @@ +name: Code Coverage +on: [push] # only on merges to main +concurrency: + group: format('{0}-{1}', ${{ github.ref }}, 'Code Coverage') + cancel-in-progress: true + +permissions: read-all + +env: + GITHUB_PR_HEAD_SHA: "${{ github.event.pull_request.head.sha }}" + +jobs: + test: + name: Code Coverage + runs-on: ubuntu-latest + + steps: + - name: Skip workflow if it's not a merge to main + id: skip-workflow + run: | + skip='true' + if [[ "${{github.event.pull_request}}" == "" ]] && [[ "${{github.ref}}" == "refs/heads/main" ]]; then + skip='false' + fi + echo Skip ${skip} + echo "skip-workflow=${skip}" >> $GITHUB_OUTPUT + + - name: Check out code + if: steps.skip-workflow.outputs.skip-workflow == 'false' + uses: actions/checkout@v3 + + - name: Check for changes in relevant files + if: steps.skip-workflow.outputs.skip-workflow == 'false' + uses: frouioui/paths-filter@main + id: changes + with: + token: '' + filters: | + unit_tests: + - 'go/**' + - 'test.go' + - 'Makefile' + - 'build.env' + - 'go.sum' + - 'go.mod' + - 'proto/*.proto' + - 'tools/**' + - 'config/**' + - 'bootstrap.sh' + - '.github/workflows/unit_test_mysql80.yml' + + - name: Set up Go + if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' + uses: actions/setup-go@v4 + with: + go-version: 1.21.3 + + - name: Set up python + if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' + uses: actions/setup-python@v4 + + - name: Tune the OS + if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' + run: | + sudo sysctl -w net.ipv4.ip_local_port_range="22768 65535" + # Increase the asynchronous non-blocking I/O. More information at https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_use_native_aio + echo "fs.aio-max-nr = 1048576" | sudo tee -a /etc/sysctl.conf + sudo sysctl -p /etc/sysctl.conf + + - name: Get dependencies + if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' + run: | + export DEBIAN_FRONTEND="noninteractive" + sudo apt-get update + + # Uninstall any previously installed MySQL first + sudo systemctl stop apparmor + sudo DEBIAN_FRONTEND="noninteractive" apt-get remove -y --purge mysql-server mysql-client mysql-common + sudo apt-get -y autoremove + sudo apt-get -y autoclean + sudo deluser mysql + sudo rm -rf /var/lib/mysql + sudo rm -rf /etc/mysql + + # Get key to latest MySQL repo + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29 + + # mysql80 + wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.24-1_all.deb + echo mysql-apt-config mysql-apt-config/select-server select mysql-8.0 | sudo debconf-set-selections + sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config* + sudo apt-get update + sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y mysql-server mysql-client + + sudo apt-get install -y make unzip g++ curl git wget ant openjdk-11-jdk eatmydata + sudo service mysql stop + sudo bash -c "echo '/usr/sbin/mysqld { }' > /etc/apparmor.d/usr.sbin.mysqld" # https://bugs.launchpad.net/ubuntu/+source/mariadb-10.1/+bug/1806263 + sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ + sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld || echo "could not remove mysqld profile" + + mkdir -p dist bin + curl -L https://github.com/coreos/etcd/releases/download/v3.3.10/etcd-v3.3.10-linux-amd64.tar.gz | tar -zxC dist + mv dist/etcd-v3.3.10-linux-amd64/{etcd,etcdctl} bin/ + + go mod download + go install golang.org/x/tools/cmd/goimports@latest + + # install JUnit report formatter + go install github.com/vitessio/go-junit-report@HEAD + + - name: Run make tools + if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' + run: | + make tools + + - name: Run unit tests and generate code coverage reports + if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' + timeout-minutes: 60 + run: | + set -exo pipefail + # We set the VTDATAROOT to the /tmp folder to reduce the file path of mysql.sock file + # which musn't be more than 107 characters long. + export VTDATAROOT="/tmp/" + + export NOVTADMINBUILD=1 + eatmydata -- make unit_test_cover + + - name: Upload coverage reports to codecov.io + if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/static_checks_etc.yml b/.github/workflows/static_checks_etc.yml index f4690c7d55f..d028b6f62d6 100644 --- a/.github/workflows/static_checks_etc.yml +++ b/.github/workflows/static_checks_etc.yml @@ -34,6 +34,11 @@ jobs: uses: actions/checkout@v3 - name: Run FOSSA scan and upload build data + # Fails on pull requests when using the API key secret. + # In order to run it on pull requests we would need to + # generate a push only token and specify that as plain + # text here: + # https://github.com/fossa-contrib/fossa-action#push-only-api-token if: github.ref == 'refs/heads/main' uses: fossa-contrib/fossa-action@v2 with: @@ -220,11 +225,3 @@ jobs: echo "$output" echo "" exit 1 - - - name: Upload coverage reports to Codecov - if: github.ref == 'refs/heads/main' - timeout-minutes: 30 - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - diff --git a/Makefile b/Makefile index 4eca82e0fc9..6e1a1f8fa3d 100644 --- a/Makefile +++ b/Makefile @@ -214,10 +214,9 @@ e2e_test: build go test $(VT_GO_PARALLEL) ./go/.../endtoend/... # Run the code coverage tools, compute aggregate. -# If you want to improve in a directory, run: -# go test -coverprofile=coverage.out && go tool cover -html=coverage.out unit_test_cover: build - go test $(VT_GO_PARALLEL) -cover ./go/... | misc/parse_cover.py + go test -coverprofile=coverage.out ./go/... || true + go tool cover -html=coverage.out || true unit_test_race: build dependency_check tools/unit_test_race.sh From 850fbbe1a8194fdb292abbecdd5e718bd1855f3b Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Sun, 22 Oct 2023 19:32:06 -0400 Subject: [PATCH 05/16] More updates from testing Signed-off-by: Matt Lord --- .github/workflows/codecov.yml | 3 --- Makefile | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index bda14f70cef..ebdfa68501e 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -105,9 +105,6 @@ jobs: go mod download go install golang.org/x/tools/cmd/goimports@latest - # install JUnit report formatter - go install github.com/vitessio/go-junit-report@HEAD - - name: Run make tools if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' run: | diff --git a/Makefile b/Makefile index 6e1a1f8fa3d..a54dedb05ed 100644 --- a/Makefile +++ b/Makefile @@ -214,7 +214,8 @@ e2e_test: build go test $(VT_GO_PARALLEL) ./go/.../endtoend/... # Run the code coverage tools, compute aggregate. -unit_test_cover: build +unit_test_cover: build dependency_check demo + source build.env go test -coverprofile=coverage.out ./go/... || true go tool cover -html=coverage.out || true From f9e6695b92ededff3793f3d0eddbfa846c92e448 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Sun, 22 Oct 2023 20:16:56 -0400 Subject: [PATCH 06/16] Exclude endtoend tests from coverage report Signed-off-by: Matt Lord --- .github/workflows/codecov.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index ebdfa68501e..6558925fd32 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -120,6 +120,8 @@ jobs: export VTDATAROOT="/tmp/" export NOVTADMINBUILD=1 + # Exclude endtoend tests from the coverage report. + rm -rf go/test/endtoend eatmydata -- make unit_test_cover - name: Upload coverage reports to codecov.io From 26445bd068fa0923bbe33080e71a254e016abbf9 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Sun, 22 Oct 2023 20:56:29 -0400 Subject: [PATCH 07/16] Workflow tweaks Signed-off-by: Matt Lord --- .github/workflows/codecov.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 6558925fd32..7f52cfd7eb9 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -1,5 +1,8 @@ name: Code Coverage -on: [push] # only on merges to main +on: # only on merges to main + push: + branches: + - main concurrency: group: format('{0}-{1}', ${{ github.ref }}, 'Code Coverage') cancel-in-progress: true @@ -112,7 +115,7 @@ jobs: - name: Run unit tests and generate code coverage reports if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' - timeout-minutes: 60 + timeout-minutes: 45 run: | set -exo pipefail # We set the VTDATAROOT to the /tmp folder to reduce the file path of mysql.sock file From 4b61418974da7e0ef9dd7127b025219f08cb8ec6 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Mon, 23 Oct 2023 12:44:31 -0400 Subject: [PATCH 08/16] Tidy up workflow yaml Signed-off-by: Matt Lord --- .github/workflows/codecov.yml | 48 +++++++++-------------------------- 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 7f52cfd7eb9..6ffb790305c 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -1,69 +1,45 @@ name: Code Coverage -on: # only on merges to main +on: push: branches: - main + pull_request: concurrency: group: format('{0}-{1}', ${{ github.ref }}, 'Code Coverage') cancel-in-progress: true permissions: read-all -env: - GITHUB_PR_HEAD_SHA: "${{ github.event.pull_request.head.sha }}" - jobs: test: name: Code Coverage - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - - name: Skip workflow if it's not a merge to main - id: skip-workflow - run: | - skip='true' - if [[ "${{github.event.pull_request}}" == "" ]] && [[ "${{github.ref}}" == "refs/heads/main" ]]; then - skip='false' - fi - echo Skip ${skip} - echo "skip-workflow=${skip}" >> $GITHUB_OUTPUT - - name: Check out code - if: steps.skip-workflow.outputs.skip-workflow == 'false' uses: actions/checkout@v3 - - name: Check for changes in relevant files - if: steps.skip-workflow.outputs.skip-workflow == 'false' + - name: Check for changes in files relevant to code coverage uses: frouioui/paths-filter@main id: changes with: token: '' filters: | - unit_tests: + go_files: - 'go/**' - - 'test.go' - - 'Makefile' - - 'build.env' - - 'go.sum' - - 'go.mod' - - 'proto/*.proto' - - 'tools/**' - - 'config/**' - - 'bootstrap.sh' - - '.github/workflows/unit_test_mysql80.yml' - name: Set up Go - if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' + if: steps.changes.outputs.go_files == 'true' uses: actions/setup-go@v4 with: go-version: 1.21.3 - name: Set up python - if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' + if: steps.changes.outputs.go_files == 'true' uses: actions/setup-python@v4 - name: Tune the OS - if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' + if: steps.changes.outputs.go_files == 'true' run: | sudo sysctl -w net.ipv4.ip_local_port_range="22768 65535" # Increase the asynchronous non-blocking I/O. More information at https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_use_native_aio @@ -71,7 +47,7 @@ jobs: sudo sysctl -p /etc/sysctl.conf - name: Get dependencies - if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' + if: steps.changes.outputs.go_files == 'true' run: | export DEBIAN_FRONTEND="noninteractive" sudo apt-get update @@ -109,12 +85,12 @@ jobs: go install golang.org/x/tools/cmd/goimports@latest - name: Run make tools - if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' + if: steps.changes.outputs.go_files == 'true' run: | make tools - name: Run unit tests and generate code coverage reports - if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' + if: steps.changes.outputs.go_files == 'true' timeout-minutes: 45 run: | set -exo pipefail @@ -128,7 +104,7 @@ jobs: eatmydata -- make unit_test_cover - name: Upload coverage reports to codecov.io - if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.unit_tests == 'true' + if: steps.changes.outputs.go_files == 'true' uses: codecov/codecov-action@v3 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} From 3e9fcd052064ad884e5e2d602223130d4c85cb32 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Fri, 5 Jan 2024 13:42:33 -0500 Subject: [PATCH 09/16] Update yaml Signed-off-by: Matt Lord --- .github/workflows/codecov.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 6ffb790305c..8753980fea0 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -32,7 +32,7 @@ jobs: if: steps.changes.outputs.go_files == 'true' uses: actions/setup-go@v4 with: - go-version: 1.21.3 + go-version: 1.21.5 - name: Set up python if: steps.changes.outputs.go_files == 'true' @@ -62,10 +62,10 @@ jobs: sudo rm -rf /etc/mysql # Get key to latest MySQL repo - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29 + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A8D3785C # mysql80 - wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.24-1_all.deb + wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.29-1_all.deb echo mysql-apt-config mysql-apt-config/select-server select mysql-8.0 | sudo debconf-set-selections sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config* sudo apt-get update From e873dff767b221b91dcd83c94327f4b370a94eb3 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Fri, 5 Jan 2024 14:08:57 -0500 Subject: [PATCH 10/16] Run on all pushes and PRs Signed-off-by: Matt Lord --- .github/workflows/codecov.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 8753980fea0..3d006882db9 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -1,9 +1,5 @@ name: Code Coverage -on: - push: - branches: - - main - pull_request: +on: [push, pull_request] concurrency: group: format('{0}-{1}', ${{ github.ref }}, 'Code Coverage') cancel-in-progress: true From a3acbca6aec637d209f208d893e8876d39b7dc8d Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Fri, 5 Jan 2024 14:12:16 -0500 Subject: [PATCH 11/16] Trigger code coverage Signed-off-by: Matt Lord --- go/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/go/README.md b/go/README.md index fc6efdde602..6f9ca0421e6 100644 --- a/go/README.md +++ b/go/README.md @@ -1,3 +1,5 @@ +# README + This directory contains all the Go code for Vitess. Most of the packages at the top level are general-purpose and are suitable @@ -16,4 +18,3 @@ import ( topodatapb "vitess.io/vitess/go/vt/proto/topodata" ) ``` - From 5f8e99cf72fdaaa660ac83de660043b23860544e Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Fri, 5 Jan 2024 14:23:47 -0500 Subject: [PATCH 12/16] Some unit tests require the e2e test packages Signed-off-by: Matt Lord --- .github/workflows/codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 3d006882db9..4cd1984509d 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -96,7 +96,7 @@ jobs: export NOVTADMINBUILD=1 # Exclude endtoend tests from the coverage report. - rm -rf go/test/endtoend + # rm -rf go/test/endtoend eatmydata -- make unit_test_cover - name: Upload coverage reports to codecov.io From 74dbeb1f1a08e3035cc505c983f403a1bd5ed80e Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Fri, 5 Jan 2024 14:56:37 -0500 Subject: [PATCH 13/16] Reduce disk space needed for unit tests Signed-off-by: Matt Lord --- .github/workflows/codecov.yml | 3 +-- Makefile | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 4cd1984509d..b44b87ebcb0 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -95,8 +95,7 @@ jobs: export VTDATAROOT="/tmp/" export NOVTADMINBUILD=1 - # Exclude endtoend tests from the coverage report. - # rm -rf go/test/endtoend + eatmydata -- make unit_test_cover - name: Upload coverage reports to codecov.io diff --git a/Makefile b/Makefile index 79808b21cf2..56f7c7d7522 100644 --- a/Makefile +++ b/Makefile @@ -216,8 +216,8 @@ e2e_test: build # Run the code coverage tools, compute aggregate. unit_test_cover: build dependency_check demo source build.env - go test -coverprofile=coverage.out ./go/... || true - go tool cover -html=coverage.out || true + go test $(VT_GO_PARALLEL) -count=1 -coverprofile=coverage.out ./go/... + go tool $(VT_GO_PARALLEL) cover -html=coverage.out unit_test_race: build dependency_check tools/unit_test_race.sh From c7ff74717eaafda9e9736efa05edd8dd0e3a3498 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Fri, 5 Jan 2024 15:22:57 -0500 Subject: [PATCH 14/16] Try again to NOT run any e2e tests as they fill up the disk Signed-off-by: Matt Lord --- .github/workflows/codecov.yml | 3 +++ Makefile | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index b44b87ebcb0..ffc11ab8d98 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -96,6 +96,9 @@ jobs: export NOVTADMINBUILD=1 + # Exclude endtoend tests from the coverage report. + rm -rf go/test/endtoend go/*/endtoend go/vt/*/endtoend go/cmd/vttestserver + eatmydata -- make unit_test_cover - name: Upload coverage reports to codecov.io diff --git a/Makefile b/Makefile index 56f7c7d7522..6e6fd0fcd2d 100644 --- a/Makefile +++ b/Makefile @@ -216,7 +216,8 @@ e2e_test: build # Run the code coverage tools, compute aggregate. unit_test_cover: build dependency_check demo source build.env - go test $(VT_GO_PARALLEL) -count=1 -coverprofile=coverage.out ./go/... + # Prevent a flaky unit test from blocking the report. + go test $(VT_GO_PARALLEL) -count=1 -coverprofile=coverage.out ./go/... || true go tool $(VT_GO_PARALLEL) cover -html=coverage.out unit_test_race: build dependency_check From 94576cde737cf4a4bf25fa3eaf641084be5431cc Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Fri, 5 Jan 2024 17:15:47 -0500 Subject: [PATCH 15/16] Deal with go tool cover issue Signed-off-by: Matt Lord --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6e6fd0fcd2d..985d3bd5150 100644 --- a/Makefile +++ b/Makefile @@ -216,8 +216,11 @@ e2e_test: build # Run the code coverage tools, compute aggregate. unit_test_cover: build dependency_check demo source build.env - # Prevent a flaky unit test from blocking the report. - go test $(VT_GO_PARALLEL) -count=1 -coverprofile=coverage.out ./go/... || true + go test $(VT_GO_PARALLEL) -count=1 -coverprofile=coverage.out ./go/... + # Handle go tool cover failures due to not handling `//line` directives, which + # the goyacc compiler adds to the generated parser in sql.go. See: + # https://github.com/golang/go/issues/41222 + sed -i'' -e '/^vitess.io\/vitess\/go\/vt\/sqlparser\/yaccpar/d' coverage.out go tool $(VT_GO_PARALLEL) cover -html=coverage.out unit_test_race: build dependency_check From 346b17e6a79c5a2f87ea7c17fa22a571ca6f34b4 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Mon, 8 Jan 2024 11:45:33 -0500 Subject: [PATCH 16/16] Address review feedback Signed-off-by: Matt Lord --- .github/workflows/codecov.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index ffc11ab8d98..769d8216715 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -21,21 +21,25 @@ jobs: with: token: '' filters: | - go_files: + changed_files: + - .github/workflows/codecov.yml - 'go/**' + - go.mod + - go.sum + - Makefile - name: Set up Go - if: steps.changes.outputs.go_files == 'true' + if: steps.changes.outputs.changed_files == 'true' uses: actions/setup-go@v4 with: go-version: 1.21.5 - name: Set up python - if: steps.changes.outputs.go_files == 'true' + if: steps.changes.outputs.changed_files == 'true' uses: actions/setup-python@v4 - name: Tune the OS - if: steps.changes.outputs.go_files == 'true' + if: steps.changes.outputs.changed_files == 'true' run: | sudo sysctl -w net.ipv4.ip_local_port_range="22768 65535" # Increase the asynchronous non-blocking I/O. More information at https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_use_native_aio @@ -43,7 +47,7 @@ jobs: sudo sysctl -p /etc/sysctl.conf - name: Get dependencies - if: steps.changes.outputs.go_files == 'true' + if: steps.changes.outputs.changed_files == 'true' run: | export DEBIAN_FRONTEND="noninteractive" sudo apt-get update @@ -81,12 +85,12 @@ jobs: go install golang.org/x/tools/cmd/goimports@latest - name: Run make tools - if: steps.changes.outputs.go_files == 'true' + if: steps.changes.outputs.changed_files == 'true' run: | make tools - name: Run unit tests and generate code coverage reports - if: steps.changes.outputs.go_files == 'true' + if: steps.changes.outputs.changed_files == 'true' timeout-minutes: 45 run: | set -exo pipefail @@ -97,12 +101,13 @@ jobs: export NOVTADMINBUILD=1 # Exclude endtoend tests from the coverage report. + # TODO: figure out how best to include our endtoend tests in the coverage report. rm -rf go/test/endtoend go/*/endtoend go/vt/*/endtoend go/cmd/vttestserver eatmydata -- make unit_test_cover - name: Upload coverage reports to codecov.io - if: steps.changes.outputs.go_files == 'true' + if: steps.changes.outputs.changed_files == 'true' uses: codecov/codecov-action@v3 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}