Commit b102186b authored by Mikaël Salson's avatar Mikaël Salson
Browse files

gitlab-ci: Launch a job several times to assess its reproducibility

The jobs are taken from .gitlab-ci.ymls provided to a script.
The script is in charge of repeating the jobs the number of times required.

See #4592
parent 7d611276
Pipeline #318181 passed with stages
in 79 minutes and 31 seconds
......@@ -65,6 +65,7 @@ test_germlines:
# Includes
include:
- local: '.gitlab-test-reproducibility.yml' # launch tests many times
- local: '/doc/.gitlab-ci.yml' # Doc
- local: 'algo/.gitlab-ci-compilers.yml' # Stage multiple_tests
- local: 'algo/.gitlab-ci.yml' # Vidjil-algo pipelines
......
generate_server_reproducibility_yml:
stage: test_tools
variables:
REPEAT: 30
script:
- tools/repeat-ci.sh server/.gitlab-ci.yml $REPEAT .gitlab-ci.yml .test_server_base .test_cypress_base -- .gitlab-ci.yml browser/.gitlab-ci.yml | grep -v .need > server-repro.yml
needs: []
artifacts:
paths:
- server-repro.yml
generate_client_reproducibility_yml:
stage: test_tools
variables:
REPEAT: 30
script:
- tools/repeat-ci.sh browser/.gitlab-ci.yml $REPEAT .gitlab-ci.yml | grep -v .need > client-repro.yml
needs: []
artifacts:
paths:
- client-repro.yml
server_reproducibility:
stage: test_cypress_server
needs: [generate_server_reproducibility_yml]
trigger:
include:
- artifact: server-repro.yml
job: generate_server_reproducibility_yml
strategy: depend
when: manual
allow_failure: true
browser_reproducibility:
stage: test_cypress_client
needs: [generate_client_reproducibility_yml]
trigger:
include:
- artifact: client-repro.yml
job: generate_client_reproducibility_yml
strategy: depend
when: manual
allow_failure: true
#!/bin/bash
if [ $# -lt 3 ]; then
echo "Usage: $0 <gitlab-ci> <repeats> <main-gitlab-ci> [ <template_names>+ -- <other_gitlab_ci> ]
Take the <gitlab-ci> and repeats its content several times.
If the [ <template_names>+ -- <other_gitlab_ci> ] are provided we get the template jobs, whose names start as in <template_names>, from the <other_gitlab_ci> files and and copy them in the resulting YML." >&2
exit 1
fi
CI_FILE="$1"
REPEATS=$2
MAIN="$3"
shift 3
TEMPLATES=$(sed -rn '/^\./,/^$/p' $CI_FILE)
STAGES=$(sed -rn '/^stages:/,/^$/p' $MAIN)
BEFORE_SCRIPT=$(sed -rn '/^before_script:/,/^$/p' $MAIN)
template_names=()
if [ $# -gt 0 ]; then
while [ "$1" != "--" ]; do
template_names+=( "$1" )
shift
done
shift
for template in ${template_names[@]}; do
TEMPLATES="$TEMPLATES"$'\n'$(sed -n '/^'$template'/,/^$/p' $*)
done
fi
NEW_CI=$(mktemp)
sed -r '/^\./,/^$/d' $CI_FILE > $NEW_CI
TEMP=$(mktemp)
for i in `seq 1 $REPEATS`; do
cp $NEW_CI $NEW_CI.$i
# Rewrite the job name by appending the job number
sed -ri 's/^([a-zA-Z].*):\s*$/\1_'$(printf "%03d" $i)':/' $NEW_CI.$i
done
rm -f $NEW_CI
echo "$BEFORE_SCRIPT"
echo "$STAGES"
echo "$TEMPLATES"
cat $NEW_CI.*
rm -f $NEW_CI.*
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