diff --git a/.github/docker/cluster_test_vreplication_basic/Dockerfile b/.github/docker/cluster_test_vreplication_basic/Dockerfile index 603c3240e30..f246f980168 100644 --- a/.github/docker/cluster_test_vreplication_basic/Dockerfile +++ b/.github/docker/cluster_test_vreplication_basic/Dockerfile @@ -35,5 +35,8 @@ ENV VTDATAROOT /vt/vtdataroot # create the vtdataroot directory RUN mkdir -p $VTDATAROOT - # sleep for 50 minutes +# install goimports +RUN go install golang.org/x/tools/cmd/goimports@latest + +# sleep for 50 minutes CMD sleep 3000 \ No newline at end of file diff --git a/.github/docker/cluster_test_vreplication_cellalias/Dockerfile b/.github/docker/cluster_test_vreplication_cellalias/Dockerfile index 603c3240e30..f246f980168 100644 --- a/.github/docker/cluster_test_vreplication_cellalias/Dockerfile +++ b/.github/docker/cluster_test_vreplication_cellalias/Dockerfile @@ -35,5 +35,8 @@ ENV VTDATAROOT /vt/vtdataroot # create the vtdataroot directory RUN mkdir -p $VTDATAROOT - # sleep for 50 minutes +# install goimports +RUN go install golang.org/x/tools/cmd/goimports@latest + +# sleep for 50 minutes CMD sleep 3000 \ No newline at end of file diff --git a/.github/docker/cluster_test_vreplication_multicell/Dockerfile b/.github/docker/cluster_test_vreplication_multicell/Dockerfile index 603c3240e30..f246f980168 100644 --- a/.github/docker/cluster_test_vreplication_multicell/Dockerfile +++ b/.github/docker/cluster_test_vreplication_multicell/Dockerfile @@ -35,5 +35,8 @@ ENV VTDATAROOT /vt/vtdataroot # create the vtdataroot directory RUN mkdir -p $VTDATAROOT - # sleep for 50 minutes +# install goimports +RUN go install golang.org/x/tools/cmd/goimports@latest + +# sleep for 50 minutes CMD sleep 3000 \ No newline at end of file diff --git a/.github/docker/cluster_test_vreplication_v2/Dockerfile b/.github/docker/cluster_test_vreplication_v2/Dockerfile index 603c3240e30..f246f980168 100644 --- a/.github/docker/cluster_test_vreplication_v2/Dockerfile +++ b/.github/docker/cluster_test_vreplication_v2/Dockerfile @@ -35,5 +35,8 @@ ENV VTDATAROOT /vt/vtdataroot # create the vtdataroot directory RUN mkdir -p $VTDATAROOT - # sleep for 50 minutes +# install goimports +RUN go install golang.org/x/tools/cmd/goimports@latest + +# sleep for 50 minutes CMD sleep 3000 \ No newline at end of file diff --git a/.github/docker/unit_test_mariadb103/Dockerfile b/.github/docker/unit_test_mariadb103/Dockerfile index 0ebc71fbaf9..e35e4e14152 100644 --- a/.github/docker/unit_test_mariadb103/Dockerfile +++ b/.github/docker/unit_test_mariadb103/Dockerfile @@ -27,8 +27,11 @@ ENV VTDATAROOT /vt/vtdataroot # create the vtdataroot directory RUN mkdir -p $VTDATAROOT +# install goimports +RUN go install golang.org/x/tools/cmd/goimports@latest + # make tools RUN make tools - # sleep for 50 minutes +# sleep for 50 minutes CMD sleep 3000 \ No newline at end of file diff --git a/.github/docker/unit_test_mysql57/Dockerfile b/.github/docker/unit_test_mysql57/Dockerfile index 61e43e741b6..15f5d6b2027 100644 --- a/.github/docker/unit_test_mysql57/Dockerfile +++ b/.github/docker/unit_test_mysql57/Dockerfile @@ -27,8 +27,11 @@ ENV VTDATAROOT /vt/vtdataroot # create the vtdataroot directory RUN mkdir -p $VTDATAROOT +# install goimports +RUN go install golang.org/x/tools/cmd/goimports@latest + # make tools RUN make tools - # sleep for 50 minutes +# sleep for 50 minutes CMD sleep 3000 \ No newline at end of file diff --git a/.github/workflows/check_formatting.yml b/.github/workflows/check_formatting.yml index a191afa76fa..c4bc9841673 100644 --- a/.github/workflows/check_formatting.yml +++ b/.github/workflows/check_formatting.yml @@ -1,5 +1,5 @@ name: check_formatting -on: [pull_request] +on: [pull_request,push] jobs: build: @@ -8,7 +8,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/check_imports.yml b/.github/workflows/check_imports.yml new file mode 100644 index 00000000000..85aad83c80e --- /dev/null +++ b/.github/workflows/check_imports.yml @@ -0,0 +1,25 @@ +name: check_imports +on: [pull_request,push] +jobs: + + build: + name: Check Imports + runs-on: ubuntu-latest + steps: + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.17 + + - name: Check out code + uses: actions/checkout@v2 + + - name: Install goimports + run: | + go install golang.org/x/tools/cmd/goimports@latest + + - name: Run goimports + run: | + out=$(goimports -local vitess.io/vitess -l -w $(find . -name "*.go" | grep -v ".pb.go")) + echo $out | grep go > /dev/null && echo -e "The following files are malformatted:\n$out" && exit 1 || echo "All the files are formatted correctly" diff --git a/.github/workflows/check_make_parser.yml b/.github/workflows/check_make_parser.yml index 6506878a407..9151669ac5c 100644 --- a/.github/workflows/check_make_parser.yml +++ b/.github/workflows/check_make_parser.yml @@ -8,7 +8,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/check_make_sizegen.yml b/.github/workflows/check_make_sizegen.yml index 3e4d08fbc8b..19ec9bd5638 100644 --- a/.github/workflows/check_make_sizegen.yml +++ b/.github/workflows/check_make_sizegen.yml @@ -8,7 +8,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 @@ -34,6 +34,7 @@ jobs: sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld go mod download + go install golang.org/x/tools/cmd/goimports@latest - name: Run make minimaltools run: | diff --git a/.github/workflows/check_make_visitor.yml b/.github/workflows/check_make_visitor.yml index 9cb0aac0551..fea9ac87e97 100644 --- a/.github/workflows/check_make_visitor.yml +++ b/.github/workflows/check_make_visitor.yml @@ -8,7 +8,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_11.yml b/.github/workflows/cluster_endtoend_11.yml index debbe8207c0..21f3c3cf48e 100644 --- a/.github/workflows/cluster_endtoend_11.yml +++ b/.github/workflows/cluster_endtoend_11.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_12.yml b/.github/workflows/cluster_endtoend_12.yml index 61173a3c4f9..1d5838b3207 100644 --- a/.github/workflows/cluster_endtoend_12.yml +++ b/.github/workflows/cluster_endtoend_12.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_13.yml b/.github/workflows/cluster_endtoend_13.yml index 0e23d2d6819..2fb8443620d 100644 --- a/.github/workflows/cluster_endtoend_13.yml +++ b/.github/workflows/cluster_endtoend_13.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_14.yml b/.github/workflows/cluster_endtoend_14.yml index 57170a068de..a6db467729b 100644 --- a/.github/workflows/cluster_endtoend_14.yml +++ b/.github/workflows/cluster_endtoend_14.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_15.yml b/.github/workflows/cluster_endtoend_15.yml index cdcd68486c6..bc05a63b58c 100644 --- a/.github/workflows/cluster_endtoend_15.yml +++ b/.github/workflows/cluster_endtoend_15.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_16.yml b/.github/workflows/cluster_endtoend_16.yml index 187728bf257..2bf1abd8eab 100644 --- a/.github/workflows/cluster_endtoend_16.yml +++ b/.github/workflows/cluster_endtoend_16.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_17.yml b/.github/workflows/cluster_endtoend_17.yml index 8eb67601454..d72d1f3324a 100644 --- a/.github/workflows/cluster_endtoend_17.yml +++ b/.github/workflows/cluster_endtoend_17.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_18.yml b/.github/workflows/cluster_endtoend_18.yml index 61efb160f98..8c3b4916d78 100644 --- a/.github/workflows/cluster_endtoend_18.yml +++ b/.github/workflows/cluster_endtoend_18.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_19.yml b/.github/workflows/cluster_endtoend_19.yml index 14e25bd3805..e317e23484f 100644 --- a/.github/workflows/cluster_endtoend_19.yml +++ b/.github/workflows/cluster_endtoend_19.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_20.yml b/.github/workflows/cluster_endtoend_20.yml index 0d12c6cf3f1..6ec1e4d29cd 100644 --- a/.github/workflows/cluster_endtoend_20.yml +++ b/.github/workflows/cluster_endtoend_20.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_21.yml b/.github/workflows/cluster_endtoend_21.yml index 47416c295f6..5f903e2ab9d 100644 --- a/.github/workflows/cluster_endtoend_21.yml +++ b/.github/workflows/cluster_endtoend_21.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_22.yml b/.github/workflows/cluster_endtoend_22.yml index 1e732196d70..64a987ec5e0 100644 --- a/.github/workflows/cluster_endtoend_22.yml +++ b/.github/workflows/cluster_endtoend_22.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_23.yml b/.github/workflows/cluster_endtoend_23.yml index 86a0a7e8f17..514d4f9c1db 100644 --- a/.github/workflows/cluster_endtoend_23.yml +++ b/.github/workflows/cluster_endtoend_23.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_24.yml b/.github/workflows/cluster_endtoend_24.yml index 822436ed637..15beb6ae4ed 100644 --- a/.github/workflows/cluster_endtoend_24.yml +++ b/.github/workflows/cluster_endtoend_24.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_26.yml b/.github/workflows/cluster_endtoend_26.yml index 95546aa9e66..dcbbe655ee5 100644 --- a/.github/workflows/cluster_endtoend_26.yml +++ b/.github/workflows/cluster_endtoend_26.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_mysql80.yml b/.github/workflows/cluster_endtoend_mysql80.yml index 70f88c7da3a..b6a4e6baeb6 100644 --- a/.github/workflows/cluster_endtoend_mysql80.yml +++ b/.github/workflows/cluster_endtoend_mysql80.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_onlineddl_declarative.yml b/.github/workflows/cluster_endtoend_onlineddl_declarative.yml index 45809895f38..63c4090a776 100644 --- a/.github/workflows/cluster_endtoend_onlineddl_declarative.yml +++ b/.github/workflows/cluster_endtoend_onlineddl_declarative.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_onlineddl_ghost.yml b/.github/workflows/cluster_endtoend_onlineddl_ghost.yml index 6f343511668..d02299b03d2 100644 --- a/.github/workflows/cluster_endtoend_onlineddl_ghost.yml +++ b/.github/workflows/cluster_endtoend_onlineddl_ghost.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_onlineddl_revert.yml b/.github/workflows/cluster_endtoend_onlineddl_revert.yml index 66607f5c59a..d678c1effc8 100644 --- a/.github/workflows/cluster_endtoend_onlineddl_revert.yml +++ b/.github/workflows/cluster_endtoend_onlineddl_revert.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_onlineddl_singleton.yml b/.github/workflows/cluster_endtoend_onlineddl_singleton.yml index e623f201186..a5ea7a1a415 100644 --- a/.github/workflows/cluster_endtoend_onlineddl_singleton.yml +++ b/.github/workflows/cluster_endtoend_onlineddl_singleton.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_onlineddl_vrepl.yml b/.github/workflows/cluster_endtoend_onlineddl_vrepl.yml index 769740d54ee..9b9d55956f4 100644 --- a/.github/workflows/cluster_endtoend_onlineddl_vrepl.yml +++ b/.github/workflows/cluster_endtoend_onlineddl_vrepl.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_onlineddl_vrepl_stress.yml b/.github/workflows/cluster_endtoend_onlineddl_vrepl_stress.yml index b5fa182cb7a..c9e801493d4 100644 --- a/.github/workflows/cluster_endtoend_onlineddl_vrepl_stress.yml +++ b/.github/workflows/cluster_endtoend_onlineddl_vrepl_stress.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_onlineddl_vrepl_stress_suite.yml b/.github/workflows/cluster_endtoend_onlineddl_vrepl_stress_suite.yml index 69977d64f30..e3c8f6895c7 100644 --- a/.github/workflows/cluster_endtoend_onlineddl_vrepl_stress_suite.yml +++ b/.github/workflows/cluster_endtoend_onlineddl_vrepl_stress_suite.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_onlineddl_vrepl_suite.yml b/.github/workflows/cluster_endtoend_onlineddl_vrepl_suite.yml index c07fabb334e..7b3d43bab2e 100644 --- a/.github/workflows/cluster_endtoend_onlineddl_vrepl_suite.yml +++ b/.github/workflows/cluster_endtoend_onlineddl_vrepl_suite.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_resharding.yml b/.github/workflows/cluster_endtoend_resharding.yml index 3c32f1829b2..0149df68077 100644 --- a/.github/workflows/cluster_endtoend_resharding.yml +++ b/.github/workflows/cluster_endtoend_resharding.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_resharding_bytes.yml b/.github/workflows/cluster_endtoend_resharding_bytes.yml index 979b2779de8..d671e60b552 100644 --- a/.github/workflows/cluster_endtoend_resharding_bytes.yml +++ b/.github/workflows/cluster_endtoend_resharding_bytes.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_tabletmanager_tablegc.yml b/.github/workflows/cluster_endtoend_tabletmanager_tablegc.yml index d894eb09566..b005da30ea6 100644 --- a/.github/workflows/cluster_endtoend_tabletmanager_tablegc.yml +++ b/.github/workflows/cluster_endtoend_tabletmanager_tablegc.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_tabletmanager_throttler.yml b/.github/workflows/cluster_endtoend_tabletmanager_throttler.yml index 1afadb07768..c083232c9b6 100644 --- a/.github/workflows/cluster_endtoend_tabletmanager_throttler.yml +++ b/.github/workflows/cluster_endtoend_tabletmanager_throttler.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_tabletmanager_throttler_custom_config.yml b/.github/workflows/cluster_endtoend_tabletmanager_throttler_custom_config.yml index af4956b3f52..5bc723b463f 100644 --- a/.github/workflows/cluster_endtoend_tabletmanager_throttler_custom_config.yml +++ b/.github/workflows/cluster_endtoend_tabletmanager_throttler_custom_config.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_upgrade.yml b/.github/workflows/cluster_endtoend_upgrade.yml index 087f7436062..9ea8929d422 100644 --- a/.github/workflows/cluster_endtoend_upgrade.yml +++ b/.github/workflows/cluster_endtoend_upgrade.yml @@ -46,7 +46,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vreplication_migrate.yml b/.github/workflows/cluster_endtoend_vreplication_migrate.yml index 9e0d4065431..a656823db23 100644 --- a/.github/workflows/cluster_endtoend_vreplication_migrate.yml +++ b/.github/workflows/cluster_endtoend_vreplication_migrate.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vstream_failover.yml b/.github/workflows/cluster_endtoend_vstream_failover.yml index 82ef74998e4..56115d51214 100644 --- a/.github/workflows/cluster_endtoend_vstream_failover.yml +++ b/.github/workflows/cluster_endtoend_vstream_failover.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vstream_stoponreshard_false.yml b/.github/workflows/cluster_endtoend_vstream_stoponreshard_false.yml index 4394525ce87..9a193bb2a96 100644 --- a/.github/workflows/cluster_endtoend_vstream_stoponreshard_false.yml +++ b/.github/workflows/cluster_endtoend_vstream_stoponreshard_false.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vstream_stoponreshard_true.yml b/.github/workflows/cluster_endtoend_vstream_stoponreshard_true.yml index 3bc82eb400f..3dbad9823a5 100644 --- a/.github/workflows/cluster_endtoend_vstream_stoponreshard_true.yml +++ b/.github/workflows/cluster_endtoend_vstream_stoponreshard_true.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vtgate_buffer.yml b/.github/workflows/cluster_endtoend_vtgate_buffer.yml index fb3843dc24c..29e3f845e1c 100644 --- a/.github/workflows/cluster_endtoend_vtgate_buffer.yml +++ b/.github/workflows/cluster_endtoend_vtgate_buffer.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vtgate_concurrentdml.yml b/.github/workflows/cluster_endtoend_vtgate_concurrentdml.yml index 9f68c8b2a1b..90712891475 100644 --- a/.github/workflows/cluster_endtoend_vtgate_concurrentdml.yml +++ b/.github/workflows/cluster_endtoend_vtgate_concurrentdml.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vtgate_gen4.yml b/.github/workflows/cluster_endtoend_vtgate_gen4.yml index ce7f30c3778..57c85ab93b3 100644 --- a/.github/workflows/cluster_endtoend_vtgate_gen4.yml +++ b/.github/workflows/cluster_endtoend_vtgate_gen4.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vtgate_readafterwrite.yml b/.github/workflows/cluster_endtoend_vtgate_readafterwrite.yml index 4a6c0d743c4..8c41648c6f1 100644 --- a/.github/workflows/cluster_endtoend_vtgate_readafterwrite.yml +++ b/.github/workflows/cluster_endtoend_vtgate_readafterwrite.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vtgate_reservedconn.yml b/.github/workflows/cluster_endtoend_vtgate_reservedconn.yml index 3cbb89849a5..046fd3119d2 100644 --- a/.github/workflows/cluster_endtoend_vtgate_reservedconn.yml +++ b/.github/workflows/cluster_endtoend_vtgate_reservedconn.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vtgate_schema.yml b/.github/workflows/cluster_endtoend_vtgate_schema.yml index f253af5fa1c..8d090bb1a80 100644 --- a/.github/workflows/cluster_endtoend_vtgate_schema.yml +++ b/.github/workflows/cluster_endtoend_vtgate_schema.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vtgate_topo.yml b/.github/workflows/cluster_endtoend_vtgate_topo.yml index c98d48679cc..a978ab484f2 100644 --- a/.github/workflows/cluster_endtoend_vtgate_topo.yml +++ b/.github/workflows/cluster_endtoend_vtgate_topo.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vtgate_transaction.yml b/.github/workflows/cluster_endtoend_vtgate_transaction.yml index 9819f3cd43e..65514420ca2 100644 --- a/.github/workflows/cluster_endtoend_vtgate_transaction.yml +++ b/.github/workflows/cluster_endtoend_vtgate_transaction.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vtgate_unsharded.yml b/.github/workflows/cluster_endtoend_vtgate_unsharded.yml index 0cab6566aad..50ff40891df 100644 --- a/.github/workflows/cluster_endtoend_vtgate_unsharded.yml +++ b/.github/workflows/cluster_endtoend_vtgate_unsharded.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vtgate_vindex.yml b/.github/workflows/cluster_endtoend_vtgate_vindex.yml index de22e37d11f..7d6fa43c37c 100644 --- a/.github/workflows/cluster_endtoend_vtgate_vindex.yml +++ b/.github/workflows/cluster_endtoend_vtgate_vindex.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vtgate_vschema.yml b/.github/workflows/cluster_endtoend_vtgate_vschema.yml index d6d0dfdcfae..e04c25ea124 100644 --- a/.github/workflows/cluster_endtoend_vtgate_vschema.yml +++ b/.github/workflows/cluster_endtoend_vtgate_vschema.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_vtorc.yml b/.github/workflows/cluster_endtoend_vtorc.yml index 07a55e9d0fb..567a0978621 100644 --- a/.github/workflows/cluster_endtoend_vtorc.yml +++ b/.github/workflows/cluster_endtoend_vtorc.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_endtoend_xb_recovery.yml b/.github/workflows/cluster_endtoend_xb_recovery.yml index 0bebf11f10e..17b6d15a4f5 100644 --- a/.github/workflows/cluster_endtoend_xb_recovery.yml +++ b/.github/workflows/cluster_endtoend_xb_recovery.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/cluster_initial_sharding_multi.yml b/.github/workflows/cluster_initial_sharding_multi.yml index 54dc50c509a..ba2bcd6635b 100644 --- a/.github/workflows/cluster_initial_sharding_multi.yml +++ b/.github/workflows/cluster_initial_sharding_multi.yml @@ -8,7 +8,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index 79f9bee0b6f..806a11f42cb 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/docker_test_1.yml b/.github/workflows/docker_test_1.yml index fe4ffde2e8d..429cc834d50 100644 --- a/.github/workflows/docker_test_1.yml +++ b/.github/workflows/docker_test_1.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/docker_test_2.yml b/.github/workflows/docker_test_2.yml index 57fa228257c..b60edc05469 100644 --- a/.github/workflows/docker_test_2.yml +++ b/.github/workflows/docker_test_2.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/docker_test_3.yml b/.github/workflows/docker_test_3.yml index 8026a25d5e1..f0eee6dc2bf 100644 --- a/.github/workflows/docker_test_3.yml +++ b/.github/workflows/docker_test_3.yml @@ -9,7 +9,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/e2e_race.yml b/.github/workflows/e2e_race.yml index d0f9e7a06b0..04141b93a55 100644 --- a/.github/workflows/e2e_race.yml +++ b/.github/workflows/e2e_race.yml @@ -8,7 +8,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/endtoend.yml b/.github/workflows/endtoend.yml index 5182fbb9d99..90c056ea764 100644 --- a/.github/workflows/endtoend.yml +++ b/.github/workflows/endtoend.yml @@ -8,7 +8,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/ensure_bootstrap_updated.yml b/.github/workflows/ensure_bootstrap_updated.yml index 2b5a0c5bd57..cf192e9eba7 100644 --- a/.github/workflows/ensure_bootstrap_updated.yml +++ b/.github/workflows/ensure_bootstrap_updated.yml @@ -8,7 +8,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.13 diff --git a/.github/workflows/golangci-linter.yml b/.github/workflows/golangci-linter.yml index 084ee49235e..249d65b28a2 100644 --- a/.github/workflows/golangci-linter.yml +++ b/.github/workflows/golangci-linter.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 id: go diff --git a/.github/workflows/gomod-tidy.yml b/.github/workflows/gomod-tidy.yml index 82872cac837..069bab38cee 100644 --- a/.github/workflows/gomod-tidy.yml +++ b/.github/workflows/gomod-tidy.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 id: go diff --git a/.github/workflows/legacy_local_example.yml b/.github/workflows/legacy_local_example.yml index 0716ad4bdb2..11bf3126894 100644 --- a/.github/workflows/legacy_local_example.yml +++ b/.github/workflows/legacy_local_example.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/local_example.yml b/.github/workflows/local_example.yml index ddcaf76fdc1..0f8e8b1e48e 100644 --- a/.github/workflows/local_example.yml +++ b/.github/workflows/local_example.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/region_example.yml b/.github/workflows/region_example.yml index 55956e453eb..baebb1e91fd 100644 --- a/.github/workflows/region_example.yml +++ b/.github/workflows/region_example.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/sonar_analysis.yml b/.github/workflows/sonar_analysis.yml index ff470b8a1c1..871e6cc7f83 100644 --- a/.github/workflows/sonar_analysis.yml +++ b/.github/workflows/sonar_analysis.yml @@ -10,7 +10,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.13 diff --git a/.github/workflows/unit_race.yml b/.github/workflows/unit_race.yml index 06b22b282ba..c828735e846 100644 --- a/.github/workflows/unit_race.yml +++ b/.github/workflows/unit_race.yml @@ -8,7 +8,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 @@ -38,6 +38,7 @@ jobs: mv dist/etcd-v3.3.10-linux-amd64/{etcd,etcdctl} bin/ go mod download + go install golang.org/x/tools/cmd/goimports@latest - name: Run make tools run: | diff --git a/.github/workflows/unit_test_mariadb102.yml b/.github/workflows/unit_test_mariadb102.yml index 1c1b49118ef..616634f1fee 100644 --- a/.github/workflows/unit_test_mariadb102.yml +++ b/.github/workflows/unit_test_mariadb102.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 @@ -63,6 +63,7 @@ jobs: mv dist/etcd-v3.3.10-linux-amd64/{etcd,etcdctl} bin/ go mod download + go install golang.org/x/tools/cmd/goimports@latest - name: Run make tools run: | diff --git a/.github/workflows/unit_test_mysql80.yml b/.github/workflows/unit_test_mysql80.yml index fe4c246c5f6..4e4118cd33a 100644 --- a/.github/workflows/unit_test_mysql80.yml +++ b/.github/workflows/unit_test_mysql80.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 @@ -63,6 +63,7 @@ jobs: mv dist/etcd-v3.3.10-linux-amd64/{etcd,etcdctl} bin/ go mod download + go install golang.org/x/tools/cmd/goimports@latest - name: Run make tools run: | diff --git a/.github/workflows/unit_test_percona56.yml b/.github/workflows/unit_test_percona56.yml index 5be13caed8c..17bc8380c29 100644 --- a/.github/workflows/unit_test_percona56.yml +++ b/.github/workflows/unit_test_percona56.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 @@ -64,6 +64,7 @@ jobs: mv dist/etcd-v3.3.10-linux-amd64/{etcd,etcdctl} bin/ go mod download + go install golang.org/x/tools/cmd/goimports@latest - name: Run make tools run: | diff --git a/examples/local/vstream_client.go b/examples/local/vstream_client.go index e9ccc7c08a6..be74f1976a3 100644 --- a/examples/local/vstream_client.go +++ b/examples/local/vstream_client.go @@ -22,6 +22,7 @@ import ( "io" "log" "time" + vtgatepb "vitess.io/vitess/go/vt/proto/vtgate" binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata" diff --git a/go/tools/sizegen/integration/cached_size.go b/go/tools/sizegen/integration/cached_size.go index a841d94f88b..6023b29b7e4 100644 --- a/go/tools/sizegen/integration/cached_size.go +++ b/go/tools/sizegen/integration/cached_size.go @@ -21,6 +21,7 @@ import ( "math" "reflect" "unsafe" + hack "vitess.io/vitess/go/hack" ) diff --git a/go/tools/sizegen/sizegen.go b/go/tools/sizegen/sizegen.go index 3865ded5ca4..b1c4762f902 100644 --- a/go/tools/sizegen/sizegen.go +++ b/go/tools/sizegen/sizegen.go @@ -23,6 +23,8 @@ import ( "go/types" "io/ioutil" "log" + "os" + "os/exec" "path" "sort" "strings" @@ -473,16 +475,22 @@ func main() { log.Printf("%d files OK", len(result)) } else { for fullPath, file := range result { - if err := file.Save(fullPath); err != nil { - log.Fatalf("filed to save file to '%s': %v", fullPath, err) + content, err := getFileInGoimportFormat(file) + if err != nil { + log.Fatalf("failed to apply goimport to '%s': %v", fullPath, err) + } + err = ioutil.WriteFile(fullPath, content, 0664) + if err != nil { + log.Fatalf("failed to save file to '%s': %v", fullPath, err) } - log.Printf("saved '%s'", fullPath) } } } // VerifyFilesOnDisk compares the generated results from the codegen against the files that -// currently exist on disk and returns any mismatches +// currently exist on disk and returns any mismatches. All the files generated by jennifer +// are formatted using the goimports command. Any difference in the imports will also make +// this test fail. func VerifyFilesOnDisk(result map[string]*jen.File) (errors []error) { for fullPath, file := range result { existing, err := ioutil.ReadFile(fullPath) @@ -491,13 +499,13 @@ func VerifyFilesOnDisk(result map[string]*jen.File) (errors []error) { continue } - var buf bytes.Buffer - if err := file.Render(&buf); err != nil { - errors = append(errors, fmt.Errorf("render error for '%s': %w", fullPath, err)) + genFile, err := getFileInGoimportFormat(file) + if err != nil { + errors = append(errors, fmt.Errorf("goimport error: %w", err)) continue } - if !bytes.Equal(existing, buf.Bytes()) { + if !bytes.Equal(existing, genFile) { errors = append(errors, fmt.Errorf("'%s' has changed", fullPath)) continue } @@ -557,3 +565,23 @@ func GenerateSizeHelpers(packagePatterns []string, typePatterns []string) (map[s return sizegen.finalize(), nil } + +func getFileInGoimportFormat(file *jen.File) ([]byte, error) { + tempFile, err := ioutil.TempFile("/tmp", "*.go") + if err != nil { + return nil, err + } + + err = file.Save(tempFile.Name()) + if err != nil { + return nil, err + } + + cmd := exec.Command("goimports", "-local", "vitess.io/vitess", "-w", tempFile.Name()) + cmd.Stderr = os.Stderr + err = cmd.Run() + if err != nil { + return nil, err + } + return ioutil.ReadFile(tempFile.Name()) +} diff --git a/go/vt/vtgate/engine/cached_size.go b/go/vt/vtgate/engine/cached_size.go index 380328449b5..a1db2e3f185 100644 --- a/go/vt/vtgate/engine/cached_size.go +++ b/go/vt/vtgate/engine/cached_size.go @@ -21,6 +21,7 @@ import ( "math" "reflect" "unsafe" + hack "vitess.io/vitess/go/hack" ) diff --git a/go/vt/vtgate/vindexes/cached_size.go b/go/vt/vtgate/vindexes/cached_size.go index a22932e6155..10af44ae6b2 100644 --- a/go/vt/vtgate/vindexes/cached_size.go +++ b/go/vt/vtgate/vindexes/cached_size.go @@ -21,6 +21,7 @@ import ( "math" "reflect" "unsafe" + hack "vitess.io/vitess/go/hack" ) diff --git a/test/templates/cluster_endtoend_test.tpl b/test/templates/cluster_endtoend_test.tpl index 8f6ccd054d7..28a6c660dee 100644 --- a/test/templates/cluster_endtoend_test.tpl +++ b/test/templates/cluster_endtoend_test.tpl @@ -11,7 +11,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/test/templates/dockerfile.tpl b/test/templates/dockerfile.tpl index a42ab4f2f1a..85fad6ea1fd 100644 --- a/test/templates/dockerfile.tpl +++ b/test/templates/dockerfile.tpl @@ -35,10 +35,13 @@ ENV VTDATAROOT /vt/vtdataroot # create the vtdataroot directory RUN mkdir -p $VTDATAROOT +# install goimports +RUN go install golang.org/x/tools/cmd/goimports@latest + {{if .MakeTools}} # make tools RUN make tools {{end}} - # sleep for 50 minutes +# sleep for 50 minutes CMD sleep 3000 \ No newline at end of file diff --git a/test/templates/unit_test.tpl b/test/templates/unit_test.tpl index 2e91ac59191..19d905aef9c 100644 --- a/test/templates/unit_test.tpl +++ b/test/templates/unit_test.tpl @@ -10,7 +10,7 @@ jobs: steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17 @@ -119,6 +119,7 @@ jobs: mv dist/etcd-v3.3.10-linux-amd64/{etcd,etcdctl} bin/ go mod download + go install golang.org/x/tools/cmd/goimports@latest - name: Run make tools run: | diff --git a/tools/check_make_sizegen.sh b/tools/check_make_sizegen.sh index edcff23a5e3..787ed43da49 100755 --- a/tools/check_make_sizegen.sh +++ b/tools/check_make_sizegen.sh @@ -13,6 +13,8 @@ ALL_FILES=$(find . -name "cached_size.go") set +e +goimports -local vitess.io/vitess -w $ALL_FILES + for SRC in $ALL_FILES do TMP="/tmp/"$(echo "$SRC" | sed 's/\//_/g' | sed "s/cached_size.go/cached_size_$$.go/g")