diff --git a/Dockerfile.jenkins b/Dockerfile.jenkins index 2ba7c2beb..7b0bc0bde 100644 --- a/Dockerfile.jenkins +++ b/Dockerfile.jenkins @@ -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; \ diff --git a/Jenkinsfile.public b/Jenkinsfile.public index 94fdcc9ac..31daae7ad 100644 --- a/Jenkinsfile.public +++ b/Jenkinsfile.public @@ -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' + } + } + } } } } diff --git a/Makefile b/Makefile index 780c0b126..35a54dd99 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/scripts/check-clean-directory.go b/scripts/check-clean-directory.go index 4100da782..e4b3d54fa 100644 --- a/scripts/check-clean-directory.go +++ b/scripts/check-clean-directory.go @@ -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 == "" { diff --git a/scripts/check-copyright.go b/scripts/check-copyright.go index 0f4181345..f8cb65c4f 100644 --- a/scripts/check-copyright.go +++ b/scripts/check-copyright.go @@ -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)] { diff --git a/scripts/check-large-files.go b/scripts/check-large-files.go index 276382393..caf8194c9 100644 --- a/scripts/check-large-files.go +++ b/scripts/check-large-files.go @@ -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 } diff --git a/scripts/protobuf.go b/scripts/protobuf.go index 03ef0f099..604ed494d 100644 --- a/scripts/protobuf.go +++ b/scripts/protobuf.go @@ -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" {