ci(codecov): utilise new codecov uploader for coverage (#2467)
* ci(codecov): utilise new codecov uploader for coverage The codecov bash uploader is being [deprecated](https://docs.codecov.com/docs/about-the-codecov-bash-uploader). This utilises the new uploader which is recommended. * ci(codecov): adjust file search path and name uploads * fix(suites): coverage paths for codecovpull/2468/head^2
parent
faf20f8c90
commit
4161fbd818
|
@ -12,14 +12,18 @@ fi
|
||||||
if [[ ! "${BUILDKITE_BRANCH}" =~ ^(v.*) ]] && [[ "${BUILDKITE_COMMAND_EXIT_STATUS}" == 0 ]]; then
|
if [[ ! "${BUILDKITE_BRANCH}" =~ ^(v.*) ]] && [[ "${BUILDKITE_COMMAND_EXIT_STATUS}" == 0 ]]; then
|
||||||
if [[ "${BUILDKITE_LABEL}" == ":hammer_and_wrench: Unit Test" ]] || [[ "${BUILDKITE_LABEL}" =~ ":selenium:" ]]; then
|
if [[ "${BUILDKITE_LABEL}" == ":hammer_and_wrench: Unit Test" ]] || [[ "${BUILDKITE_LABEL}" =~ ":selenium:" ]]; then
|
||||||
echo "--- :codecov: Upload coverage reports"
|
echo "--- :codecov: Upload coverage reports"
|
||||||
|
NAME="UnitTest"
|
||||||
if [[ "${BUILDKITE_AGENT_META_DATA_CODECOV}" == "verbose" ]]; then
|
if [[ "${BUILDKITE_AGENT_META_DATA_CODECOV}" == "verbose" ]]; then
|
||||||
BUILDKITE_AGENT_META_DATA_CODECOV="-v"
|
BUILDKITE_AGENT_META_DATA_CODECOV="-v"
|
||||||
fi
|
fi
|
||||||
bash <(curl -s --connect-timeout 10 --retry 10 --retry-max-time 0 https://codecov.io/bash) -Z -c -s 'coverage*.txt' -F backend "${BUILDKITE_AGENT_META_DATA_CODECOV}"
|
if [[ "${BUILDKITE_LABEL}" =~ ":selenium:" ]]; then
|
||||||
|
NAME=$(echo ${BUILDKITE_LABEL/:selenium: /} | awk '{ print $1 }')
|
||||||
|
fi
|
||||||
|
codecov -Z -c -f 'coverage*.txt' -n ${NAME} -F backend "${BUILDKITE_AGENT_META_DATA_CODECOV}"
|
||||||
if [[ "${BUILDKITE_LABEL}" =~ ":selenium:" ]]; then
|
if [[ "${BUILDKITE_LABEL}" =~ ":selenium:" ]]; then
|
||||||
cd web && pnpm report
|
cd web && pnpm report
|
||||||
fi
|
fi
|
||||||
bash <(curl -s --connect-timeout 10 --retry 10 --retry-max-time 0 https://codecov.io/bash) -Z -c -f '!*.go' -f '!*.zst' -F frontend "${BUILDKITE_AGENT_META_DATA_CODECOV}"
|
codecov -Z -c -f '!Dockerfile*' -f '!*.go' -f '!*.zst' -n ${NAME} -F frontend "${BUILDKITE_AGENT_META_DATA_CODECOV}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package suites
|
package suites
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetLoginBaseURL returns the URL of the login portal and the path prefix if specified.
|
// GetLoginBaseURL returns the URL of the login portal and the path prefix if specified.
|
||||||
|
@ -25,3 +28,37 @@ func GetWebDriverPort() int {
|
||||||
|
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func fixCoveragePath(path string, file os.FileInfo, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if file.IsDir() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
coverage, err := filepath.Match("*.json", file.Name())
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if coverage {
|
||||||
|
read, err := ioutil.ReadFile(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
wd, _ := os.Getwd()
|
||||||
|
ciPath := strings.TrimSuffix(wd, "internal/suites")
|
||||||
|
content := strings.ReplaceAll(string(read), "/node/src/app/", ciPath+"web/")
|
||||||
|
|
||||||
|
err = ioutil.WriteFile(path, []byte(content), 0)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -103,6 +104,11 @@ func (wds *WebDriverSession) Stop() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = filepath.Walk("../../web/.nyc_output", fixCoveragePath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err = wds.WebDriver.Quit()
|
err = wds.WebDriver.Quit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue