jenkins: build and test web/satellite (#2908)

This commit is contained in:
Egon Elbre 2019-09-05 16:32:46 +03:00 committed by GitHub
parent 15e52e0985
commit c4ee7eb51c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 9 deletions

View File

@ -4,8 +4,9 @@ FROM golang:1.12.9
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get update && apt-get install -y -qq postgresql-11 redis-server unzip libuv1-dev libjson-c-dev nettle-dev
RUN apt-get update && apt-get install -y -qq postgresql-11 redis-server unzip libuv1-dev libjson-c-dev nettle-dev nodejs
RUN rm /etc/postgresql/11/main/pg_hba.conf; \
echo 'local all all trust' >> /etc/postgresql/11/main/pg_hba.conf; \

View File

@ -2,13 +2,16 @@ pipeline {
agent {
dockerfile {
filename 'Dockerfile.jenkins'
args '-u root:root --cap-add SYS_PTRACE -v "/tmp/gomod":/go/pkg/mod'
args '-u root:root --cap-add SYS_PTRACE -v "/tmp/gomod":/go/pkg/mod -v "/tmp/npm":/tmp/npm'
label 'main'
}
}
options {
timeout(time: 14, unit: 'MINUTES')
}
environment {
NPM_CONFIG_CACHE = '/tmp/npm/cache'
}
stages {
stage('Build') {
steps {
@ -21,7 +24,7 @@ pipeline {
// download dependencies
sh 'go mod download'
sh 'make -j2 build-packages'
sh 'make -j3 build-packages'
sh 'make install-sim'
sh 'service postgresql start'
@ -106,6 +109,18 @@ pipeline {
sh 'make test-sim-backwards-compatible'
}
}
stage('npm') {
steps {
dir("web/satellite") {
sh 'npm run build'
sh 'npm run lint'
// TODO: reenable with vue4
sh script: 'npm audit', returnStatus: true
sh 'npm run test'
}
}
}
}
}
}

View File

@ -72,11 +72,13 @@ proto: ## Rebuild protobuf files
go run scripts/protobuf.go generate
.PHONY: build-packages
build-packages: build-packages-race build-packages-normal ## Test docker images locally
build-packages: build-packages-race build-packages-normal build-npm ## Test docker images locally
build-packages-race:
go install -v ./...
build-packages-normal:
go install -v -race ./...
build-npm:
cd web/satellite && npm ci
##@ Simulator

View File

@ -23,7 +23,14 @@ func main() {
}
leftover := strings.Split(strings.TrimSpace(string(out)), "\n")
leftover = ignoreDir(leftover, ".build")
leftover = ignorePrefix(leftover, ".build")
// there's no easy way to modify npm to use tmp folders
leftover = ignorePrefix(leftover, "web/satellite/node_modules/")
leftover = ignorePrefix(leftover, "web/satellite/coverage/")
leftover = ignorePrefix(leftover, "web/satellite/dist/")
// TODO: shouldn't this be already up to date?
leftover = ignorePrefix(leftover, "web/satellite/package-lock.json")
if len(leftover) != 0 {
fmt.Println("Files left-over after running tests:")
@ -34,7 +41,7 @@ func main() {
}
}
func ignoreDir(files []string, dir string) []string {
func ignorePrefix(files []string, dir string) []string {
result := files[:0]
for _, file := range files {
if file == "" {

View File

@ -20,6 +20,13 @@ var checkFiles = map[string]bool{
".vue": true,
}
var ignoreFolder = map[string]bool{
".git": true,
"node_modules": true,
"coverage": true,
"dist": true,
}
func main() {
var failed int
@ -28,7 +35,7 @@ func main() {
fmt.Println(err)
return nil
}
if info.IsDir() && info.Name() == ".git" {
if info.IsDir() && ignoreFolder[info.Name()] {
return filepath.SkipDir
}
if !checkFiles[filepath.Ext(path)] {

View File

@ -13,6 +13,13 @@ import (
"storj.io/storj/internal/memory"
)
var ignoreFolder = map[string]bool{
".git": true,
"node_modules": true,
"coverage": true,
"dist": true,
}
func main() {
const fileSizeLimit = 600 * memory.KB
@ -23,7 +30,7 @@ func main() {
fmt.Println(err)
return nil
}
if info.IsDir() && info.Name() == ".git" {
if info.IsDir() && ignoreFolder[info.Name()] {
return filepath.SkipDir
}

View File

@ -23,6 +23,14 @@ var ignoreProto = map[string]bool{
"gogo.proto": true,
}
var ignoreDir = map[string]bool{
".git": true,
".build": true,
"node_modules": true,
"coverage": true,
"dist": true,
}
var protoc = flag.String("protoc", "protoc", "protoc location")
func main() {
@ -306,7 +314,7 @@ func listProtoFiles(root string) ([]string, error) {
fmt.Fprintln(os.Stderr, err)
return nil
}
if info.IsDir() && info.Name() == ".git" {
if info.IsDir() && ignoreDir[info.Name()] {
return filepath.SkipDir
}
if filepath.Ext(path) == ".proto" {