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

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

stages:
  - test

variables:
  # SAST related variables
  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: traveltissues-testing-106842226
  PYTEST_ADDOPTS: "--color=yes"
  INTEGRATION_CACHE: "${CI_PROJECT_DIR}/cache/integration-cache"
  PYTEST_ARGS: "--color=yes --integration -n 2"
  TEST_COMMAND: "tox -- ${PYTEST_ARGS}"
  EXTERNAL_TESTS_COMMAND: "tox -e py35-external,py36-external,py37-external,py38-external -- ${PYTEST_ARGS}"
  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}"
  - su buildstream -c "${EXTERNAL_TESTS_COMMAND}"

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

tests-remote-execution:
  allow_failure: true
  image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:31-${DOCKER_IMAGE_VERSION}
  <<: *tests
  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
  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: ""
    COMPOSE_MANIFEST: .gitlab-ci/buildgrid-compose.yml
    ARTIFACT_CACHE_SERVICE: http://docker:50052
    REMOTE_EXECUTION_SERVICE: http://docker:50051
    SOURCE_CACHE_SERVICE: http://docker:50052
    PYTEST_ARGS: "--color=yes --remote-execution tests/remoteexecution/workspaces.py"