Skip to content

Commit 66893d9

Browse files
authored
[BugFix] Enable the "exit on error" mode in CI scripts (#333)
* rm randount log message * use scripts * add run_command
1 parent 335ab13 commit 66893d9

15 files changed

+130
-88
lines changed

.github/workflows/blas-op-test.yaml

+1-10
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,4 @@ jobs:
3030
echo "This is a push event. The relate PR number is ${PR_NUMBER}"
3131
PR_ID=${PR_NUMBER}
3232
fi
33-
ID_SHA="${PR_ID}-${GITHUB_SHA}"
34-
echo ID_SHA $ID_SHA
35-
PR_ID_DIR="PR${PR_ID}"
36-
37-
COVERAGE_ARGS="--parallel-mode --omit "*/.flaggems/*","*/usr/lib/*" --source=./src,./tests --data-file=${ID_SHA}-op"
38-
bash tools/pytest_mark_check.sh && \
39-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_blas_ops.py
40-
41-
mkdir -p /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
42-
mv ${ID_SHA}* /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
33+
bash tools/blas-op-test.sh ${PR_ID}

.github/workflows/model-test.yaml

+1-10
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,11 @@ jobs:
2323
echo "current dir: $(pwd)"
2424
git config --global --add safe.directory ../FlagGems
2525
if [ "${{ github.event_name }}" == "pull_request" ]; then
26-
echo "current dir: $(pwd)"
2726
echo "This is a pull request event. PR number is ${{ github.event.pull_request.number }}"
2827
PR_ID=${{ github.event.pull_request.number }}
2928
elif [ "${{ github.event_name }}" == "push" ]; then
3029
PR_NUMBER=$(git log -1 --pretty=format:'%s' | grep -oE '#[0-9]+' | grep -oE '[0-9]+')
3130
echo "This is a push event. The relate PR number is ${PR_NUMBER}"
3231
PR_ID=${PR_NUMBER}
3332
fi
34-
ID_SHA="${PR_ID}-${GITHUB_SHA}"
35-
echo ID_SHA $ID_SHA
36-
PR_ID_DIR="PR${PR_ID}"
37-
38-
COVERAGE_ARGS="--parallel-mode --omit "*/.flaggems/*","*/usr/lib/*" --source=./src,./tests --data-file=${ID_SHA}-model"
39-
coverage run ${COVERAGE_ARGS} -m pytest -s examples/model_bert_test.py
40-
41-
mkdir -p /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
42-
mv ${ID_SHA}* /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
33+
bash tools/model-test.sh ${PR_ID}

.github/workflows/op-test-quick-cpu.yaml

+1-18
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,11 @@ jobs:
2323
echo "current dir: $(pwd)"
2424
git config --global --add safe.directory ../FlagGems
2525
if [ "${{ github.event_name }}" == "pull_request" ]; then
26-
echo "current dir: $(pwd)"
2726
echo "This is a pull request event. PR number is ${{ github.event.pull_request.number }}"
2827
PR_ID=${{ github.event.pull_request.number }}
2928
elif [ "${{ github.event_name }}" == "push" ]; then
3029
PR_NUMBER=$(git log -1 --pretty=format:'%s' | grep -oE '#[0-9]+' | grep -oE '[0-9]+')
3130
echo "This is a push event. The relate PR number is ${PR_NUMBER}"
3231
PR_ID=${PR_NUMBER}
3332
fi
34-
ID_SHA="${PR_ID}-${GITHUB_SHA}"
35-
echo ID_SHA $ID_SHA
36-
PR_ID_DIR="PR${PR_ID}"
37-
38-
COVERAGE_ARGS="--parallel-mode --omit "*/.flaggems/*","*/usr/lib/*" --source=./src,./tests --data-file=${ID_SHA}-op"
39-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_blas_ops.py --ref=cpu --mode=quick && \
40-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_reduction_ops.py --ref=cpu --mode=quick && \
41-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_general_reduction_ops.py --ref=cpu --mode=quick && \
42-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_norm_ops.py --ref=cpu --mode=quick && \
43-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_unary_pointwise_ops.py --ref=cpu --mode=quick && \
44-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_binary_pointwise_ops.py --ref=cpu --mode=quick && \
45-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_special_ops.py --ref=cpu --mode=quick && \
46-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_pointwise_type_promotion.py --ref=cpu --mode=quick && \
47-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_tensor_constructor_ops.py --ref=cpu --mode=quick
48-
49-
mkdir -p /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
50-
mv ${ID_SHA}* /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
33+
bash tools/op-test-quick-cpu.sh ${PR_ID}

.github/workflows/op-utils-test.yaml

+1-12
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,11 @@ jobs:
2323
echo "current dir: $(pwd)"
2424
git config --global --add safe.directory ../FlagGems
2525
if [ "${{ github.event_name }}" == "pull_request" ]; then
26-
echo "current dir: $(pwd)"
2726
echo "This is a pull request event. PR number is ${{ github.event.pull_request.number }}"
2827
PR_ID=${{ github.event.pull_request.number }}
2928
elif [ "${{ github.event_name }}" == "push" ]; then
3029
PR_NUMBER=$(git log -1 --pretty=format:'%s' | grep -oE '#[0-9]+' | grep -oE '[0-9]+')
3130
echo "This is a push event. The relate PR number is ${PR_NUMBER}"
3231
PR_ID=${PR_NUMBER}
3332
fi
34-
ID_SHA="${PR_ID}-${GITHUB_SHA}"
35-
echo ID_SHA $ID_SHA
36-
PR_ID_DIR="PR${PR_ID}"
37-
38-
COVERAGE_ARGS="--parallel-mode --omit "*/.flaggems/*","*/usr/lib/*" --source=./src,./tests --data-file=${ID_SHA}-op"
39-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_libentry.py && \
40-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_shape_utils.py && \
41-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_tensor_wrapper.py
42-
43-
mkdir -p /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
44-
mv ${ID_SHA}* /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
33+
bash tools/op-utils-test.sh ${PR_ID}

.github/workflows/pointwise-op-test.yaml

+1-14
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,11 @@ jobs:
2323
echo "current dir: $(pwd)"
2424
git config --global --add safe.directory ../FlagGems
2525
if [ "${{ github.event_name }}" == "pull_request" ]; then
26-
echo "current dir: $(pwd)"
2726
echo "This is a pull request event. PR number is ${{ github.event.pull_request.number }}"
2827
PR_ID=${{ github.event.pull_request.number }}
2928
elif [ "${{ github.event_name }}" == "push" ]; then
3029
PR_NUMBER=$(git log -1 --pretty=format:'%s' | grep -oE '#[0-9]+' | grep -oE '[0-9]+')
3130
echo "This is a push event. The relate PR number is ${PR_NUMBER}"
3231
PR_ID=${PR_NUMBER}
3332
fi
34-
ID_SHA="${PR_ID}-${GITHUB_SHA}"
35-
echo ID_SHA $ID_SHA
36-
PR_ID_DIR="PR${PR_ID}"
37-
38-
COVERAGE_ARGS="--parallel-mode --omit "*/.flaggems/*","*/usr/lib/*" --source=./src,./tests --data-file=${ID_SHA}-op"
39-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_pointwise_dynamic.py && \
40-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_unary_pointwise_ops.py && \
41-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_unary_pointwise_ops.py -m abs --record=log && \
42-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_binary_pointwise_ops.py && \
43-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_pointwise_type_promotion.py
44-
45-
mkdir -p /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
46-
mv ${ID_SHA}* /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
33+
bash tools/pointwise-op-test.sh ${PR_ID}

.github/workflows/reduction-op-test.yaml

+1-12
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,11 @@ jobs:
2323
echo "current dir: $(pwd)"
2424
git config --global --add safe.directory ../FlagGems
2525
if [ "${{ github.event_name }}" == "pull_request" ]; then
26-
echo "current dir: $(pwd)"
2726
echo "This is a pull request event. PR number is ${{ github.event.pull_request.number }}"
2827
PR_ID=${{ github.event.pull_request.number }}
2928
elif [ "${{ github.event_name }}" == "push" ]; then
3029
PR_NUMBER=$(git log -1 --pretty=format:'%s' | grep -oE '#[0-9]+' | grep -oE '[0-9]+')
3130
echo "This is a push event. The relate PR number is ${PR_NUMBER}"
3231
PR_ID=${PR_NUMBER}
3332
fi
34-
ID_SHA="${PR_ID}-${GITHUB_SHA}"
35-
echo ID_SHA $ID_SHA
36-
PR_ID_DIR="PR${PR_ID}"
37-
38-
COVERAGE_ARGS="--parallel-mode --omit "*/.flaggems/*","*/usr/lib/*" --source=./src,./tests --data-file=${ID_SHA}-op"
39-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_reduction_ops.py && \
40-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_general_reduction_ops.py && \
41-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_norm_ops.py
42-
43-
mkdir -p /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
44-
mv ${ID_SHA}* /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
33+
bash tools/reduction-op-test.sh ${PR_ID}

.github/workflows/special-op-test.yaml

+1-12
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,11 @@ jobs:
2323
echo "current dir: $(pwd)"
2424
git config --global --add safe.directory ../FlagGems
2525
if [ "${{ github.event_name }}" == "pull_request" ]; then
26-
echo "current dir: $(pwd)"
2726
echo "This is a pull request event. PR number is ${{ github.event.pull_request.number }}"
2827
PR_ID=${{ github.event.pull_request.number }}
2928
elif [ "${{ github.event_name }}" == "push" ]; then
3029
PR_NUMBER=$(git log -1 --pretty=format:'%s' | grep -oE '#[0-9]+' | grep -oE '[0-9]+')
3130
echo "This is a push event. The relate PR number is ${PR_NUMBER}"
3231
PR_ID=${PR_NUMBER}
3332
fi
34-
ID_SHA="${PR_ID}-${GITHUB_SHA}"
35-
echo ID_SHA $ID_SHA
36-
PR_ID_DIR="PR${PR_ID}"
37-
38-
COVERAGE_ARGS="--parallel-mode --omit "*/.flaggems/*","*/usr/lib/*" --source=./src,./tests --data-file=${ID_SHA}-op"
39-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_special_ops.py && \
40-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_tensor_constructor_ops.py && \
41-
coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_distribution_ops.py
42-
43-
mkdir -p /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
44-
mv ${ID_SHA}* /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
33+
bash tools/special-op-test.sh ${PR_ID}

tools/blas-op-test.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -e
4+
PR_ID=$1
5+
ID_SHA="${PR_ID}-${GITHUB_SHA}"
6+
echo ID_SHA $ID_SHA
7+
8+
source tools/run_command.sh
9+
COVERAGE_ARGS="--parallel-mode --omit "*/.flaggems/*","*/usr/lib/*" --source=./src,./tests --data-file=${ID_SHA}-op"
10+
bash tools/pytest_mark_check.sh && \
11+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_blas_ops.py
12+
13+
mkdir -p /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
14+
mv ${ID_SHA}* /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}

tools/model-test.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e
4+
PR_ID=$1
5+
ID_SHA="${PR_ID}-${GITHUB_SHA}"
6+
echo ID_SHA $ID_SHA
7+
8+
source tools/run_command.sh
9+
COVERAGE_ARGS="--parallel-mode --omit "*/.flaggems/*","*/usr/lib/*" --source=./src,./tests --data-file=${ID_SHA}-model"
10+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s examples/model_bert_test.py
11+
12+
mkdir -p /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
13+
mv ${ID_SHA}* /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}

tools/op-test-quick-cpu.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -e
4+
PR_ID=$1
5+
ID_SHA="${PR_ID}-${GITHUB_SHA}"
6+
echo ID_SHA $ID_SHA
7+
8+
source tools/run_command.sh
9+
COVERAGE_ARGS="--parallel-mode --omit "*/.flaggems/*","*/usr/lib/*" --source=./src,./tests --data-file=${ID_SHA}-op"
10+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_blas_ops.py --ref=cpu --mode=quick && \
11+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_reduction_ops.py --ref=cpu --mode=quick && \
12+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_general_reduction_ops.py --ref=cpu --mode=quick && \
13+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_norm_ops.py --ref=cpu --mode=quick && \
14+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_unary_pointwise_ops.py --ref=cpu --mode=quick && \
15+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_binary_pointwise_ops.py --ref=cpu --mode=quick && \
16+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_special_ops.py --ref=cpu --mode=quick && \
17+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_pointwise_type_promotion.py --ref=cpu --mode=quick && \
18+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_tensor_constructor_ops.py --ref=cpu --mode=quick
19+
20+
mkdir -p /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
21+
mv ${ID_SHA}* /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}

tools/op-utils-test.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
set -e
4+
PR_ID=$1
5+
ID_SHA="${PR_ID}-${GITHUB_SHA}"
6+
echo ID_SHA $ID_SHA
7+
8+
echo $PWD
9+
source tools/run_command.sh
10+
COVERAGE_ARGS="--parallel-mode --omit "*/.flaggems/*","*/usr/lib/*" --source=./src,./tests --data-file=${ID_SHA}-op"
11+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_libentry.py && \
12+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_shape_utils.py && \
13+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_tensor_wrapper.py
14+
15+
mkdir -p /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
16+
mv ${ID_SHA}* /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}

tools/pointwise-op-test.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -e
4+
PR_ID=$1
5+
ID_SHA="${PR_ID}-${GITHUB_SHA}"
6+
echo ID_SHA $ID_SHA
7+
8+
source tools/run_command.sh
9+
COVERAGE_ARGS="--parallel-mode --omit "*/.flaggems/*","*/usr/lib/*" --source=./src,./tests --data-file=${ID_SHA}-op"
10+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_pointwise_dynamic.py && \
11+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_unary_pointwise_ops.py && \
12+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_unary_pointwise_ops.py -m abs --record=log && \
13+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_binary_pointwise_ops.py && \
14+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_pointwise_type_promotion.py
15+
16+
mkdir -p /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
17+
mv ${ID_SHA}* /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}

tools/reduction-op-test.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -e
4+
PR_ID=$1
5+
ID_SHA="${PR_ID}-${GITHUB_SHA}"
6+
echo ID_SHA $ID_SHA
7+
8+
source tools/run_command.sh
9+
COVERAGE_ARGS="--parallel-mode --omit "*/.flaggems/*","*/usr/lib/*" --source=./src,./tests --data-file=${ID_SHA}-op"
10+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_reduction_ops.py && \
11+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_general_reduction_ops.py && \
12+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_norm_ops.py
13+
14+
mkdir -p /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
15+
mv ${ID_SHA}* /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}

tools/run_command.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
run_command() {
4+
echo "Running command: $@"
5+
"$@"
6+
local status=$?
7+
if [ $status -ne 0 ]; then
8+
echo "Command '$1' failed with exit status $status."
9+
exit $status
10+
fi
11+
return $status
12+
}

tools/special-op-test.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -e
4+
PR_ID=$1
5+
ID_SHA="${PR_ID}-${GITHUB_SHA}"
6+
echo ID_SHA $ID_SHA
7+
8+
source tools/run_command.sh
9+
COVERAGE_ARGS="--parallel-mode --omit "*/.flaggems/*","*/usr/lib/*" --source=./src,./tests --data-file=${ID_SHA}-op"
10+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_special_ops.py && \
11+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_tensor_constructor_ops.py && \
12+
run_command coverage run ${COVERAGE_ARGS} -m pytest -s tests/test_distribution_ops.py
13+
14+
mkdir -p /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}
15+
mv ${ID_SHA}* /home/zhangbo/PR_Coverage/PR${PR_ID}/${ID_SHA}

0 commit comments

Comments
 (0)