summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: 5120f60f5c3e6b5370ae03060ffe4ab6e17faea3 (plain)
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
image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-debian:10-${DOCKER_IMAGE_VERSION}

cache:
  key: "$CI_JOB_NAME-"
  paths:
    - cache/

stages:
  - test
  - post
  - publish

variables:
  # SAST related variables
  SAST_DEFAULT_ANALYZERS: "bandit, secrets"
  SAST_DISABLE_DIND: "true"
  SAST_GOSEC_LEVEL: 2
  CI_PROJECT_REPOSITORY_LANGUAGES: "python"

  # Our own variables
  # Version of the docker images we should use for all the images.
  # This is taken from buildstream/buildstream-docker-images
  DOCKER_IMAGE_VERSION: master-177137613
  PYTEST_ADDOPTS: "--color=yes"
  INTEGRATION_CACHE: "${CI_PROJECT_DIR}/cache/integration-cache"
  PYTEST_ARGS: "--color=yes --integration -n 2"
  TEST_COMMAND: "tox -- ${PYTEST_ARGS}"
  TOXENV: py36, py37, py38-nocover, py36-plugins, py37-plugins, py38-plugins-nocover
  COVERAGE_PREFIX: "${CI_JOB_NAME}."


#####################################################
#                    Test stage                     #
#####################################################

# Run premerge commits
#
.tests-template: &tests
  stage: test

  before_script:
  # Diagnostics
  - mount
  - df -h
  - tox --version

  script:
  - mkdir -p "${INTEGRATION_CACHE}"
  - useradd -Um buildstream
  - chown -R buildstream:buildstream .

  # Run the tests as a simple user to test for permission issues
  - su buildstream -c "${TEST_COMMAND}"

  after_script:
  except:
  - schedules
  artifacts:
    paths:
    - .coverage-reports

# This template ensures that the server stack defined in COMPOSE_MANIFEST is spun up for script execution
# and cleaned up after the script is completed.
.compose-test-boilerplate: &remote-test
  allow_failure: true
  image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:32-${DOCKER_IMAGE_VERSION}
  before_script:
    - dnf install -y docker docker-compose
    - docker-compose --file ${COMPOSE_MANIFEST} up --detach
  after_script:
    - docker-compose --file ${COMPOSE_MANIFEST} stop
    - docker-compose --file ${COMPOSE_MANIFEST} logs
    - docker-compose --file ${COMPOSE_MANIFEST} down
  services:
    - docker:stable-dind

.docker-variables-boilerplate: &docker-variables
  DOCKER_HOST: tcp://docker:2375
  DOCKER_DRIVER: overlay2
  # Required to be able to connect to the docker daemon. See https://gitlab.com/gitlab-org/gitlab-runner/issues/4501
  DOCKER_TLS_CERTDIR: ""

tests-remote-execution:
  <<: *tests
  <<: *remote-test # Spin up server stack
  variables:
    <<: *docker-variables
    COMPOSE_MANIFEST: .gitlab-ci/buildgrid-remote-execution.yml # < *remote-test
    ARTIFACT_CACHE_SERVICE: http://docker:50052
    REMOTE_EXECUTION_SERVICE: http://docker:50051
    SOURCE_CACHE_SERVICE: http://docker:50052
    PYTEST_ARGS: "--color=yes --remote-execution"