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

ci: remove vendored yarn, and use volta for Travis + GHA #19069

Merged
merged 30 commits into from
May 29, 2020
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
14 changes: 3 additions & 11 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ jobs:
DJANGO_VERSION: ">=1.11,<1.12"

# Node configuration
# node's version is pinned by .nvmrc and is autodetected by `nvm install`.
NODE_OPTIONS: --max-old-space-size=4096
NODE_ENV: development

Expand Down Expand Up @@ -119,16 +118,14 @@ jobs:
# Checkout codebase
- uses: actions/checkout@v2

# Install node
- uses: volta-cli/action@v1

# See https://github.com/actions/cache/blob/master/examples.md#node---yarn for example
- name: Get yarn cache dir
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

# Use nvmrc so we don't have yet another place node version is defined
- name: Get node version from .nvmrc
id: nvmrc
run: echo "::set-output name=version::$(cat .nvmrc)"

# yarn cache
- uses: actions/cache@v1
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
Expand All @@ -138,11 +135,6 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-

# Setup node
- uses: actions/setup-node@v1
with:
node-version: ${{ steps.nvmrc.outputs.version }}

# Use `.python-version` to avoid duplication
# XXX: can't actually read from .python-version because GitHub Actions
# does not support our version (2.7.16)
Expand Down
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
exclude: >
(?x)(
LICENSE$|
^bin/yarn$|
\.snap$|
\.map$|
\.map\.js$|
Expand Down
72 changes: 44 additions & 28 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cache:
yarn: true
directories:
- "${HOME}/virtualenv/python$(python -c 'import platform; print(platform.python_version())')"
- '$NODE_DIR'
- '$VOLTA_HOME'
- node_modules
- '${HOME}/google-cloud-sdk'

Expand All @@ -32,8 +32,9 @@ env:
- MIGRATIONS_TEST_MIGRATE=0
# Use this to override the django version in the requirements file.
- DJANGO_VERSION=">=1.11,<1.12"
# node's version is pinned by .nvmrc and is autodetected by `nvm install`.
- NODE_DIR="${HOME}/.nvm/versions/node/v$(< .nvmrc)"
- VOLTA_VERSION=0.8.1
- VOLTA_HOME="${HOME}/.volta"
- PATH="${HOME}/.volta/bin:${PATH}"
- NODE_OPTIONS=--max-old-space-size=4096
- PYTEST_SENTRY_DSN=https://6fd5cfea2d4d46b182ad214ac7810508@sentry.io/2423079
- SENTRY_KAFKA_HOSTS=localhost:9092
Expand Down Expand Up @@ -62,6 +63,21 @@ base_install: &base_install |-

[ "$TRAVIS_PULL_REQUEST" != "false" ] || export PYTEST_SENTRY_ALWAYS_REPORT=1

install_volta: &install_volta |-
command -v volta && exit 0
wget --quiet "https://github.com/volta-cli/volta/releases/download/v$VOLTA_VERSION/volta-$VOLTA_VERSION-linux-openssl-1.0.tar.gz"
tar -xzf "volta-$VOLTA_VERSION-linux-openssl-1.0.tar.gz" -C "${HOME}/bin"
# Running `volta -v` triggers setting up the shims in VOLTA_HOME (otherwise node won't work)
volta -v

install_node_dependencies: &install_node_dependencies |-
# Running `node -v` and `yarn -v` triggers Volta to install the versions set in the project.
# There might be a more readable `volta install` in the future that would replace this magic.
# Tracking: https://github.com/volta-cli/volta/issues/653#issuecomment-628909923
node -v
yarn -v
yarn install --frozen-lockfile
joshuarli marked this conversation as resolved.
Show resolved Hide resolved

start_snuba: &start_snuba |-
docker run \
--name sentry_clickhouse \
Expand Down Expand Up @@ -94,14 +110,15 @@ after_script:
pip install -U codecov
codecov -e TEST_SUITE
fi
- ./bin/yarn global add @zeus-ci/cli
- $(./bin/yarn global bin)/zeus upload -t "text/xml+xunit" .artifacts/*junit.xml
- $(./bin/yarn global bin)/zeus upload -t "text/xml+coverage" .artifacts/*coverage.xml
- $(./bin/yarn global bin)/zeus upload -t "text/xml+coverage" .artifacts/coverage/cobertura-coverage.xml
- $(./bin/yarn global bin)/zeus upload -t "text/html+pytest" .artifacts/*pytest.html
- $(./bin/yarn global bin)/zeus upload -t "text/plain+pycodestyle" .artifacts/*pycodestyle.log
- $(./bin/yarn global bin)/zeus upload -t "text/xml+checkstyle" .artifacts/*checkstyle.xml
- $(./bin/yarn global bin)/zeus upload -t "application/webpack-stats+json" .artifacts/*webpack-stats.json
- yarn global add @zeus-ci/cli
- export PATH="$(yarn global bin):${PATH}"
- zeus upload -t "text/xml+xunit" .artifacts/*junit.xml
- zeus upload -t "text/xml+coverage" .artifacts/*coverage.xml
- zeus upload -t "text/xml+coverage" .artifacts/coverage/cobertura-coverage.xml
- zeus upload -t "text/html+pytest" .artifacts/*pytest.html
- zeus upload -t "text/plain+pycodestyle" .artifacts/*pycodestyle.log
- zeus upload -t "text/xml+checkstyle" .artifacts/*checkstyle.xml
- zeus upload -t "application/webpack-stats+json" .artifacts/*webpack-stats.json

base_postgres: &postgres_default
python: 2.7
Expand All @@ -128,20 +145,19 @@ base_acceptance: &acceptance_default
- postgresql
before_install:
- *base_install
- *install_volta
- *start_snuba
- find "$NODE_DIR" -type d -empty -delete
- nvm install
- docker ps -a
install:
- ./bin/yarn install --frozen-lockfile
- *install_node_dependencies
- python setup.py install_egg_info
- pip install -U -e ".[dev]"
- |
CHROME_MAJOR_VERSION="$(dpkg -s google-chrome-stable | sed -nr 's/Version: ([0-9]+).*/\1/p')"
wget -N "https://chromedriver.storage.googleapis.com/$(curl https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_MAJOR_VERSION})/chromedriver_linux64.zip" -P ~/
- unzip ~/chromedriver_linux64.zip -d ~/
- rm ~/chromedriver_linux64.zip
- sudo install -m755 ~/chromedriver /usr/local/bin/
- install -m755 ~/chromedriver -C "${HOME}/bin"
before_script:
- psql -c 'create database sentry;' -U postgres

Expand All @@ -154,13 +170,13 @@ matrix:
- language: generic
name: 'Linter (Javascript)'
env: TEST_SUITE=lint-js
install:
- find "$NODE_DIR" -type d -empty -delete
before_install:
# Under a "generic" language environment, this will make travis pyenv error because there
# is no pyenv python installed.
- rm .python-version
- nvm install
- ./bin/yarn install --frozen-lockfile
- *install_volta
install:
- *install_node_dependencies

- python: 3.7
name: 'pre-commit hooks (includes python linting + format check) and dependency scanning'
Expand Down Expand Up @@ -206,19 +222,17 @@ matrix:
name: 'Frontend [test]'
env: TEST_SUITE=js
before_install:
- find "$NODE_DIR" -type d -empty -delete
- nvm install
- *install_volta
install:
- ./bin/yarn install --frozen-lockfile
- *install_node_dependencies

- python: 2.7
name: 'Frontend [build]'
env: TEST_SUITE=js-build
before_install:
- find "$NODE_DIR" -type d -empty -delete
- nvm install
- *install_volta
install:
- ./bin/yarn install --frozen-lockfile
- *install_node_dependencies

- python: 2.7
name: 'Command Line'
Expand Down Expand Up @@ -298,14 +312,16 @@ matrix:

# Deploy 'storybook' (component & style guide)
- name: 'Storybook Deploy'
language: node_js
language: generic
env: STORYBOOK_BUILD=1
before_install:
# travis pyenv will attempt to use .python-version, but the appropriate python version won't be installed.
# since we don't need python here, we have to remove this.
- rm .python-version
install: ./bin/yarn install --frozen-lockfile
script: ./bin/yarn run storybook-build
- *install_volta
install:
- *install_node_dependencies
script: yarn run storybook-build
after_success: .travis/deploy-storybook.sh
after_failure: skip

Expand Down
1 change: 0 additions & 1 deletion .yarnrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@

disable-self-update-check true
lastUpdateCheck 1562193150687
BYK marked this conversation as resolved.
Show resolved Hide resolved
yarn-path "./bin/yarn"
19 changes: 10 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
PIP := python -m pip --disable-pip-version-check
WEBPACK := NODE_ENV=production ./bin/yarn webpack
YARN := ./bin/yarn
WEBPACK := NODE_ENV=production yarn webpack

# Currently, this is only required to install black via pre-commit.
REQUIRED_PY3_VERSION := $(shell awk 'FNR == 2' .python-version)
Expand Down Expand Up @@ -80,17 +79,19 @@ setup-git: ensure-venv setup-git-config
@echo ""

node-version-check:
@test "$$(node -v)" = v"$$(cat .nvmrc)" || (echo 'node version does not match .nvmrc. Recommended to use https://github.com/volta-cli/volta'; exit 1)
@# Checks to see if node's version matches the one specified in package.json for Volta.
@node -pe "process.exit(Number(!(process.version == 'v' + require('./package.json').volta.node )))" || \
(echo 'Unexpected node version. Recommended to use https://github.com/volta-cli/volta'; exit 1)

install-js-dev: node-version-check
@echo "--> Installing Yarn packages (for development)"
# Use NODE_ENV=development so that yarn installs both dependencies + devDependencies
NODE_ENV=development $(YARN) install --frozen-lockfile
NODE_ENV=development yarn install --frozen-lockfile
# A common problem is with node packages not existing in `node_modules` even though `yarn install`
# says everything is up to date. Even though `yarn install` is run already, it doesn't take into
# account the state of the current filesystem (it only checks .yarn-integrity).
# Add an additional check against `node_modules`
$(YARN) check --verify-tree || $(YARN) install --check-files
yarn check --verify-tree || yarn install --check-files

install-py-dev: ensure-pinned-pip
@echo "--> Installing Sentry (for development)"
Expand Down Expand Up @@ -154,24 +155,24 @@ test-cli:

test-js-build: node-version-check
@echo "--> Running type check"
@$(YARN) run tsc
@yarn run tsc
@echo "--> Building static assets"
@$(WEBPACK) --profile --json > .artifacts/webpack-stats.json

test-js: node-version-check
@echo "--> Running JavaScript tests"
@$(YARN) run test
@yarn run test
@echo ""

test-js-ci: node-version-check
@echo "--> Running CI JavaScript tests"
@$(YARN) run test-ci
@yarn run test-ci
@echo ""

# builds and creates percy snapshots
test-styleguide:
@echo "--> Building and snapshotting styleguide"
@$(YARN) run snapshot
@yarn run snapshot
@echo ""

test-python:
Expand Down
Loading