-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
95 lines (90 loc) · 3.11 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
stages:
- build
- test
variables:
GIT_STRATEGY: clone
CONTAINER_URL: "${NDIP_DOCKER_REPOSITORY}/${CI_PROJECT_PATH}"
# This import is for the func_rse_docker_* functions
before_script:
- curl https://code.ornl.gov/rse-deployment/rse-sharables/raw/master/rse-bash-modules.sh -O
- docker login -u $NDIP_DOCKER_USER -p $NDIP_DOCKER_PASSWORD $NDIP_DOCKER_REPOSITORY
- source rse-bash-modules.sh
- func_rse_docker_cleanup
after_script:
- curl https://code.ornl.gov/rse-deployment/rse-sharables/raw/master/rse-bash-modules.sh -O
- source rse-bash-modules.sh
- func_rse_docker_cleanup
- sudo chown -R gitlab-runner .
service-build:
stage: build
script:
- >
docker build
-f dockerfiles/Dockerfile
-t galaxy_tools .
- docker tag galaxy_tools $CONTAINER_URL:build-$CI_COMMIT_SHORT_SHA
- docker tag galaxy_tools $CONTAINER_URL:latest
- docker push $CONTAINER_URL:latest
- docker push $CONTAINER_URL:build-$CI_COMMIT_SHORT_SHA
when: manual
tags:
- rse-multi-builder
testing:
stage: test
variables:
ENVIRONMENT: "calvera-test"
GALAXY_URL: "https://calvera-test.ornl.gov"
API_KEY: $CALVERA_TEST_API_KEY
ADMIN_KEY: $CALVERA_TEST_ADMIN_KEY
script:
- echo "Running tests for all tools."
- cd `pwd`/tools/neutrons
- TEST_FOLDERS=`find . -type d -name retired -prune -o -type d -name dockerfiles -prune -o -type f -name "*.xml" -exec grep -l "<test>" {} + | awk -F/ 'BEGIN { OFS="/"; } { $NF=""; sub(/\/$/, ""); print }' | sort -u | sed 's/^\.\///'`
- echo testing in $TEST_FOLDERS
- GLOBAL_ERROR=0
- |
for FOLDER in $TEST_FOLDERS
do
docker run -v `pwd`:`pwd` --workdir `pwd`/$FOLDER $CONTAINER_URL \
planemo test --galaxy_root /galaxy --docker --no_conda_auto_init \
--test_output_json `pwd`/test_output_${FOLDER}.json \
--test_output_junit `pwd`/test_output_${FOLDER}.xml \
--galaxy_url $GALAXY_URL \
--galaxy_user_key $API_KEY \
--galaxy_admin_key $ADMIN_KEY 2>&1 | tee docker_output.log || ERROR=1
if grep -q "No tests were executed" docker_output.log && [ "$CI_COMMIT_BRANCH" == "main" ]; then
echo "Ignoring error: 'no tests were executed'"
ERROR=0
fi
GLOBAL_ERROR=$((GLOBAL_ERROR | ERROR))
done
- cd -
- |
if [ "$CI_PIPELINE_SOURCE" = "schedule" ] || [ "$CI_PIPELINE_SOURCE" = "web" ]; then
docker run \
-v `pwd`:`pwd` \
--workdir `pwd` \
-e CI_PIPELINE_ID \
-e CI_PROJECT_URL \
-e PROMETHEUS_URL \
-e ENVIRONMENT \
$CONTAINER_URL python3 scripts/push_to_gateway.py tools/neutrons
fi
- exit $GLOBAL_ERROR
artifacts:
when: always
reports:
junit: tools/neutrons/test_output*.xml
tags:
- rse-multi-builder
rules:
- if: '$CI_COMMIT_BRANCH == "dev"'
when: always
- if: '$CI_COMMIT_BRANCH == "main"'
variables:
ENVIRONMENT: "calvera"
GALAXY_URL: "https://calvera.ornl.gov"
API_KEY: $CALVERA_API_KEY
ADMIN_KEY: $CALVERA_ADMIN_KEY
when: always
- when: never