2023-01-13 00:05:48 +05:30
|
|
|
# Read more about the feature here: https://docs.gitlab.com/ee/ci/testing/browser_performance_testing.html
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
browser_performance:
|
|
|
|
stage: performance
|
2022-05-07 20:08:51 +05:30
|
|
|
image: docker:20.10.12
|
2021-06-08 01:23:25 +05:30
|
|
|
allow_failure: true
|
|
|
|
variables:
|
|
|
|
DOCKER_TLS_CERTDIR: ""
|
|
|
|
SITESPEED_IMAGE: sitespeedio/sitespeed.io
|
|
|
|
SITESPEED_VERSION: 14.1.0
|
|
|
|
SITESPEED_OPTIONS: ''
|
|
|
|
services:
|
2022-05-07 20:08:51 +05:30
|
|
|
- name: 'docker:20.10.12-dind'
|
|
|
|
command: ['--tls=false', '--host=tcp://0.0.0.0:2375']
|
2021-06-08 01:23:25 +05:30
|
|
|
script:
|
|
|
|
- |
|
|
|
|
if ! docker info &>/dev/null; then
|
2022-05-07 20:08:51 +05:30
|
|
|
if [ -z "$DOCKER_HOST" ] && [ -n "$KUBERNETES_PORT" ]; then
|
2021-06-08 01:23:25 +05:30
|
|
|
export DOCKER_HOST='tcp://localhost:2375'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
- export CI_ENVIRONMENT_URL=$(cat environment_url.txt)
|
|
|
|
- mkdir gitlab-exporter
|
|
|
|
# Busybox wget does not support proxied HTTPS, get the real thing.
|
|
|
|
# See https://gitlab.com/gitlab-org/gitlab/-/issues/287611.
|
2022-05-07 20:08:51 +05:30
|
|
|
- (env | grep -i _proxy= >/dev/null 2>&1) && apk --no-cache add wget
|
2021-06-08 01:23:25 +05:30
|
|
|
- wget -O gitlab-exporter/index.js https://gitlab.com/gitlab-org/gl-performance/raw/1.1.0/index.js
|
|
|
|
- mkdir sitespeed-results
|
|
|
|
- |
|
|
|
|
function propagate_env_vars() {
|
|
|
|
CURRENT_ENV=$(printenv)
|
|
|
|
|
|
|
|
for VAR_NAME; do
|
|
|
|
echo $CURRENT_ENV | grep "${VAR_NAME}=" > /dev/null && echo "--env $VAR_NAME "
|
|
|
|
done
|
|
|
|
}
|
|
|
|
- |
|
|
|
|
if [ -f .gitlab-urls.txt ]
|
|
|
|
then
|
|
|
|
sed -i -e 's@^@'"$CI_ENVIRONMENT_URL"'@' .gitlab-urls.txt
|
|
|
|
docker run \
|
|
|
|
$(propagate_env_vars \
|
|
|
|
auto_proxy \
|
|
|
|
https_proxy \
|
|
|
|
http_proxy \
|
|
|
|
no_proxy \
|
|
|
|
AUTO_PROXY \
|
|
|
|
HTTPS_PROXY \
|
|
|
|
HTTP_PROXY \
|
|
|
|
NO_PROXY \
|
|
|
|
) \
|
|
|
|
--shm-size=1g --rm -v "$(pwd)":/sitespeed.io $SITESPEED_IMAGE:$SITESPEED_VERSION --plugins.add ./gitlab-exporter --cpu --outputFolder sitespeed-results .gitlab-urls.txt $SITESPEED_OPTIONS
|
|
|
|
else
|
|
|
|
docker run \
|
|
|
|
$(propagate_env_vars \
|
|
|
|
auto_proxy \
|
|
|
|
https_proxy \
|
|
|
|
http_proxy \
|
|
|
|
no_proxy \
|
|
|
|
AUTO_PROXY \
|
|
|
|
HTTPS_PROXY \
|
|
|
|
HTTP_PROXY \
|
|
|
|
NO_PROXY \
|
|
|
|
) \
|
|
|
|
--shm-size=1g --rm -v "$(pwd)":/sitespeed.io $SITESPEED_IMAGE:$SITESPEED_VERSION --plugins.add ./gitlab-exporter --cpu --outputFolder sitespeed-results "$CI_ENVIRONMENT_URL" $SITESPEED_OPTIONS
|
|
|
|
fi
|
|
|
|
- mv sitespeed-results/data/performance.json browser-performance.json
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- sitespeed-results/
|
|
|
|
reports:
|
|
|
|
browser_performance: browser-performance.json
|
|
|
|
rules:
|
2021-12-11 22:18:48 +05:30
|
|
|
- if: '($CI_KUBERNETES_ACTIVE == null || $CI_KUBERNETES_ACTIVE == "") && ($KUBECONFIG == null || $KUBECONFIG == "")'
|
2021-06-08 01:23:25 +05:30
|
|
|
when: never
|
2021-09-04 01:27:46 +05:30
|
|
|
- if: '$BROWSER_PERFORMANCE_DISABLED'
|
2021-06-08 01:23:25 +05:30
|
|
|
when: never
|
|
|
|
- if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
|