mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #13651 from serathius/coverage
Re-enable code coverage upload
This commit is contained in:
commit
a99c919a9f
28
.github/workflows/coverage.yaml
vendored
Normal file
28
.github/workflows/coverage.yaml
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
name: Coverage
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
coverage:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target:
|
||||
- linux-amd64-coverage
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: "1.17.6"
|
||||
- env:
|
||||
TARGET: ${{ matrix.target }}
|
||||
run: |
|
||||
mkdir "${TARGET}"
|
||||
case "${TARGET}" in
|
||||
linux-amd64-coverage)
|
||||
GOARCH=amd64 ./scripts/codecov_upload.sh
|
||||
;;
|
||||
*)
|
||||
echo "Failed to find target"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
@ -1,7 +1,7 @@
|
||||
# etcd
|
||||
|
||||
[](https://goreportcard.com/report/github.com/etcd-io/etcd)
|
||||
[](https://codecov.io/gh/etcd-io/etcd)
|
||||
[](https://codecov.io/gh/etcd-io/etcd)
|
||||
[](https://github.com/etcd-io/etcd/actions/workflows/tests.yaml)
|
||||
[](https://github.com/etcd-io/etcd/actions/workflows/asset-transparency.yaml)
|
||||
[](https://github.com/etcd-io/etcd/actions/workflows/codeql-analysis.yml)
|
||||
|
2
test.sh
2
test.sh
@ -330,7 +330,7 @@ function cov_pass {
|
||||
-timeout=5m "${gocov_build_flags[@]}" "$@" || failed="$failed integration_v2"
|
||||
# integration_cluster_proxy
|
||||
run_for_module "tests" go_test "./integration/..." "parallel" "pkg_to_coverprofileflag integration_cluster_proxy" \
|
||||
-tags cluster_proxy -timeout=5m "${gocov_build_flags[@]}" || failed="$failed integration_cluster_proxy"
|
||||
-tags cluster_proxy -timeout=30m "${gocov_build_flags[@]}" || failed="$failed integration_cluster_proxy"
|
||||
|
||||
log_callout "[$(date)] Collecting coverage from e2e tests ..."
|
||||
# We don't pass 'gocov_build_flags' nor 'pkg_to_coverprofileflag' here,
|
||||
|
24
tests/framework/e2e/etcd_spawn.go
Normal file
24
tests/framework/e2e/etcd_spawn.go
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright 2022 The etcd Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"go.etcd.io/etcd/pkg/v3/expect"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func SpawnCmd(args []string, envVars map[string]string) (*expect.ExpectProcess, error) {
|
||||
return SpawnCmdWithLogger(zap.NewNop(), args, envVars)
|
||||
}
|
@ -36,13 +36,9 @@ var (
|
||||
coverDir = integration.MustAbsPath(os.Getenv("COVERDIR"))
|
||||
)
|
||||
|
||||
func SpawnCmd(args []string) (*expect.ExpectProcess, error) {
|
||||
return SpawnCmdWithLogger(zap.NewNop(), args)
|
||||
}
|
||||
|
||||
func SpawnCmdWithLogger(lg *zap.Logger, args []string) (*expect.ExpectProcess, error) {
|
||||
func SpawnCmdWithLogger(lg *zap.Logger, args []string, envVars map[string]string) (*expect.ExpectProcess, error) {
|
||||
cmd := args[0]
|
||||
env := make([]string, 0)
|
||||
env := mergeEnvVariables(envVars)
|
||||
switch {
|
||||
case strings.HasSuffix(cmd, "/etcd"):
|
||||
cmd = cmd + "_test"
|
||||
@ -66,7 +62,7 @@ func SpawnCmdWithLogger(lg *zap.Logger, args []string) (*expect.ExpectProcess, e
|
||||
}
|
||||
// when withFlagByEnv() is used in testCtl(), env variables for ctl is set to os.env.
|
||||
// they must be included in ctl_cov_env.
|
||||
env = append(env, os.Environ()...)
|
||||
|
||||
all_args := append(args[1:], covArgs...)
|
||||
lg.Info("spawning process", zap.Strings("args", all_args), zap.String("working-dir", wd))
|
||||
ep, err := expect.NewExpectWithEnv(cmd, all_args, env)
|
||||
|
@ -18,7 +18,6 @@
|
||||
package e2e
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@ -28,10 +27,6 @@ import (
|
||||
|
||||
const noOutputLineCount = 0 // regular binaries emit no extra lines
|
||||
|
||||
func SpawnCmd(args []string, envVars map[string]string) (*expect.ExpectProcess, error) {
|
||||
return SpawnCmdWithLogger(zap.NewNop(), args, envVars)
|
||||
}
|
||||
|
||||
func SpawnCmdWithLogger(lg *zap.Logger, args []string, envVars map[string]string) (*expect.ExpectProcess, error) {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
@ -46,23 +41,3 @@ func SpawnCmdWithLogger(lg *zap.Logger, args []string, envVars map[string]string
|
||||
lg.Info("spawning process", zap.Strings("args", args), zap.String("working-dir", wd), zap.Strings("environment-variables", env))
|
||||
return expect.NewExpectWithEnv(args[0], args[1:], env)
|
||||
}
|
||||
|
||||
func mergeEnvVariables(envVars map[string]string) []string {
|
||||
var env []string
|
||||
// Environment variables are passed as parameter have higher priority
|
||||
// than os environment variables.
|
||||
for k, v := range envVars {
|
||||
env = append(env, fmt.Sprintf("%s=%s", k, v))
|
||||
}
|
||||
|
||||
// Now, we can set os environment variables not passed as parameter.
|
||||
currVars := os.Environ()
|
||||
for _, v := range currVars {
|
||||
p := strings.Split(v, "=")
|
||||
if _, ok := envVars[p[0]]; !ok {
|
||||
env = append(env, fmt.Sprintf("%s=%s", p[0], p[1]))
|
||||
}
|
||||
}
|
||||
|
||||
return env
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@ -131,3 +132,23 @@ func ExecuteWithTimeout(t *testing.T, timeout time.Duration, f func()) {
|
||||
case <-donec:
|
||||
}
|
||||
}
|
||||
|
||||
func mergeEnvVariables(envVars map[string]string) []string {
|
||||
var env []string
|
||||
// Environment variables are passed as parameter have higher priority
|
||||
// than os environment variables.
|
||||
for k, v := range envVars {
|
||||
env = append(env, fmt.Sprintf("%s=%s", k, v))
|
||||
}
|
||||
|
||||
// Now, we can set os environment variables not passed as parameter.
|
||||
currVars := os.Environ()
|
||||
for _, v := range currVars {
|
||||
p := strings.Split(v, "=")
|
||||
if _, ok := envVars[p[0]]; !ok {
|
||||
env = append(env, fmt.Sprintf("%s=%s", p[0], p[1]))
|
||||
}
|
||||
}
|
||||
|
||||
return env
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user