Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Yarn instead of NPM #5541

Merged
merged 5 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .circleci/Dockerfile.cypress
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM cypress/browsers:node14.0.0-chrome84
FROM cypress/browsers:node14.17.0-chrome91-ff89

ENV APP /usr/src/app
WORKDIR $APP

COPY package.json package-lock.json $APP/
COPY package.json yarn.lock .yarnrc $APP/
COPY viz-lib $APP/viz-lib
RUN npm ci > /dev/null
RUN npm install [email protected] -g && yarn --frozen-lockfile --network-concurrency 1 > /dev/null

COPY . $APP

Expand Down
50 changes: 28 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ version: 2.0

build-docker-image-job: &build-docker-image-job
docker:
- image: circleci/node:12
- image: circleci/node:14.17
steps:
- setup_remote_docker
- setup_remote_docker:
version: 19.03.13
- checkout
- run: sudo apt update
- run: sudo apt install python3-pip
- run: sudo pip3 install -r requirements_bundles.txt
- run: .circleci/update_version
- run: npm run bundle
- run: sudo npm install --global --force [email protected]
- run: yarn bundle
- run: .circleci/docker_build
jobs:
backend-lint:
Expand All @@ -27,7 +29,8 @@ jobs:
docker:
- image: circleci/buildpack-deps:xenial
steps:
- setup_remote_docker
- setup_remote_docker:
version: 19.03.13
- checkout
- run:
name: Build Docker Images
Expand Down Expand Up @@ -61,34 +64,36 @@ jobs:
CYPRESS_INSTALL_BINARY: 0
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
docker:
- image: circleci/node:12
- image: circleci/node:14.17
steps:
- checkout
- run: mkdir -p /tmp/test-results/eslint
- run: npm ci
- run: npm run lint:ci
- run: sudo npm install --global --force [email protected]
- run: yarn cache clean && yarn --frozen-lockfile --network-concurrency 1
- run: yarn lint:ci
- store_test_results:
path: /tmp/test-results
frontend-unit-tests:
environment:
CYPRESS_INSTALL_BINARY: 0
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
docker:
- image: circleci/node:12
- image: circleci/node:14.17
steps:
- checkout
- run: sudo apt update
- run: sudo apt install python3-pip
- run: sudo pip3 install -r requirements_bundles.txt
- run: npm ci
- run: npm run bundle
- run: sudo npm install --global --force [email protected]
- run: yarn cache clean && yarn --frozen-lockfile --network-concurrency 1
- run: yarn bundle
- run:
name: Run App Tests
command: npm test
command: yarn test
- run:
name: Run Visualizations Tests
command: (cd viz-lib && npm test)
- run: npm run lint
command: (cd viz-lib && yarn test)
- run: yarn lint
frontend-e2e-tests:
environment:
COMPOSE_FILE: .circleci/docker-compose.cypress.yml
Expand All @@ -99,9 +104,10 @@ jobs:
CYPRESS_INSTALL_BINARY: 0
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: 1
docker:
- image: circleci/node:12
- image: circleci/node:14.17
steps:
- setup_remote_docker
- setup_remote_docker:
version: 19.03.13
- checkout
- run:
name: Enable Code Coverage report for master branch
Expand All @@ -110,19 +116,19 @@ jobs:
echo 'export CODE_COVERAGE=true' >> $BASH_ENV
source $BASH_ENV
fi
- run: sudo npm install --global --force [email protected]
- run:
name: Install npm dependencies
command: |
npm ci
name: Install frontend dependencies
command: yarn cache clean && yarn --frozen-lockfile --network-concurrency 1
- run:
name: Setup Redash server
command: |
npm run cypress build
npm run cypress start -- --skip-db-seed
docker-compose run cypress npm run cypress db-seed
yarn cypress build
yarn cypress start -- --skip-db-seed
docker-compose run cypress yarn cypress db-seed
- run:
name: Execute Cypress tests
command: npm run cypress run-ci
command: yarn cypress run-ci
- run:
name: "Failure: output container logs to console"
command: |
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v14.16.1
2 changes: 2 additions & 0 deletions .yarn/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
Empty file added .yarnrc
Empty file.
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM node:12 as frontend-builder
FROM node:14.17 as frontend-builder

RUN npm install --global --force [email protected]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't node docker images come with yarn? (Same for the circleci one)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They do, but with older version (different in both cases). For consistency, I'm upgrading it everywhere


# Controls whether to build the frontend assets
ARG skip_frontend_build
Expand All @@ -10,18 +12,19 @@ RUN useradd -m -d /frontend redash
USER redash

WORKDIR /frontend
COPY --chown=redash package.json package-lock.json /frontend/
COPY --chown=redash package.json yarn.lock .yarnrc /frontend/
COPY --chown=redash viz-lib /frontend/viz-lib

# Controls whether to instrument code for coverage information
ARG code_coverage
ENV BABEL_ENV=${code_coverage:+test}

RUN if [ "x$skip_frontend_build" = "x" ] ; then npm ci --unsafe-perm; fi
RUN if [ "x$skip_frontend_build" = "x" ] ; then yarn --frozen-lockfile --network-concurrency 1; fi

COPY --chown=redash client /frontend/client
COPY --chown=redash webpack.config.js /frontend/
RUN if [ "x$skip_frontend_build" = "x" ] ; then npm run build; else mkdir -p /frontend/client/dist && touch /frontend/client/dist/multi_org.html && touch /frontend/client/dist/index.html; fi
RUN if [ "x$skip_frontend_build" = "x" ] ; then yarn build; else mkdir -p /frontend/client/dist && touch /frontend/client/dist/multi_org.html && touch /frontend/client/dist/index.html; fi

FROM python:3.7-slim

EXPOSE 5000
Expand Down Expand Up @@ -57,7 +60,7 @@ RUN apt-get update && \
libsasl2-dev \
unzip \
libsasl2-modules-gssapi-mit && \
# MSSQL ODBC Driver:
# MSSQL ODBC Driver:
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ backend-unit-tests: up test_db
docker-compose run --rm --name tests server tests

frontend-unit-tests: bundle
CYPRESS_INSTALL_BINARY=0 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 npm ci
npm run bundle
npm test
CYPRESS_INSTALL_BINARY=0 PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 yarn --frozen-lockfile
yarn bundle
yarn test

test: lint backend-unit-tests frontend-unit-tests

build: bundle
npm run build
yarn build

watch: bundle
npm run watch
yarn watch

start: bundle
npm run start
yarn start

redis-cli:
docker-compose run --rm redis redis-cli -h redis
Expand Down
2 changes: 1 addition & 1 deletion client/cypress/cypress.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@ switch (command) {
stopServer();
break;
default:
console.log("Usage: npm run cypress [build|start|db-seed|open|run|stop]");
console.log("Usage: yarn cypress [build|start|db-seed|open|run|stop]");
break;
}
8 changes: 6 additions & 2 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
[build]
base = "client"
publish = "client/dist"
command = "npm ci && npm run build"
# Netlify doesn't seem to install Yarn even though NETLIFY_USE_YARN is set below
# command = "cd ../ && npm i -g [email protected] && yarn --frozen-lockfile --force && cd viz-lib && yarn build:babel && cd .. && rm -r ./node_modules/@redash/viz && cp -r ./viz-lib/. ./node_modules/@redash/viz && yarn build && cd ./client"
command = "cd ../ && npm i -g [email protected] && yarn cache clean && yarn --frozen-lockfile --network-concurrency 1 && yarn build && cd ./client"

[build.environment]
NODE_VERSION = "12.18.4"
NODE_VERSION = "14.16.1"
NETLIFY_USE_YARN = "true"
YARN_VERSION = "1.22.10"
CYPRESS_INSTALL_BINARY = "0"
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = "1"

Expand Down
Loading