summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJames E. Blair <jim@acmegating.com>2022-12-08 13:12:38 -0800
committerJames E. Blair <jim@acmegating.com>2022-12-20 08:57:53 -0800
commit6c8855ede4516f6d1299844fb1459706b3947261 (patch)
tree69d2f691207b2ec729e9745a218670bc45c9bb23 /tools
parent07ab843dd3bc22f6982aa8048285bd6a901bb2c1 (diff)
downloadzuul-6c8855ede4516f6d1299844fb1459706b3947261.tar.gz
Add noxfile and switch to nox
Tox v4 behaves significantly differently than v3, and some of the more complex things we do with tox would need an overhaul to continue to use it. Meanwhile, nox is much simpler and more flexible, so let's try using it. This adds a noxfile which should be equivalent to our tox.ini file. We still need to update the docs build (which involves changes to base jobs) before we can completely remove tox. Depends-On: https://review.opendev.org/868134 Change-Id: Ibebb0988d2702d310e46c437e58917db3f091382
Diffstat (limited to 'tools')
-rwxr-xr-xtools/yarn-build.sh73
1 files changed, 73 insertions, 0 deletions
diff --git a/tools/yarn-build.sh b/tools/yarn-build.sh
new file mode 100755
index 000000000..42eaffc7b
--- /dev/null
+++ b/tools/yarn-build.sh
@@ -0,0 +1,73 @@
+#!/bin/bash
+# Copyright 2018 Red Hat, Inc.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -ex
+
+# This script checks if yarn is installed in the current path. If it is not,
+# it will use nodeenv to install node, npm and yarn.
+# Finally, it will install pip things.
+if [[ ! $(command -v yarn) ]]
+then
+ pip install nodeenv
+ # Initialize nodeenv and tell it to re-use the currently active virtualenv
+ attempts=0
+ set +e
+ until nodeenv --python-virtualenv -n 16.14.0 ; do
+ ((attempts++))
+ if [[ $attempts > 2 ]]
+ then
+ echo "Failed creating nodeenv"
+ exit 1
+ fi
+ done
+ set -e
+ # Use -g because inside of the virtualenv '-g' means 'install into the'
+ # virtualenv - as opposed to installing into the local node_modules.
+ # Avoid writing a package-lock.json file since we don't use it.
+ # Avoid writing yarn into package.json.
+ npm install -g --no-package-lock --no-save yarn
+fi
+if [[ ! -f zuul/web/static/index.html ]]
+then
+ mkdir -p zuul/web/static
+ ln -sfn ../zuul/web/static web/build
+ pushd web/
+ if [[ -n "${YARN_REGISTRY}" ]]
+ then
+ echo "Using yarn registry: ${YARN_REGISTRY}"
+ sed -i "s#https://registry.yarnpkg.com#${YARN_REGISTRY}#" yarn.lock
+ fi
+
+ # Be forgiving of package retrieval errors
+ attempts=0
+ set +e
+ until yarn install; do
+ ((attempts++))
+ if [[ $attempts > 2 ]]
+ then
+ echo "Failed installing npm packages"
+ exit 1
+ fi
+ done
+ set -e
+
+ yarn build
+ if [[ -n "${YARN_REGISTRY}" ]]
+ then
+ echo "Resetting yarn registry"
+ sed -i "s#${YARN_REGISTRY}#https://registry.yarnpkg.com#" yarn.lock
+ fi
+ popd
+fi