diff --git a/.github/workflows/jobs.yaml b/.github/workflows/jobs.yaml index b39d3af8f..82a1aaa93 100644 --- a/.github/workflows/jobs.yaml +++ b/.github/workflows/jobs.yaml @@ -289,12 +289,18 @@ jobs: with: go-version: ${{ matrix.go-version }} id: go - - uses: actions/setup-node@v2 - with: - node-version: '17' + - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Read .nvmrc + id: node_version + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + + - uses: actions/setup-node@v2 + with: + node-version: ${{ env.NVMRC }} + - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" @@ -387,12 +393,18 @@ jobs: with: go-version: ${{ matrix.go-version }} id: go - - uses: actions/setup-node@v2 - with: - node-version: '16' + - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Read .nvmrc + id: node_version + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + + - uses: actions/setup-node@v2 + with: + node-version: ${{ env.NVMRC }} + - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" @@ -466,12 +478,18 @@ jobs: with: go-version: ${{ matrix.go-version }} id: go - - uses: actions/setup-node@v2 - with: - node-version: '16' + - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Read .nvmrc + id: node_version + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + + - uses: actions/setup-node@v2 + with: + node-version: ${{ env.NVMRC }} + - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" @@ -545,12 +563,18 @@ jobs: with: go-version: ${{ matrix.go-version }} id: go - - uses: actions/setup-node@v2 - with: - node-version: '16' + - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Read .nvmrc + id: node_version + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + + - uses: actions/setup-node@v2 + with: + node-version: ${{ env.NVMRC }} + - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" @@ -626,11 +650,14 @@ jobs: with: go-version: ${{ matrix.go-version }} id: go - - uses: actions/setup-node@v2 - with: - node-version: '16' - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Read .nvmrc + id: node_version + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + - uses: actions/setup-node@v2 + with: + node-version: ${{ env.NVMRC }} - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" @@ -695,11 +722,14 @@ jobs: with: go-version: ${{ matrix.go-version }} id: go - - uses: actions/setup-node@v2 - with: - node-version: '16' - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Read .nvmrc + id: node_version + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + - uses: actions/setup-node@v2 + with: + node-version: ${{ env.NVMRC }} - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" @@ -764,11 +794,14 @@ jobs: with: go-version: ${{ matrix.go-version }} id: go - - uses: actions/setup-node@v2 - with: - node-version: '16' - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Read .nvmrc + id: node_version + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + - uses: actions/setup-node@v2 + with: + node-version: ${{ env.NVMRC }} - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" @@ -833,11 +866,14 @@ jobs: with: go-version: ${{ matrix.go-version }} id: go - - uses: actions/setup-node@v2 - with: - node-version: '16' - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Read .nvmrc + id: node_version + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + - uses: actions/setup-node@v2 + with: + node-version: ${{ env.NVMRC }} - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" @@ -902,11 +938,14 @@ jobs: with: go-version: ${{ matrix.go-version }} id: go - - uses: actions/setup-node@v2 - with: - node-version: '16' - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Read .nvmrc + id: node_version + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + - uses: actions/setup-node@v2 + with: + node-version: ${{ env.NVMRC }} - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" @@ -971,12 +1010,18 @@ jobs: with: go-version: ${{ matrix.go-version }} id: go - - uses: actions/setup-node@v2 - with: - node-version: '16' + - name: Check out code into the Go module directory uses: actions/checkout@v2 + - name: Read .nvmrc + id: node_version + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + + - uses: actions/setup-node@v2 + with: + node-version: ${{ env.NVMRC }} + - name: Get yarn cache directory path id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" @@ -1050,11 +1095,18 @@ jobs: with: go-version: ${{ matrix.go-version }} id: go - - uses: actions/setup-node@v2 - with: - node-version: '16' + - name: Check out code into the Go module directory uses: actions/checkout@v2 + + - name: Read .nvmrc + id: node_version + run: echo ::set-output name=NVMRC::$(cat .nvmrc) + + - uses: actions/setup-node@v2 + with: + node-version: ${{ env.NVMRC }} + - uses: actions/cache@v2 name: Go Mod Cache with: diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 000000000..8e2afd342 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +17 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 283672256..bc41649df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM node:17 as uilayer +ARG NODE_VERSION +FROM node:$NODE_VERSION as uilayer WORKDIR /app diff --git a/Dockerfile.assets b/Dockerfile.assets index a537d1572..52b7a436f 100644 --- a/Dockerfile.assets +++ b/Dockerfile.assets @@ -1,4 +1,5 @@ -FROM node:17 as uilayer +ARG NODE_VERSION +FROM node:$NODE_VERSION as uilayer WORKDIR /app diff --git a/Makefile b/Makefile index 0977d2d5c..2057bc0d4 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ BUILD_TIME:=$(shell date 2>/dev/null) TAG ?= "minio/console:$(BUILD_VERSION)-dev" MINIO_VERSION ?= "quay.io/minio/minio:latest" TARGET_BUCKET ?= "target" +NODE_VERSION := $(shell cat .nvmrc) default: console @@ -15,7 +16,7 @@ console: @(GO111MODULE=on CGO_ENABLED=0 go build -trimpath --tags=kqueue,operator --ldflags "-s -w" -o console ./cmd/console) k8sdev: - @docker build -t $(TAG) --build-arg build_version=$(BUILD_VERSION) --build-arg build_time='$(BUILD_TIME)' . + @docker build -t $(TAG) --build-arg build_version=$(BUILD_VERSION) --build-arg build_time='$(BUILD_TIME)' --build-arg NODE_VERSION='$(NODE_VERSION)' . @kind load docker-image $(TAG) @echo "Done, now restart your console deployment" @@ -63,7 +64,8 @@ swagger-operator: @swagger generate server -A operator --main-package=operator --server-package=operatorapi --exclude-main -P models.Principal -f ./swagger-operator.yml -r NOTICE assets: - @(cd portal-ui; yarn install --prefer-offline; make build-static; yarn prettier --write . --loglevel warn; cd ..) + @(if [ -f "${NVM_DIR}/nvm.sh" ]; then \. "${NVM_DIR}/nvm.sh" && nvm install && nvm use && npm install -g yarn ; fi &&\ + cd portal-ui; yarn install --prefer-offline; make build-static; yarn prettier --write . --loglevel warn; cd ..) test-integration: @(docker stop pgsqlcontainer || true) @@ -261,7 +263,7 @@ clean: @rm -vf console docker: - @docker buildx build --output=type=docker --platform linux/amd64 -t $(TAG) --build-arg build_version=$(BUILD_VERSION) --build-arg build_time='$(BUILD_TIME)' . + @docker buildx build --output=type=docker --platform linux/amd64 -t $(TAG) --build-arg build_version=$(BUILD_VERSION) --build-arg build_time='$(BUILD_TIME)' --build-arg NODE_VERSION='$(NODE_VERSION)' . release: swagger-gen @echo "Generating Release: $(RELEASE)" diff --git a/portal-ui/Makefile b/portal-ui/Makefile index 43d6cad12..cc60ce412 100644 --- a/portal-ui/Makefile +++ b/portal-ui/Makefile @@ -2,7 +2,8 @@ default: build-static build-static: @echo "Building frontend static assets to 'build'" - NODE_OPTIONS=--openssl-legacy-provider yarn build + @if [ -f "${NVM_DIR}/nvm.sh" ]; then \. "${NVM_DIR}/nvm.sh" && nvm install && nvm use; fi && \ + NODE_OPTIONS=--openssl-legacy-provider yarn build test-warnings: ./check-warnings.sh diff --git a/portal-ui/check-prettier.sh b/portal-ui/check-prettier.sh index 1b35677d3..0cbbee2c9 100755 --- a/portal-ui/check-prettier.sh +++ b/portal-ui/check-prettier.sh @@ -1,4 +1,9 @@ #!/bin/bash +if [ -f "$NVM_DIR/nvm.sh" ] +then + \. "$NVM_DIR/nvm.sh"; + nvm use; +fi yarn install yarn prettier --check . diff --git a/portal-ui/check-warnings.sh b/portal-ui/check-warnings.sh index 750bdedde..2c6e7121a 100755 --- a/portal-ui/check-warnings.sh +++ b/portal-ui/check-warnings.sh @@ -10,7 +10,7 @@ die() { try() { "$@" &> yarn.log || die "cannot $*"; } -rm yarn.log +rm -f yarn.log try make build-static if cat yarn.log | grep "Compiled with warnings"; then