Commit f65e9c6e authored by André Anjos's avatar André Anjos 💬

[conda] Fix CI by using a template system for linking the editor installation during test

parent 7593b96b
Pipeline #27475 canceled with stages
in 23 minutes and 4 seconds
......@@ -112,3 +112,5 @@ conda-bld/
# built JS files
beat/editor/js
prefix/
conda/js/package.json
conda/js/webpack.config.js
......@@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"start": "cross-env NODE_ENV=debug webpack-dev-server --hot",
"prebuild": "rimraf ../editor",
"prebuild": "rimraf %%jsfiles%%",
"build": "cross-env NODE_ENV=production webpack",
"test-start": "cross-env BABEL_ENV=test NODE_ENV=test karma start --no-single-run",
"test": "cross-env BABEL_ENV=test NODE_ENV=test karma start",
......
......@@ -5,7 +5,7 @@ const VisualizerPlugin = require('webpack-visualizer-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin')
const dist = resolve(__dirname, '../editor');
const dist = resolve(__dirname, '%%jsfiles%%');
const isExternal = (module) => module.context && module.context.indexOf('node_modules') === -1;
......
......@@ -5,13 +5,30 @@
import os
import sys
import pkg_resources
import beat.editor
import glob
# destination "linked" directory
dest = os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), 'editor')
if os.path.exists(dest):
os.unlink(dest)
src = pkg_resources.resource_filename(beat.editor.__name__, 'js')
os.symlink(src, dest)
print('%s -> %s' % (src, dest))
key = '%%jsfiles%%'
scriptdir = os.path.realpath(os.path.dirname(sys.argv[0]))
try:
import pkg_resources
import beat.editorx
jsfiles = pkg_resources.resource_filename(beat.editor.__name__, 'js')
print('Running test (beat.editor import suceeded) - setting javascript path to %s' % jsfiles)
except ImportError as e:
jsfiles = os.path.realpath(os.path.join(scriptdir, '..', 'beat', 'editor',
'js'))
print('Running build (beat.editor import failed) - setting javascript path to %s' % jsfiles)
if not os.path.exists(jsfiles):
print(' Creating directory %s' % jsfiles)
os.makedirs(jsfiles)
templatedir = os.path.realpath(os.path.join(scriptdir, 'js'))
for k in glob.glob(os.path.join(templatedir, '*.template')):
output = os.path.splitext(k)[0]
print(' ** Replacing template %s -> %s' % (k, output))
with open(k, 'rt') as reader, open(output, 'wt') as writer:
for line in reader:
if key in line: line = line.replace(key, jsfiles)
writer.writelines([line])
......@@ -9,12 +9,12 @@ build:
run_exports:
- {{ pin_subpackage(name) }}
script:
- cd {{ environ.get('RECIPE_DIR') }}/js
- mkdir {{ environ.get('RECIPE_DIR') }}/../beat/editor/js
- ln -s {{ environ.get('RECIPE_DIR') }}/../beat/editor/js {{ environ.get('RECIPE_DIR') }}/editor
- cd {{ environ.get('RECIPE_DIR') }}
- python linkeditor.py
- cd js
- npm install
- npm run build
- cd {{ environ.get('RECIPE_DIR') + '/..' }}
- cd ../..
{% if environ.get('BUILD_EGG') %}
- python setup.py sdist --formats=zip
{% endif %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment