From ce8e71b29e9ea9e67b69bff16c5b813e28ad6f25 Mon Sep 17 00:00:00 2001 From: Bheesham Persaud Date: Mon, 21 Oct 2024 15:15:53 -0400 Subject: [PATCH] ci Don't always re-install dependencies, which speeds up successive builds (Sample size: 1) Now (some output ommitted): # Do a clean build rm -rf .tox; time tox tox 17.25s user 8.84s system 49% cpu 52.303 total # Do a successive build time tox tox 1.72s user 0.38s system 86% cpu 2.436 total Before (some output ommitted): # Do a clean build rm -rf .tox; time tox tox 19.69s user 11.41s system 46% cpu 1:06.32 total # Do a successive build time tox tox 3.57s user 3.64s system 24% cpu 29.537 total It can go _faster_, but that'd come at the cost of having tox managing our dependencies when they change, so I opted not to do that. Though, we should keep that in our back pocket if we get to that point. --- ci/node-install.sh | 11 ++++++++++ tox.ini | 53 +++++++++++++++++----------------------------- 2 files changed, 30 insertions(+), 34 deletions(-) create mode 100755 ci/node-install.sh diff --git a/ci/node-install.sh b/ci/node-install.sh new file mode 100755 index 00000000..dd1a6a92 --- /dev/null +++ b/ci/node-install.sh @@ -0,0 +1,11 @@ +#!/bin/sh +set -eu + +if [ -f "$TOX_ENV_DIR/bin/node" ]; then + echo Node and friends already installed. + exit 0 +fi + +nodeenv --prebuilt -p --node 18.20.4 "$TOX_ENV_DIR" +npm install -g npm@latest +npm ci diff --git a/tox.ini b/tox.ini index ad53b435..6d19c72a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,19 +1,31 @@ [tox] env_list = - node, eslint, stylelint, pylint, py312 + pytest + pylint + eslint + stylelint minversion = 4.6.0 skip_missing_interpreters = false [testenv] -description = run the tests with pytest +description = base environment package = wheel wheel_build_env = .pkg deps = + pytest: -r requirements.txt + eslint,stylelint: nodeenv +commands_pre = + {es,style}lint: ./ci/node-install.sh +allowlist_externals = + {es,style}lint: ./ci/node-install.sh + +[testenv:pytest] +description = run the tests with pytest +deps = + {[testenv]deps} pytest>=6 pytest-mock>=3 - -rrequirements.txt -commands = - pytest {tty:--color=yes} {posargs} +commands = pytest {tty:--color=yes} {posargs} [testenv:pylint] description = run python black linters @@ -22,39 +34,12 @@ deps = black==24.8.0 commands = black --check {posargs: ./tests ./dashboard} -[testenv:node] -description = setup Node.js environment -skip_install = true -deps = - nodeenv -commands = - nodeenv --prebuilt -p --node 18.20.4 - npm install -g npm@latest -allowlist_externals = - node - npm - npx - [testenv:eslint] description = run eslint skip_install = true -deps = - {[testenv:node]deps} -commands = - {[testenv:node]commands} - npm ci - npm run lint:js -depends = node -allowlist_externals = npm +commands = npm run lint:js [testenv:stylelint] description = run stylelint skip_install = true -deps = - {[testenv:node]deps} -commands = - {[testenv:node]commands} - npm ci - npm run lint:css -depends = node -allowlist_externals = npm +commands = npm run lint:css