Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-06-16 09:28:16 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-06-20 11:03:21 +0300
commit021ad9f33873be3d09f819a2973fb25a1ddcc25c (patch)
tree54f51abeabc9546a2f4104cd61dbf92fe8344bd9
parent5c18e86bfd7219fa2f44d4f4bca36ac02454f6b8 (diff)
ci: Deduplicate test script
Most of the test script logic is the same across all tests, with the only typical difference being which test target the test is running. Deduplicate this logic into the `test_template`.
-rw-r--r--.gitlab-ci.yml48
1 files changed, 20 insertions, 28 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 09b3dde5e..0c2b432b7 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -84,7 +84,7 @@ include:
- name: postgres:${POSTGRES_VERSION}
alias: postgres
command: ["postgres", "-c", "max_connections=500"]
- variables: &postgres_variables
+ variables: &test_variables
PGHOST: postgres
PGPORT: 5432
PGUSER: postgres
@@ -98,6 +98,14 @@ include:
# Create a directory for the unprivileged user that we're running tests as.
# This is required so that we can still store test reports successfully.
- install --directory --owner=${TEST_UID} --group=${TEST_UID} _unprivileged
+ # We need to explicitly build all prerequisites so that we can run tests unprivileged.
+ - make -j$(nproc) build prepare-tests $(pwd)/_build/tools/gocover-cobertura $(test "${GIT_VERSION}" = default && echo WITH_BUNDLED_GIT=YesPlease)
+ script:
+ # But the actual tests should run unprivileged. This assures that we pay
+ # proper attention to permission bits and that we don't modify the source
+ # directory.
+ - setpriv --reuid=${TEST_UID} --regid=${TEST_UID} --clear-groups --no-new-privs make ${TEST_TARGET} SKIP_RSPEC_BUILD=YesPlease $(test "${GIT_VERSION}" = default && echo WITH_BUNDLED_GIT=YesPlease)
+
after_script:
- |
# Checking for panics in ${TEST_FULL_OUTPUT}
@@ -166,43 +174,35 @@ build:binaries:
test:
<<: *test_definition
- script:
- # We need to prepare test dependencies as privileged user.
- - make -j$(nproc) build prepare-tests $(test "${GIT_VERSION}" = default && echo WITH_BUNDLED_GIT=YesPlease)
- # But the actual tests should run unprivileged. This assures that we pay
- # proper attention to permission bits and that we don't modify the source
- # directory.
- - setpriv --reuid=${TEST_UID} --regid=${TEST_UID} --clear-groups --no-new-privs make ${TARGET} SKIP_RSPEC_BUILD=YesPlease $(test "${GIT_VERSION}" = default && echo WITH_BUNDLED_GIT=YesPlease)
parallel:
matrix:
# The following jobs all test with our default Git version, which is
# using bundled Git binaries.
- GO_VERSION: [ "1.16", "1.17" ]
- TARGET: test
- - TARGET: [ test-with-proxies, test-with-praefect, race-go ]
+ TEST_TARGET: test
+ - TEST_TARGET: [ test-with-proxies, test-with-praefect, race-go ]
# We also verify that things work as expected with a non-bundled Git
# version matching our minimum required Git version.
- - TARGET: test
+ - TEST_TARGET: test
GIT_VERSION: "v2.33.0"
# Execute tests with our minimum required Postgres version, as well. If
# the minimum version changes, please change this to the new minimum
# version. Furthermore, please make sure to update the minimum required
# version in `datastore.CheckPostgresVersion()`.
- POSTGRES_VERSION: "11.14-alpine"
- TARGET: [ test, test-with-praefect ]
+ TEST_TARGET: [ test, test-with-praefect ]
test:coverage:
<<: *test_definition
coverage: /^total:\t+\(statements\)\t+\d+\.\d+%$/
- script:
- # We need to explicitly build all prerequisites so that we can run tests unprivileged.
- - make -j$(nproc) build prepare-tests $(pwd)/_build/tools/gocover-cobertura
- - setpriv --reuid=${TEST_UID} --regid=${TEST_UID} --clear-groups --no-new-privs make cover SKIP_RSPEC_BUILD=YesPlease
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: ${TEST_COVERAGE_DIR}/cobertura.xml
+ variables:
+ <<: *test_variables
+ TEST_TARGET: "cover"
test:pgbouncer:
<<: *test_definition
@@ -213,7 +213,7 @@ test:pgbouncer:
- name: bitnami/pgbouncer:${PGBOUNCER_VERSION}
alias: pgbouncer
variables:
- <<: *postgres_variables
+ <<: *test_variables
# The following variables are used by PgBouncer to connect to Postgres.
POSTGRESQL_HOST: "${PGHOST}"
# The image doesn't support setting `auth_user`, so we're cheating and use
@@ -235,22 +235,14 @@ test:pgbouncer:
# We need to enable per-build networking such that the PgBouncer service
# can reach Postgres.
FF_NETWORK_PER_BUILD: "true"
- before_script:
- - *test_before_script
- script:
- # We need to explicitly build all prerequisites so that we can run tests unprivileged.
- - make -j$(nproc) build prepare-tests
- - setpriv --reuid=${TEST_UID} --regid=${TEST_UID} --clear-groups --no-new-privs make test-with-praefect SKIP_RSPEC_BUILD=YesPlease
+ TEST_TARGET: "test-with-praefect"
test:nightly:
<<: *test_definition
- script:
- - make -j$(nproc) build prepare-tests
- - setpriv --reuid=${TEST_UID} --regid=${TEST_UID} --clear-groups --no-new-privs make ${TARGET} SKIP_RSPEC_BUILD=YesPlease
parallel:
matrix:
- GIT_VERSION: [ "master", "next" ]
- TARGET: [ test, test-with-proxies, test-with-praefect ]
+ TEST_TARGET: [ test, test-with-proxies, test-with-praefect ]
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
@@ -293,7 +285,7 @@ dbschema:
# available in the build image.
- postgres:11.13-alpine
variables:
- <<: *postgres_variables
+ <<: *test_variables
script:
- make dump-database-schema no-changes
artifacts: