From 3934ce81a29078495ec72c10577f998de1c2f6f5 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Tue, 28 Nov 2017 11:51:53 +0000 Subject: .gitlab-ci.yml: Use source distribution tarballs in all tests This commit adds an initial stage to the pipeline to build a distribution tarball and generate some helper scripts for later CI to use to unpack it and install it. Then, it makes sure that all pytest and integration test runs work from the dist tarball instead of directly from the git repo, also the docs are built from the dist tarball. This ensures that everything continues to work with a dist tarball at all times. --- .gitlab-ci.yml | 87 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 74 insertions(+), 13 deletions(-) (limited to '.gitlab-ci.yml') diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5c9f23303..c4af56754 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,7 @@ cache: - cache/buildstream/sources/ stages: + - dist - test - coverage - docs @@ -20,19 +21,64 @@ before_script: - adduser -m buildstream - chown -R buildstream:buildstream . +# Create a source distribution +# +distcheck: + stage: dist + script: + + # Generate the source distribution tarball + # + - python3 setup.py sdist + - tar -ztf dist/* + - tarball=$(cd dist && echo $(ls *)) + + # Create an installer script + - | + cat > dist/install.sh << EOF + #!/bin/sh + tar -zxf ${tarball} + cd ${tarball%.tar.gz} + pip3 install --no-index . + EOF + + # unpack tarball as `dist/buildstream` directory + - | + cat > dist/unpack.sh << EOF + #!/bin/sh + tar -zxf ${tarball} + mv ${tarball%.tar.gz} buildstream + EOF + + # Make our helpers executable + - chmod +x dist/install.sh + - chmod +x dist/unpack.sh + artifacts: + paths: + - dist/ + # Run premerge commits # -pytest: +pytest_linux: stage: test script: - # We run as a simple user to test for permission issues + + # Unpack and get into dist/buildstream + - cd dist && ./unpack.sh + - chown -R buildstream:buildstream buildstream + - cd buildstream + + # Run the tests from the source distribution, 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/ - - cp .coverage.* coverage-pytest/coverage.pytest + # Go back to the toplevel and collect our reports + - cd ../.. + - mkdir -p coverage-pytest-linux/ + - cp dist/buildstream/.coverage.* coverage-pytest-linux/coverage.pytest-linux artifacts: paths: - - coverage-pytest/ + - coverage-pytest-linux/ # Run integration tests # @@ -40,7 +86,7 @@ integration_linux: stage: test script: - - pip3 install --no-index . + - cd dist && ./install.sh && cd .. - cd integration-tests # We run as a simple user to test for permission issues @@ -56,6 +102,9 @@ integration_linux: - coverage-linux/ - logs-linux/ + dependencies: + - distcheck + pytest_unix: stage: test variables: @@ -67,11 +116,16 @@ pytest_unix: - dnf mark install fuse-libs - dnf erase -y bubblewrap ostree + # Unpack and get into dist/buildstream + - cd dist && ./unpack.sh && cd buildstream + # Since the unix platform is required to run as root, no user change required - python3 setup.py test --index-url invalid://uri + # Go back to the toplevel and collect our reports + - cd ../.. - mkdir -p coverage-pytest-unix - - cp .coverage.* coverage-pytest-unix/coverage.pytest-unix + - cp dist/buildstream/.coverage.* coverage-pytest-unix/coverage.pytest-unix artifacts: paths: - coverage-pytest-unix/ @@ -81,7 +135,7 @@ integration_unix: variables: BST_FORCE_BACKEND: "unix" script: - - pip3 install --no-index . + - cd dist && ./install.sh && cd .. - cd integration-tests # Since the unix platform is required to run as root, no user change required @@ -97,6 +151,9 @@ integration_unix: - coverage-unix/ - logs-unix/ + dependencies: + - distcheck + # Collate coverage reports # coverage: @@ -108,13 +165,13 @@ coverage: - cp ../coverage-linux/coverage.linux .coverage - cp ../coverage-unix/coverage.unix . - coverage combine --rcfile=../.coveragerc -a ../coverage-unix/coverage.unix - - cp ../coverage-pytest/coverage.pytest . - - coverage combine --rcfile=../.coveragerc -a coverage.pytest + - cp ../coverage-pytest-linux/coverage.pytest-linux . + - coverage combine --rcfile=../.coveragerc -a coverage.pytest-linux - cp ../coverage-pytest-unix/coverage.pytest-unix . - coverage combine --rcfile=../.coveragerc -a coverage.pytest-unix - coverage report --rcfile=../.coveragerc -m dependencies: - - pytest + - pytest_linux - integration_linux - pytest_unix - integration_unix @@ -131,11 +188,15 @@ pages: - dnf install -y python2 - pip3 install sphinx - pip3 install sphinx-click - - pip3 install --user . + - cd dist && ./unpack.sh && cd buildstream + - pip3 install . - make -C doc - - mv doc/build/html public + - cd ../.. + - mv dist/buildstream/doc/build/html public artifacts: paths: - public/ only: - master + dependencies: + - distcheck -- cgit v1.2.1