.gitlab-ci.yml 4.88 KB
Newer Older
1
image: buildstream/buildstream-fedora:master-26-3fd7fe1
2

Tristan Maat's avatar
Tristan Maat committed
3 4 5 6
cache:
  paths:
    - cache/buildstream/sources/

7
stages:
8
  - dist
9 10 11 12
  - test
  - coverage
  - docs

13
before_script:
14 15 16
  # Diagnostics
  - mount
  - df -h
17

Tristan Maat's avatar
Tristan Maat committed
18
  # Store cache in the project directory
19
  - if [ -d "$(pwd)/cache" ]; then chmod -R a+rw "$(pwd)/cache"; fi
Tristan Maat's avatar
Tristan Maat committed
20
  - export XDG_CACHE_HOME="$(pwd)/cache"
21 22
  - adduser -m buildstream
  - chown -R buildstream:buildstream .
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
# 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/

60 61
# Run premerge commits
#
62
pytest_linux:
63
  stage: test
64
  script:
65 66 67 68 69 70 71 72

  # 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
73 74
  - su buildstream -c 'python3 setup.py test --index-url invalid://uri'

75 76 77 78
  # 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
79 80
  artifacts:
    paths:
81
    - coverage-pytest-linux/
82

83 84
# Run integration tests
#
85
integration_linux:
86
  stage: test
87 88

  script:
89
    - cd dist && ./install.sh && cd ..
90
    - cd integration-tests
91 92 93 94

    # 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'

95 96
    - cd ..
    - mkdir -p coverage-linux/
97 98
    - cp integration-tests/.coverage coverage-linux/coverage.linux
    - cp -a integration-tests/tmp/logs logs-linux
99 100 101 102 103 104

  artifacts:
    paths:
    - coverage-linux/
    - logs-linux/

105 106 107
  dependencies:
  - distcheck

108 109 110 111 112
pytest_unix:
  stage: test
  variables:
    BST_FORCE_BACKEND: "unix"
  script:
113
    # We remove the Bubblewrap and OSTree packages here so that we catch any
114 115 116
    # codepaths that try to use them. Removing OSTree causes fuse-libs to
    # disappear unless we mark it as user-installed.
    - dnf mark install fuse-libs
117
    - dnf erase -y bubblewrap ostree
118

119 120 121
    # Unpack and get into dist/buildstream
    - cd dist && ./unpack.sh && cd buildstream

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

125 126
    # Go back to the toplevel and collect our reports
    - cd ../..
127
    - mkdir -p coverage-pytest-unix
128
    - cp dist/buildstream/.coverage.* coverage-pytest-unix/coverage.pytest-unix
129 130 131 132 133 134 135 136
  artifacts:
    paths:
      - coverage-pytest-unix/

integration_unix:
  stage: test
  variables:
    BST_FORCE_BACKEND: "unix"
137
  script:
138
    - cd dist && ./install.sh && cd ..
139
    - cd integration-tests
140 141

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

144
    - cd ..
145
    - mkdir -p coverage-unix/
146 147
    - cp integration-tests/.coverage coverage-unix/coverage.unix
    - cp -a integration-tests/tmp/logs logs-unix
148

149 150
  artifacts:
    paths:
151 152
    - coverage-unix/
    - logs-unix/
153

154 155 156
  dependencies:
  - distcheck

157 158 159 160 161
# Collate coverage reports
#
coverage:
  stage: coverage
  script:
162
    - pip3 install --no-index .
163 164
    - mkdir report
    - cd report
165 166
    - cp ../coverage-linux/coverage.linux .coverage
    - cp ../coverage-unix/coverage.unix .
167
    - coverage combine --rcfile=../.coveragerc -a ../coverage-unix/coverage.unix
168 169
    - cp ../coverage-pytest-linux/coverage.pytest-linux .
    - coverage combine --rcfile=../.coveragerc -a coverage.pytest-linux
170 171
    - cp ../coverage-pytest-unix/coverage.pytest-unix .
    - coverage combine --rcfile=../.coveragerc -a coverage.pytest-unix
172
    - coverage report --rcfile=../.coveragerc -m
173
  dependencies:
174
  - pytest_linux
175 176 177
  - integration_linux
  - pytest_unix
  - integration_unix
178

179 180
# Automatically build documentation, only for merges which land
# on master branch.
181 182 183 184
#
# Note: We still do not enforce a consistent installation of python2
#       or sphinx, as python2 will significantly grow the backing image.
#
185
pages:
186
  stage: docs
187
  script:
188
  - dnf install -y python2
189
  - pip3 install sphinx
190
  - pip3 install sphinx-click
191 192
  - cd dist && ./unpack.sh && cd buildstream
  - pip3 install .
193
  - make -C doc
194 195
  - cd ../..
  - mv dist/buildstream/doc/build/html public
196 197 198 199 200
  artifacts:
    paths:
    - public/
  only:
  - master
201 202
  dependencies:
  - distcheck