运行 持续集成 Meteor 应用程序上的 Facebook Flow
Run Facebook Flow on a Continuos Integration Meteor application
我有一个使用 Circle CI 作为持续集成服务的 Meteor 应用程序。
Facebook Flow 运行在本地使用以下 .flowconfig
:
[ignore]
.*/node_modules/.*
[options]
module.name_mapper='^\/\(.*\)$' -> '<PROJECT_ROOT>/'
module.name_mapper='^meteor\/\(.*\):\(.*\)$' -> '<PROJECT_ROOT>/.meteor/local/build/programs/server/packages/_'
module.name_mapper='^meteor\/\(.*\)$' -> '<PROJECT_ROOT>/.meteor/local/build/programs/server/packages/'
在 CI 中,我收到如下错误:
client/main.jsx:4
4: import { Meteor } from 'meteor/meteor';
^^^^^^^^^^^^^^^ meteor/meteor. Required module not found
Flow 好像找不到我的模块。重写规则不适用。通过 SSH 访问 Circle CI,我发现 <PROJECT_ROOT>/.meteor/local
目录不存在。
一旦我 运行 meteor
在 CI 机器上,目录就会出现。
问题:如果我 运行 meteor
Meteor 服务器将启动并且我的测试将超时。
据我所知我需要
- 调整我的
.flowconfig
或
- 想办法让 Meteor 在没有 运行ning
meteor
或 的情况下创建目录
- 找到一种方法在服务器 运行ning 后终止
meteor
进程。
我选择了第三个选项:
bbaja42 shared a script 保存程序的输出并在到达关键字时终止程序。
适应我的情况我有两个文件:
ci-tests.sh
#!/bin/sh
# Check if the output directory exits. Flow needs the modules there.
if [ ! -d ".meteor/local/build/programs/server/packages" ]; then
echo "Meteor build directory does not exist. Starting Meteor."
# Run Meteor so the output directory is built.
./build-and-kill-meteor.sh
else
echo "Meteor build directory exists"
fi
./node_modules/.bin/flow --json
if [ $? -ne 0 ] ; then
exit 1
fi
build-and-kill-meteor.sh
#!/bin/bash
OUTPUT=/tmp/meteor-launch.log
PROGRAM=meteor
$PROGRAM > $OUTPUT &
PID=$!
echo Program is running under pid: $PID
#Every 10 seconds, check requirements
while true; do
tail -1 $OUTPUT
grep "App running at: http://localhost" $OUTPUT
if [ $? -eq 0 ] ; then
break
fi
sleep 10
done
kill $PID || echo "Killing process with pid $PID failed, try manual kill with -9 argument"
我 运行 遇到了同样的问题,并根据 OP 的回答提出了我自己的推导。我 运行 在 每个 CI 构建这个脚本以确保 Meteor 将始终安装我随附的任何新大气包。
#!/bin/bash
# Install meteor
if [ -d ~/.meteor ]; then sudo ln -s ~/.meteor/meteor /usr/local/bin/meteor; fi
if [ ! -e $HOME/.meteor/meteor ]; then curl https://install.meteor.com | sh; fi
OUTPUT=/tmp/meteor-launch.log
PROGRAM=meteor
$PROGRAM > $OUTPUT &
PID=$!
echo Program is running under pid: $PID
# Start meteor to install atmosphere packages
while true; do
tail -1 $OUTPUT
grep "Your application is crashing." $OUTPUT
# Cancel the program once meteor has started
if [ $? -eq 0 ] ; then
break
fi
sleep 10
done
kill $PID || echo "Killing process with pid $PID failed, try manual kill with -9 argument."
我有一个使用 Circle CI 作为持续集成服务的 Meteor 应用程序。
Facebook Flow 运行在本地使用以下 .flowconfig
:
[ignore]
.*/node_modules/.*
[options]
module.name_mapper='^\/\(.*\)$' -> '<PROJECT_ROOT>/'
module.name_mapper='^meteor\/\(.*\):\(.*\)$' -> '<PROJECT_ROOT>/.meteor/local/build/programs/server/packages/_'
module.name_mapper='^meteor\/\(.*\)$' -> '<PROJECT_ROOT>/.meteor/local/build/programs/server/packages/'
在 CI 中,我收到如下错误:
client/main.jsx:4
4: import { Meteor } from 'meteor/meteor';
^^^^^^^^^^^^^^^ meteor/meteor. Required module not found
Flow 好像找不到我的模块。重写规则不适用。通过 SSH 访问 Circle CI,我发现 <PROJECT_ROOT>/.meteor/local
目录不存在。
一旦我 运行 meteor
在 CI 机器上,目录就会出现。
问题:如果我 运行 meteor
Meteor 服务器将启动并且我的测试将超时。
据我所知我需要
- 调整我的
.flowconfig
或 - 想办法让 Meteor 在没有 运行ning
meteor
或 的情况下创建目录
- 找到一种方法在服务器 运行ning 后终止
meteor
进程。
我选择了第三个选项:
bbaja42 shared a script 保存程序的输出并在到达关键字时终止程序。
适应我的情况我有两个文件:
ci-tests.sh
#!/bin/sh
# Check if the output directory exits. Flow needs the modules there.
if [ ! -d ".meteor/local/build/programs/server/packages" ]; then
echo "Meteor build directory does not exist. Starting Meteor."
# Run Meteor so the output directory is built.
./build-and-kill-meteor.sh
else
echo "Meteor build directory exists"
fi
./node_modules/.bin/flow --json
if [ $? -ne 0 ] ; then
exit 1
fi
build-and-kill-meteor.sh
#!/bin/bash
OUTPUT=/tmp/meteor-launch.log
PROGRAM=meteor
$PROGRAM > $OUTPUT &
PID=$!
echo Program is running under pid: $PID
#Every 10 seconds, check requirements
while true; do
tail -1 $OUTPUT
grep "App running at: http://localhost" $OUTPUT
if [ $? -eq 0 ] ; then
break
fi
sleep 10
done
kill $PID || echo "Killing process with pid $PID failed, try manual kill with -9 argument"
我 运行 遇到了同样的问题,并根据 OP 的回答提出了我自己的推导。我 运行 在 每个 CI 构建这个脚本以确保 Meteor 将始终安装我随附的任何新大气包。
#!/bin/bash
# Install meteor
if [ -d ~/.meteor ]; then sudo ln -s ~/.meteor/meteor /usr/local/bin/meteor; fi
if [ ! -e $HOME/.meteor/meteor ]; then curl https://install.meteor.com | sh; fi
OUTPUT=/tmp/meteor-launch.log
PROGRAM=meteor
$PROGRAM > $OUTPUT &
PID=$!
echo Program is running under pid: $PID
# Start meteor to install atmosphere packages
while true; do
tail -1 $OUTPUT
grep "Your application is crashing." $OUTPUT
# Cancel the program once meteor has started
if [ $? -eq 0 ] ; then
break
fi
sleep 10
done
kill $PID || echo "Killing process with pid $PID failed, try manual kill with -9 argument."