[Notes] [Git][BuildStream/buildstream][tristan/docs-version-badge] 10 commits: element.py: Schedule assemble for key of workspaced elements



Title: GitLab

Tristan Van Berkom pushed to branch tristan/docs-version-badge at BuildStream / buildstream

Commits:

10 changed files:

Changes:

  • .gitignore
    ... ... @@ -26,6 +26,7 @@ __pycache__/
    26 26
     buildstream/__version__.py
    
    27 27
     
    
    28 28
     # Autogenerated doc
    
    29
    +doc/source/badges/
    
    29 30
     doc/source/sessions/
    
    30 31
     doc/source/elements/
    
    31 32
     doc/source/sources/
    

  • .gitlab-ci.yml
    ... ... @@ -50,89 +50,6 @@ source_dist:
    50 50
     #                    Test stage                     #
    
    51 51
     #####################################################
    
    52 52
     
    
    53
    -# Run premerge commits
    
    54
    -#
    
    55
    -.linux-tests-template: &linux-tests
    
    56
    -  stage: test
    
    57
    -  variables:
    
    58
    -    PYTEST_ADDOPTS: "--color=yes"
    
    59
    -  script:
    
    60
    -  # Diagnostics
    
    61
    -  - mount
    
    62
    -  - df -h
    
    63
    -
    
    64
    -  - useradd -Um buildstream
    
    65
    -  - chown -R buildstream:buildstream .
    
    66
    -
    
    67
    -  - export INTEGRATION_CACHE="$(pwd)/cache/integration-cache"
    
    68
    -
    
    69
    -  # Unpack and get into dist/buildstream
    
    70
    -  - cd dist && ./unpack.sh
    
    71
    -  - chown -R buildstream:buildstream buildstream
    
    72
    -  - cd buildstream
    
    73
    -
    
    74
    -  # Run the tests from the source distribution, We run as a simple
    
    75
    -  # user to test for permission issues
    
    76
    -  - su buildstream -c 'python3 setup.py test --index-url invalid://uri --addopts --integration'
    
    77
    -
    
    78
    -  # Go back to the toplevel and collect our reports
    
    79
    -  - cd ../..
    
    80
    -  - mkdir -p coverage-linux/
    
    81
    -  - cp dist/buildstream/.coverage.* coverage-linux/coverage."${CI_JOB_NAME}"
    
    82
    -  artifacts:
    
    83
    -    paths:
    
    84
    -    - coverage-linux/
    
    85
    -
    
    86
    -tests-debian-9:
    
    87
    -  image: buildstream/testsuite-debian:9-master-114-4cab18e3
    
    88
    -  <<: *linux-tests
    
    89
    -
    
    90
    -tests-fedora-27:
    
    91
    -  image: buildstream/testsuite-fedora:27-master-114-4cab18e3
    
    92
    -  <<: *linux-tests
    
    93
    -
    
    94
    -tests-fedora-28:
    
    95
    -  image: buildstream/testsuite-fedora:28-master-114-4cab18e3
    
    96
    -  <<: *linux-tests
    
    97
    -
    
    98
    -tests-ubuntu-18.04:
    
    99
    -  image: buildstream/testsuite-ubuntu:18.04-master-114-4cab18e3
    
    100
    -  <<: *linux-tests
    
    101
    -
    
    102
    -tests-unix:
    
    103
    -  # Use fedora here, to a) run a test on fedora and b) ensure that we
    
    104
    -  # can get rid of ostree - this is not possible with debian-8
    
    105
    -  image: buildstream/testsuite-fedora:27-master-114-4cab18e3
    
    106
    -  stage: test
    
    107
    -  variables:
    
    108
    -    BST_FORCE_BACKEND: "unix"
    
    109
    -    PYTEST_ADDOPTS: "--color=yes"
    
    110
    -  script:
    
    111
    -
    
    112
    -    - export INTEGRATION_CACHE="$(pwd)/cache/integration-cache"
    
    113
    -
    
    114
    -    # We remove the Bubblewrap and OSTree packages here so that we catch any
    
    115
    -    # codepaths that try to use them. Removing OSTree causes fuse-libs to
    
    116
    -    # disappear unless we mark it as user-installed.
    
    117
    -    - dnf mark install fuse-libs
    
    118
    -    - dnf erase -y bubblewrap ostree
    
    119
    -
    
    120
    -    # Unpack and get into dist/buildstream
    
    121
    -    - cd dist && ./unpack.sh && cd buildstream
    
    122
    -
    
    123
    -    # Since the unix platform is required to run as root, no user change required
    
    124
    -    - python3 setup.py test --index-url invalid://uri --addopts --integration
    
    125
    -
    
    126
    -    # Go back to the toplevel and collect our reports
    
    127
    -    - cd ../..
    
    128
    -    - mkdir -p coverage-unix/
    
    129
    -    - cp dist/buildstream/.coverage.* coverage-unix/coverage.unix
    
    130
    -  artifacts:
    
    131
    -    paths:
    
    132
    -    - coverage-unix/
    
    133
    -    - logs-unix/
    
    134
    -
    
    135
    -
    
    136 53
     # Automatically build documentation for every commit, we want to know
    
    137 54
     # if building documentation fails even if we're not deploying it.
    
    138 55
     # Note: We still do not enforce a consistent installation of python3-sphinx,
    
    ... ... @@ -153,78 +70,10 @@ docs:
    153 70
         - public/
    
    154 71
     
    
    155 72
     
    
    156
    -# Check code quality with gitlab's built-in feature.
    
    157
    -#
    
    158
    -code_quality:
    
    159
    -  image: docker:stable
    
    160
    -  stage: test
    
    161
    -  variables:
    
    162
    -    DOCKER_DRIVER: overlay2
    
    163
    -  allow_failure: true
    
    164
    -  services:
    
    165
    -    - docker:stable-dind
    
    166
    -  script:
    
    167
    -    - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
    
    168
    -    - docker run
    
    169
    -        --env SOURCE_CODE="$PWD"
    
    170
    -        --volume "$PWD":/code
    
    171
    -        --volume /var/run/docker.sock:/var/run/docker.sock
    
    172
    -        "registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
    
    173
    -  artifacts:
    
    174
    -    paths: [gl-code-quality-report.json]
    
    175
    -
    
    176 73
     #####################################################
    
    177 74
     #                    Post stage                     #
    
    178 75
     #####################################################
    
    179 76
     
    
    180
    -analysis:
    
    181
    -  stage: post
    
    182
    -  script:
    
    183
    -  - |
    
    184
    -    pip3 install radon
    
    185
    -    mkdir analysis
    
    186
    -
    
    187
    -  - |
    
    188
    -    echo "Calculating Maintainability Index"
    
    189
    -    radon mi -s -j buildstream > analysis/mi.json
    
    190
    -    radon mi -s buildstream
    
    191
    -
    
    192
    -  - |
    
    193
    -    echo "Calculating Cyclomatic Complexity"
    
    194
    -    radon cc -a -s -j buildstream > analysis/cc.json
    
    195
    -    radon cc -a -s buildstream
    
    196
    -
    
    197
    -  - |
    
    198
    -    echo "Calculating Raw Metrics"
    
    199
    -    radon raw -s -j buildstream > analysis/raw.json
    
    200
    -    radon raw -s buildstream
    
    201
    -
    
    202
    -  artifacts:
    
    203
    -    paths:
    
    204
    -    - analysis/
    
    205
    -
    
    206
    -# Collate coverage reports
    
    207
    -#
    
    208
    -coverage:
    
    209
    -  stage: post
    
    210
    -  coverage: '/TOTAL +\d+ +\d+ +(\d+\.\d+)%/'
    
    211
    -  script:
    
    212
    -    - cd dist && ./unpack.sh && cd buildstream
    
    213
    -    - pip3 install --no-index .
    
    214
    -    - mkdir report
    
    215
    -    - cd report
    
    216
    -    - cp ../../../coverage-unix/coverage.unix .
    
    217
    -    - cp ../../../coverage-linux/coverage.* .
    
    218
    -    - ls coverage.*
    
    219
    -    - coverage combine --rcfile=../.coveragerc -a coverage.*
    
    220
    -    - coverage report --rcfile=../.coveragerc -m
    
    221
    -  dependencies:
    
    222
    -  - tests-debian-9
    
    223
    -  - tests-fedora-27
    
    224
    -  - tests-fedora-28
    
    225
    -  - tests-unix
    
    226
    -  - source_dist
    
    227
    -
    
    228 77
     # Deploy, only for merges which land on master branch.
    
    229 78
     #
    
    230 79
     pages:
    
    ... ... @@ -248,3 +97,4 @@ pages:
    248 97
       # See https://gitlab.com/gitlab-org/gitlab-ce/issues/35141
    
    249 98
       #
    
    250 99
       - master
    
    100
    +  - tristan/docs-version-badge

  • README.rst
    1 1
     About
    
    2 2
     -----
    
    3
    +
    
    4
    +.. image:: https://buildstream.gitlab.io/buildstream/_static/release.svg
    
    5
    +
    
    6
    +.. image:: https://buildstream.gitlab.io/buildstream/_static/snapshot.svg
    
    7
    +
    
    3 8
     .. image:: https://gitlab.com/BuildStream/buildstream/badges/master/pipeline.svg
    
    4 9
        :target: https://gitlab.com/BuildStream/buildstream/commits/master
    
    5 10
     
    

  • buildstream/element.py
    ... ... @@ -1101,9 +1101,12 @@ class Element(Plugin):
    1101 1101
                 # until the full cache query below.
    
    1102 1102
                 if (not self.__assemble_scheduled and not self.__assemble_done and
    
    1103 1103
                         not self.__cached_success(keystrength=_KeyStrength.WEAK) and
    
    1104
    -                    not self._pull_pending() and self._is_required()):
    
    1105
    -                self._schedule_assemble()
    
    1106
    -                return
    
    1104
    +                    not self._pull_pending()):
    
    1105
    +                # For uncached workspaced elements, assemble is required
    
    1106
    +                # even if we only need the cache key
    
    1107
    +                if self._is_required() or self._get_workspace():
    
    1108
    +                    self._schedule_assemble()
    
    1109
    +                    return
    
    1107 1110
     
    
    1108 1111
             if self.__strict_cache_key is None:
    
    1109 1112
                 dependencies = [
    
    ... ... @@ -1126,13 +1129,17 @@ class Element(Plugin):
    1126 1129
                     self.__weak_cached = self.__artifacts.contains(self, self.__weak_cache_key)
    
    1127 1130
     
    
    1128 1131
             if (not self.__assemble_scheduled and not self.__assemble_done and
    
    1129
    -                not self._cached_success() and not self._pull_pending() and self._is_required()):
    
    1132
    +                not self._cached_success() and not self._pull_pending()):
    
    1130 1133
                 # Workspaced sources are considered unstable if a build is pending
    
    1131 1134
                 # as the build will modify the contents of the workspace.
    
    1132 1135
                 # Determine as early as possible if a build is pending to discard
    
    1133 1136
                 # unstable cache keys.
    
    1134
    -            self._schedule_assemble()
    
    1135
    -            return
    
    1137
    +
    
    1138
    +            # For uncached workspaced elements, assemble is required
    
    1139
    +            # even if we only need the cache key
    
    1140
    +            if self._is_required() or self._get_workspace():
    
    1141
    +                self._schedule_assemble()
    
    1142
    +                return
    
    1136 1143
     
    
    1137 1144
             if self.__cache_key is None:
    
    1138 1145
                 # Calculate strong cache key
    
    ... ... @@ -1430,7 +1437,6 @@ class Element(Plugin):
    1430 1437
         # in a subprocess.
    
    1431 1438
         #
    
    1432 1439
         def _schedule_assemble(self):
    
    1433
    -        assert self._is_required()
    
    1434 1440
             assert not self.__assemble_scheduled
    
    1435 1441
             self.__assemble_scheduled = True
    
    1436 1442
     
    
    ... ... @@ -1438,6 +1444,8 @@ class Element(Plugin):
    1438 1444
             for dep in self.dependencies(Scope.BUILD, recurse=False):
    
    1439 1445
                 dep._set_required()
    
    1440 1446
     
    
    1447
    +        self._set_required()
    
    1448
    +
    
    1441 1449
             # Invalidate workspace key as the build modifies the workspace directory
    
    1442 1450
             workspace = self._get_workspace()
    
    1443 1451
             if workspace:
    
    ... ... @@ -1661,6 +1669,10 @@ class Element(Plugin):
    1661 1669
         #   (bool): Whether a pull operation is pending
    
    1662 1670
         #
    
    1663 1671
         def _pull_pending(self):
    
    1672
    +        if self._get_workspace():
    
    1673
    +            # Workspace builds are never pushed to artifact servers
    
    1674
    +            return False
    
    1675
    +
    
    1664 1676
             if self.__strong_cached:
    
    1665 1677
                 # Artifact already in local cache
    
    1666 1678
                 return False
    

  • doc/Makefile
    ... ... @@ -35,7 +35,7 @@ endif
    35 35
     PYTHONPATH=$(CURDIR)/..:$(CURDIR)/../buildstream/plugins
    
    36 36
     
    
    37 37
     
    
    38
    -.PHONY: all clean templates templates-clean sessions sessions-prep sessions-clean html devhelp
    
    38
    +.PHONY: all clean templates templates-clean sessions sessions-prep sessions-clean badges badges-clean html devhelp
    
    39 39
     
    
    40 40
     # Canned recipe for generating plugin api skeletons
    
    41 41
     #   $1 = the plugin directory
    
    ... ... @@ -70,9 +70,13 @@ endef
    70 70
     
    
    71 71
     all: html devhelp
    
    72 72
     
    
    73
    -clean: templates-clean sessions-clean
    
    73
    +clean: templates-clean sessions-clean badges-clean
    
    74 74
     	rm -rf build
    
    75 75
     
    
    76
    +############################################################
    
    77
    +#                 Plugin doc templates                     #
    
    78
    +############################################################
    
    79
    +
    
    76 80
     # Generate rst templates for the docs using a mix of sphinx-apidoc and
    
    77 81
     # our 'plugin-doc-skeleton' routine for plugin pages.
    
    78 82
     templates:
    
    ... ... @@ -86,6 +90,10 @@ templates-clean:
    86 90
     	rm -rf source/elements
    
    87 91
     	rm -rf source/sources
    
    88 92
     
    
    93
    +############################################################
    
    94
    +#                   Session captures                       #
    
    95
    +############################################################
    
    96
    +
    
    89 97
     # Stage the stored sessions into the place where they will
    
    90 98
     # be used in the build.
    
    91 99
     #
    
    ... ... @@ -111,10 +119,27 @@ sessions: sessions-prep
    111 119
     sessions-clean:
    
    112 120
     	rm -rf source/sessions
    
    113 121
     
    
    122
    +
    
    123
    +############################################################
    
    124
    +#                  Generate release badges                 #
    
    125
    +############################################################
    
    126
    +badges-clean:
    
    127
    +	rm -rf source/badges
    
    128
    +
    
    129
    +badges:
    
    130
    +	mkdir -p source/badges
    
    131
    +	$(CURDIR)/badges.py > source/badges/snapshot.svg
    
    132
    +	$(CURDIR)/badges.py --release > source/badges/release.svg
    
    133
    +
    
    134
    +
    
    135
    +############################################################
    
    136
    +#                    Main sphinx build                     #
    
    137
    +############################################################
    
    138
    +
    
    114 139
     # Targets which generate docs with sphinx build
    
    115 140
     #
    
    116 141
     #
    
    117
    -html devhelp: templates sessions
    
    142
    +html devhelp: templates sessions badges
    
    118 143
     	@echo "Building $@..."
    
    119 144
     	PYTHONPATH=$(PYTHONPATH) \
    
    120 145
     	    $(SPHINXBUILD) -b $@ $(ALLSPHINXOPTS) "$(BUILDDIR)/$@" \
    

  • doc/badges.py
    1
    +#!/usr/bin/env python3
    
    2
    +#
    
    3
    +#  Copyright (C) 2018 Codethink Limited
    
    4
    +#
    
    5
    +#  This program is free software; you can redistribute it and/or
    
    6
    +#  modify it under the terms of the GNU Lesser General Public
    
    7
    +#  License as published by the Free Software Foundation; either
    
    8
    +#  version 2 of the License, or (at your option) any later version.
    
    9
    +#
    
    10
    +#  This library is distributed in the hope that it will be useful,
    
    11
    +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    12
    +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
    
    13
    +#  Lesser General Public License for more details.
    
    14
    +#
    
    15
    +#  You should have received a copy of the GNU Lesser General Public
    
    16
    +#  License along with this library. If not, see <http://www.gnu.org/licenses/>.
    
    17
    +#
    
    18
    +#  Authors:
    
    19
    +#        Tristan Van Berkom <tristan vanberkom codethink co uk>
    
    20
    +#
    
    21
    +import click
    
    22
    +import subprocess
    
    23
    +import re
    
    24
    +
    
    25
    +# The badge template is modeled after the gitlab badge svgs
    
    26
    +#
    
    27
    +BADGE_TEMPLATE = """<svg xmlns="http://www.w3.org/2000/svg"
    
    28
    +                         xmlns:xlink="http://www.w3.org/1999/xlink"
    
    29
    +                         width="116" height="20">
    
    30
    +  <a xlink:href="">
    
    31
    +    <linearGradient id="b" x2="0" y2="100%">
    
    32
    +      <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
    
    33
    +      <stop offset="1" stop-opacity=".1"/>
    
    34
    +    </linearGradient>
    
    35
    +
    
    36
    +    <mask id="a">
    
    37
    +      <rect width="116" height="20" rx="3" fill="#fff"/>
    
    38
    +    </mask>
    
    39
    +
    
    40
    +    <g mask="url(#a)">
    
    41
    +      <path fill="#555"
    
    42
    +            d="M0 0 h62 v20 H0 z"/>
    
    43
    +      <path fill="{color}"
    
    44
    +            d="M62 0 h54 v20 H62 z"/>
    
    45
    +      <path fill="url(#b)"
    
    46
    +            d="M0 0 h116 v20 H0 z"/>
    
    47
    +    </g>
    
    48
    +
    
    49
    +    <g fill="#fff" text-anchor="middle">
    
    50
    +      <g font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
    
    51
    +        <text x="31" y="15" fill="#010101" fill-opacity=".3">
    
    52
    +          {badge_name}
    
    53
    +        </text>
    
    54
    +        <text x="31" y="14">
    
    55
    +          {badge_name}
    
    56
    +        </text>
    
    57
    +        <text x="89" y="15" fill="#010101" fill-opacity=".3">
    
    58
    +          {version}
    
    59
    +        </text>
    
    60
    +        <text x="89" y="14">
    
    61
    +          {version}
    
    62
    +        </text>
    
    63
    +      </g>
    
    64
    +    </g>
    
    65
    +  </a>
    
    66
    +</svg>
    
    67
    +"""
    
    68
    +
    
    69
    +URL_FORMAT = 'https://download.gnome.org/sources/BuildStream/{brief_version}/BuildStream-{full_version}.tar.xz'
    
    70
    +RELEASE_COLOR = '#0040FF'
    
    71
    +SNAPSHOT_COLOR = '#FF8000'
    
    72
    +VERSION_TAG_MATCH = r'([0-9]*)\.([0-9]*)\.([0-9]*)'
    
    73
    +
    
    74
    +
    
    75
    +# Parse a release tag and return a three tuple
    
    76
    +# of the major, minor and micro version.
    
    77
    +#
    
    78
    +# Tags which do not follow the release tag format
    
    79
    +# will just be returned as (0, 0, 0)
    
    80
    +#
    
    81
    +def parse_tag(tag):
    
    82
    +    match = re.search(VERSION_TAG_MATCH, tag)
    
    83
    +    if match:
    
    84
    +        major = match.group(1)
    
    85
    +        minor = match.group(2)
    
    86
    +        micro = match.group(3)
    
    87
    +        return (int(major), int(minor), int(micro))
    
    88
    +
    
    89
    +    return (0, 0, 0)
    
    90
    +
    
    91
    +
    
    92
    +# Call out to git and guess the latest version,
    
    93
    +# this will just return (0, 0, 0) in case of any error.
    
    94
    +#
    
    95
    +def guess_version(release):
    
    96
    +    try:
    
    97
    +        tags_output = subprocess.check_output(['git', 'tag'])
    
    98
    +    except CalledProcessError:
    
    99
    +        return (0, 0, 0)
    
    100
    +
    
    101
    +    # Parse the `git tag` output into a list of integer tuples
    
    102
    +    tags_output = tags_output.decode('UTF-8')
    
    103
    +    all_tags = tags_output.splitlines()
    
    104
    +    all_versions = [parse_tag(tag) for tag in all_tags]
    
    105
    +
    
    106
    +    # Filter the list by the minor point version, if
    
    107
    +    # we are checking for the latest "release" version, then
    
    108
    +    # only pickup even number minor points.
    
    109
    +    #
    
    110
    +    filtered_versions = [
    
    111
    +        version for version in all_versions
    
    112
    +        if (version[1] % 2) == (not release)
    
    113
    +    ]
    
    114
    +
    
    115
    +    # Make sure they are sorted, and take the last one
    
    116
    +    sorted_versions = sorted(filtered_versions)
    
    117
    +    latest_version = sorted_versions[-1]
    
    118
    +
    
    119
    +    return latest_version
    
    120
    +
    
    121
    +
    
    122
    +@click.command(short_help="Generate the version badges")
    
    123
    +@click.option('--release', is_flag=True, default=False,
    
    124
    +              help="Whether to generate the badge for the release version")
    
    125
    +def generate_badges(release):
    
    126
    +    """Generate the version badge svg files
    
    127
    +    """
    
    128
    +    major, minor, micro = guess_version(release)
    
    129
    +
    
    130
    +    if release:
    
    131
    +        badge_name = 'release'
    
    132
    +        color = RELEASE_COLOR
    
    133
    +    else:
    
    134
    +        badge_name = 'snapshot'
    
    135
    +        color = SNAPSHOT_COLOR
    
    136
    +
    
    137
    +    brief_version = '{major}.{minor}'.format(major=major, minor=minor)
    
    138
    +    full_version = '{major}.{minor}.{micro}'.format(major=major, minor=minor, micro=micro)
    
    139
    +    url_target = URL_FORMAT.format(brief_version=brief_version, full_version=full_version)
    
    140
    +    badge = BADGE_TEMPLATE.format(badge_name=badge_name,
    
    141
    +                                  version=full_version,
    
    142
    +                                  color=color,
    
    143
    +                                  url_target=url_target)
    
    144
    +    click.echo(badge, nl=False)
    
    145
    +    return 0
    
    146
    +
    
    147
    +
    
    148
    +if __name__ == '__main__':
    
    149
    +    generate_badges()

  • doc/source/conf.py
    ... ... @@ -160,7 +160,7 @@ html_theme = 'sphinx_rtd_theme'
    160 160
     # Add any paths that contain custom static files (such as style sheets) here,
    
    161 161
     # relative to this directory. They are copied after the builtin static files,
    
    162 162
     # so a file named "default.css" will overwrite the builtin "default.css".
    
    163
    -html_static_path = []
    
    163
    +html_static_path = ['badges']
    
    164 164
     
    
    165 165
     # Add any extra paths that contain custom files (such as robots.txt or
    
    166 166
     # .htaccess) here, relative to this directory. These files are copied
    

  • doc/source/install_versions.rst
    ... ... @@ -13,8 +13,12 @@ For example, for a given version number ``X.Y.Z``
    13 13
      * The ``X.<odd number>.*`` versions are development spanshots intended for testing.
    
    14 14
     
    
    15 15
     If you are :ref:`installing from git <install_git_checkout>`, please look for the latest
    
    16
    -tag in the latest release branch to ensure you're getting the latest release.
    
    16
    +tag to ensure you're getting the latest release.
    
    17 17
     
    
    18
    -Current release branches:
    
    19
    - * `bst-1.2 (latest) <https://gitlab.com/BuildStream/buildstream/commits/bst-1.2>`_
    
    20
    - * `bst-1.0 (deprecated) <https://gitlab.com/BuildStream/buildstream/commits/bst-1.0>`_
    18
    +* Latest release:
    
    19
    +
    
    20
    +  .. image:: https://buildstream.gitlab.io/buildstream/_static/release.svg
    
    21
    +
    
    22
    +* Latest development snapshot:
    
    23
    +
    
    24
    +  .. image:: https://buildstream.gitlab.io/buildstream/_static/snapshot.svg

  • doc/source/main_install.rst
    ... ... @@ -4,6 +4,11 @@
    4 4
     
    
    5 5
     Install
    
    6 6
     =======
    
    7
    +
    
    8
    +.. image:: https://buildstream.gitlab.io/buildstream/_static/release.svg
    
    9
    +
    
    10
    +.. image:: https://buildstream.gitlab.io/buildstream/_static/snapshot.svg
    
    11
    +
    
    7 12
     This section provides instructions for installing BuildStream and its
    
    8 13
     companion artifact server on various platforms, along with any installation
    
    9 14
     related materials.
    

  • tests/frontend/workspace.py
    ... ... @@ -780,3 +780,72 @@ def test_inconsitent_pipeline_message(cli, tmpdir, datafiles, kind):
    780 780
             'build', element_name
    
    781 781
         ])
    
    782 782
         result.assert_main_error(ErrorDomain.PIPELINE, "inconsistent-pipeline-workspaced")
    
    783
    +
    
    784
    +
    
    785
    +@pytest.mark.datafiles(DATA_DIR)
    
    786
    +@pytest.mark.parametrize("strict", [("strict"), ("non-strict")])
    
    787
    +def test_cache_key_workspace_in_dependencies(cli, tmpdir, datafiles, strict):
    
    788
    +    checkout = os.path.join(str(tmpdir), 'checkout')
    
    789
    +    element_name, project, workspace = open_workspace(cli, os.path.join(str(tmpdir), 'repo-a'), datafiles, 'git', False)
    
    790
    +
    
    791
    +    element_path = os.path.join(project, 'elements')
    
    792
    +    back_dep_element_name = 'workspace-test-back-dep.bst'
    
    793
    +
    
    794
    +    # Write out our test target
    
    795
    +    element = {
    
    796
    +        'kind': 'compose',
    
    797
    +        'depends': [
    
    798
    +            {
    
    799
    +                'filename': element_name,
    
    800
    +                'type': 'build'
    
    801
    +            }
    
    802
    +        ]
    
    803
    +    }
    
    804
    +    _yaml.dump(element,
    
    805
    +               os.path.join(element_path,
    
    806
    +                            back_dep_element_name))
    
    807
    +
    
    808
    +    # Modify workspace
    
    809
    +    shutil.rmtree(os.path.join(workspace, 'usr', 'bin'))
    
    810
    +    os.makedirs(os.path.join(workspace, 'etc'))
    
    811
    +    with open(os.path.join(workspace, 'etc', 'pony.conf'), 'w') as f:
    
    812
    +        f.write("PONY='pink'")
    
    813
    +
    
    814
    +    # Configure strict mode
    
    815
    +    strict_mode = True
    
    816
    +    if strict != 'strict':
    
    817
    +        strict_mode = False
    
    818
    +    cli.configure({
    
    819
    +        'projects': {
    
    820
    +            'test': {
    
    821
    +                'strict': strict_mode
    
    822
    +            }
    
    823
    +        }
    
    824
    +    })
    
    825
    +
    
    826
    +    # Build artifact with dependency's modified workspace
    
    827
    +    assert cli.get_element_state(project, element_name) == 'buildable'
    
    828
    +    assert cli.get_element_key(project, element_name) == "{:?<64}".format('')
    
    829
    +    assert cli.get_element_state(project, back_dep_element_name) == 'waiting'
    
    830
    +    assert cli.get_element_key(project, back_dep_element_name) == "{:?<64}".format('')
    
    831
    +    result = cli.run(project=project, args=['build', back_dep_element_name])
    
    832
    +    result.assert_success()
    
    833
    +    assert cli.get_element_state(project, element_name) == 'cached'
    
    834
    +    assert cli.get_element_key(project, element_name) != "{:?<64}".format('')
    
    835
    +    assert cli.get_element_state(project, back_dep_element_name) == 'cached'
    
    836
    +    assert cli.get_element_key(project, back_dep_element_name) != "{:?<64}".format('')
    
    837
    +    result = cli.run(project=project, args=['build', back_dep_element_name])
    
    838
    +    result.assert_success()
    
    839
    +
    
    840
    +    # Checkout the result
    
    841
    +    result = cli.run(project=project, args=[
    
    842
    +        'checkout', back_dep_element_name, checkout
    
    843
    +    ])
    
    844
    +    result.assert_success()
    
    845
    +
    
    846
    +    # Check that the pony.conf from the modified workspace exists
    
    847
    +    filename = os.path.join(checkout, 'etc', 'pony.conf')
    
    848
    +    assert os.path.exists(filename)
    
    849
    +
    
    850
    +    # Check that the original /usr/bin/hello is not in the checkout
    
    851
    +    assert not os.path.exists(os.path.join(checkout, 'usr', 'bin', 'hello'))



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]