Commit 28830191 authored by Tristan Maat's avatar Tristan Maat
Browse files

.gitlab-ci.yml: Drop root privileges for some tests

parent 0f7e5df5
Loading
Loading
Loading
Loading
Loading
+24 −3
Original line number Original line Diff line number Diff line
@@ -15,16 +15,25 @@ before_script:
  - df -h
  - df -h


  # Store cache in the project directory
  # Store cache in the project directory
  - mkdir -p "$(pwd)/cache"
  - if [ -d "$(pwd)/cache" ]; then chmod -R a+rw "$(pwd)/cache"; fi
  - export XDG_CACHE_HOME="$(pwd)/cache"
  - export XDG_CACHE_HOME="$(pwd)/cache"
  - adduser -m buildstream
  - chown -R buildstream:buildstream .


# Run premerge commits
# Run premerge commits
#
#
pytest:
pytest:
  stage: test
  stage: test
  script:
  script:
  - python3 setup.py test --index-url invalid://uri
  - chmod -R a+rw .
  - su buildstream -c 'mkdir -p ~/.gnupg/'
  - su buildstream -c 'chmod 600 ~/.gnupg/'

  # We run as a simple user to test for permission issues
  - su buildstream -c 'python3 setup.py test --index-url invalid://uri'

  - mkdir -p coverage-pytest/
  - mkdir -p coverage-pytest/
  - chmod -R a+rw coverage-pytest/
  - cp .coverage.* coverage-pytest/coverage.pytest
  - cp .coverage.* coverage-pytest/coverage.pytest
  artifacts:
  artifacts:
    paths:
    paths:
@@ -37,10 +46,16 @@ integration_linux:


  script:
  script:
    - pip3 install --no-index .
    - pip3 install --no-index .
    - su buildstream -c 'mkdir -p ~/.gnupg/'
    - su buildstream -c 'chmod 600 ~/.gnupg/'
    - cd integration-tests
    - cd integration-tests
    - ./run-test.sh --arg --colors --cov ../.coveragerc --sources ${XDG_CACHE_HOME}/buildstream/sources test

    # We run as a simple user to test for permission issues
    - su buildstream -c './run-test.sh --arg --colors --cov ../.coveragerc --sources ${XDG_CACHE_HOME}/buildstream/sources test'

    - cd ..
    - cd ..
    - mkdir -p coverage-linux/
    - mkdir -p coverage-linux/
    - chmod -R a+rw coverage-linux/
    - cp integration-tests/.coverage coverage-linux/coverage.linux
    - cp integration-tests/.coverage coverage-linux/coverage.linux
    - cp -a integration-tests/tmp/logs logs-linux
    - cp -a integration-tests/tmp/logs logs-linux


@@ -59,7 +74,10 @@ pytest_unix:
    # disappear unless we mark it as user-installed.
    # disappear unless we mark it as user-installed.
    - dnf mark install fuse-libs
    - dnf mark install fuse-libs
    - dnf erase -y bubblewrap ostree
    - dnf erase -y bubblewrap ostree

    # Since the unix platform is required to run as root, no user change required
    - python3 setup.py test --index-url invalid://uri
    - python3 setup.py test --index-url invalid://uri

    - mkdir -p coverage-pytest-unix
    - mkdir -p coverage-pytest-unix
    - cp .coverage.* coverage-pytest-unix/coverage.pytest-unix
    - cp .coverage.* coverage-pytest-unix/coverage.pytest-unix
  artifacts:
  artifacts:
@@ -73,7 +91,10 @@ integration_unix:
  script:
  script:
    - pip3 install --no-index .
    - pip3 install --no-index .
    - cd integration-tests
    - cd integration-tests

    # Since the unix platform is required to run as root, no user change required
    - ./run-test.sh --arg --colors --cov ../.coveragerc --sources ${XDG_CACHE_HOME}/buildstream/sources test
    - ./run-test.sh --arg --colors --cov ../.coveragerc --sources ${XDG_CACHE_HOME}/buildstream/sources test

    - cd ..
    - cd ..
    - mkdir -p coverage-unix/
    - mkdir -p coverage-unix/
    - cp integration-tests/.coverage coverage-unix/coverage.unix
    - cp integration-tests/.coverage coverage-unix/coverage.unix
+1 −0
Original line number Original line Diff line number Diff line
@@ -3,6 +3,7 @@ test=pytest


[tool:pytest]
[tool:pytest]
addopts = --verbose --basetemp ./tmp --pep8 --cov=buildstream --cov-config .coveragerc
addopts = --verbose --basetemp ./tmp --pep8 --cov=buildstream --cov-config .coveragerc
norecursedirs = integration-tests*
python_files = tests/*/*.py
python_files = tests/*/*.py
pep8maxlinelength = 119
pep8maxlinelength = 119
pep8ignore =
pep8ignore =