fix(ci): use npm ci to install node packages

This commit is contained in:
Łukasz Mierzwa
2020-09-20 16:54:13 +01:00
committed by Łukasz Mierzwa
parent cbc657c46b
commit f46c821a1c
4 changed files with 18 additions and 14 deletions

View File

@@ -3,7 +3,7 @@ __defaults_go: &DEFAULTS_GO
go: "1.15.2"
cache:
directories:
- ui/node_modules
- "$HOME/.npm"
# https://restic.net/blog/2018-09-02/travis-build-cache
- $HOME/.cache/go-build
- $HOME/gopath/pkg/mod
@@ -21,7 +21,7 @@ __defaults_js: &DEFAULTS_JS
install: []
cache:
directories:
- ui/node_modules
- "$HOME/.npm"
env:
- NODE_ENV=test

View File

@@ -2,7 +2,7 @@ FROM node:12.18.4-alpine as nodejs-builder
RUN mkdir -p /src/ui
COPY ui/package.json ui/package-lock.json /src/ui/
ENV NODE_ENV=production
RUN cd /src/ui && npm install
RUN cd /src/ui && npm ci
RUN apk add make git
COPY ui /src/ui
RUN make -C /src/ui build

View File

@@ -2,7 +2,7 @@ FROM node:12.18.4-alpine as nodejs-builder
RUN mkdir -p /src/ui
COPY ui/package.json ui/package-lock.json /src/ui/
ENV NODE_ENV=production
RUN cd /src/ui && npm install
RUN cd /src/ui && npm ci
RUN apk add make git
COPY ui /src/ui
RUN make -C /src/ui build

View File

@@ -3,17 +3,21 @@
# based on http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html
rwildcard = $(foreach d, $(wildcard $1*), $(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
NODE_PATH := $(shell npm bin)
PATH := $(PATH):$(NODE_PATH)
SHELL := env PATH=$(PATH) /bin/sh
NODE_PATH := $(shell npm bin)
NODE_MODULES := $(shell dirname `npm bin`)
NODE_INSTALL := $(NODE_MODULES)/.install
$(NODE_PATH)/%: package.json package-lock.json
@export D="$*"; \
if [ "$*" = "commitlint-travis" ]; then export D="@commitlint/travis-cli" ; fi; \
if [ "$*" = "build-storybook" ]; then export D="@storybook/react" ; fi; \
if [ "$*" = "percy-storybook" ]; then export D="@percy-io/percy-storybook" ; fi; \
if [ -d "$(CURDIR)/node_modules/$$D" ] && [ ! -x "$@" ]; then (echo "resetting node_modules" && npm ci); else npm install ; fi
@if [ -x $@ ]; then touch -c $@ ; else echo "missing script: $@" ; exit 1; fi
PATH := $(PATH):$(NODE_PATH)
SHELL := env PATH=$(PATH) /bin/sh
.DEFAULT_GOAL := build/index.html
$(NODE_INSTALL): package.json package-lock.json
@if [ -e $(NODE_INSTALL) ]; then npm install ; else npm ci; fi
touch $@
$(NODE_PATH)/%: $(NODE_INSTALL)
@if [ ! -x $@ ]; then echo "missing script: $@" ; exit 1; fi
build/index.html: $(NODE_PATH)/react-scripts $(call rwildcard, public src, *)
@rm -fr node_modules/.cache/eslint-loader