[Notes] [Git][BuildStream/buildstream][chandan/automate-pypi-release] 2 commits: .gitlab-ci.yml: Publish to PyPI when new tags are pushed



Title: GitLab

Chandan Singh pushed to branch chandan/automate-pypi-release at BuildStream / buildstream

Commits:

1 changed file:

Changes:

  • .gitlab-ci.yml
    ... ... @@ -6,14 +6,16 @@ cache:
    6 6
         - cache/
    
    7 7
     
    
    8 8
     stages:
    
    9
    -  - prepare
    
    10
    -  - test
    
    11 9
       - post
    
    12 10
     
    
    13 11
     variables:
    
    14 12
       PYTEST_ADDOPTS: "--color=yes"
    
    15 13
       INTEGRATION_CACHE: "${CI_PROJECT_DIR}/cache/integration-cache"
    
    16 14
       TEST_COMMAND: 'python3 setup.py test --index-url invalid://uri --addopts --integration'
    
    15
    +  TEST_PYPI_UPLOAD_URL: "https://test.pypi.org/legacy/"
    
    16
    +  TEST_PYPI_INDEX_URL: "https://test.pypi.org/simple/"
    
    17
    +  PYPI_UPLOAD_URL: "https://upload.pypi.org/legacy/"
    
    18
    +  CI_COMMIT_TAG: "1.2.3"
    
    17 19
     
    
    18 20
     #####################################################
    
    19 21
     #                  Prepare stage                    #
    
    ... ... @@ -51,275 +53,30 @@ source_dist:
    51 53
         - dist/
    
    52 54
     
    
    53 55
     
    
    54
    -#####################################################
    
    55
    -#                    Test stage                     #
    
    56
    -#####################################################
    
    57
    -
    
    58
    -# Run premerge commits
    
    59
    -#
    
    60
    -.tests-template: &tests
    
    61
    -  stage: test
    
    62
    -
    
    63
    -  variables:
    
    64
    -    COVERAGE_DIR: coverage-linux
    
    65
    -
    
    66
    -  before_script:
    
    67
    -  # Diagnostics
    
    68
    -  - mount
    
    69
    -  - df -h
    
    70
    -
    
    71
    -  # Unpack
    
    72
    -  - cd dist && ./unpack.sh
    
    73
    -  - cd buildstream
    
    74
    -
    
    75
    -  script:
    
    76
    -  - useradd -Um buildstream
    
    77
    -  - chown -R buildstream:buildstream .
    
    78
    -
    
    79
    -  # Run the tests from the source distribution, We run as a simple
    
    80
    -  # user to test for permission issues
    
    81
    -  - su buildstream -c "${TEST_COMMAND}"
    
    82
    -
    
    83
    -  after_script:
    
    84
    -  # Collect our reports
    
    85
    -  - mkdir -p ${COVERAGE_DIR}
    
    86
    -  - cp dist/buildstream/.coverage ${COVERAGE_DIR}/coverage."${CI_JOB_NAME}"
    
    87
    -  except:
    
    88
    -  - schedules
    
    89
    -  artifacts:
    
    90
    -    paths:
    
    91
    -    - ${COVERAGE_DIR}
    
    92
    -
    
    93
    -tests-debian-9:
    
    94
    -  image: buildstream/testsuite-debian:9-master-123-7ce6581b
    
    95
    -  <<: *tests
    
    96
    -
    
    97
    -tests-fedora-27:
    
    98
    -  image: buildstream/testsuite-fedora:27-master-123-7ce6581b
    
    99
    -  <<: *tests
    
    100
    -
    
    101
    -tests-fedora-28:
    
    102
    -  image: buildstream/testsuite-fedora:28-master-123-7ce6581b
    
    103
    -  <<: *tests
    
    104
    -
    
    105
    -tests-ubuntu-18.04:
    
    106
    -  image: buildstream/testsuite-ubuntu:18.04-master-123-7ce6581b
    
    107
    -  <<: *tests
    
    108
    -
    
    109
    -overnight-fedora-28-aarch64:
    
    110
    -  image: buildstream/testsuite-fedora:aarch64-28-master-123-7ce6581b
    
    111
    -  tags:
    
    112
    -    - aarch64
    
    113
    -  <<: *tests
    
    114
    -  # We need to override the exclusion from the template
    
    115
    -  # in order to run on schedules
    
    116
    -  except: []
    
    117
    -  only:
    
    118
    -  - schedules
    
    119
    -
    
    120
    -tests-unix:
    
    121
    -  # Use fedora here, to a) run a test on fedora and b) ensure that we
    
    122
    -  # can get rid of ostree - this is not possible with debian-8
    
    123
    -  image: buildstream/testsuite-fedora:27-master-123-7ce6581b
    
    124
    -  <<: *tests
    
    125
    -  variables:
    
    126
    -    BST_FORCE_BACKEND: "unix"
    
    127
    -    COVERAGE_DIR: coverage-unix
    
    128
    -
    
    129
    -  script:
    
    130
    -
    
    131
    -    # We remove the Bubblewrap and OSTree packages here so that we catch any
    
    132
    -    # codepaths that try to use them. Removing OSTree causes fuse-libs to
    
    133
    -    # disappear unless we mark it as user-installed.
    
    134
    -    - dnf mark install fuse-libs
    
    135
    -    - dnf erase -y bubblewrap ostree
    
    136
    -
    
    137
    -    # Since the unix platform is required to run as root, no user change required
    
    138
    -    - ${TEST_COMMAND}
    
    139
    -
    
    140
    -
    
    141
    -tests-fedora-missing-deps:
    
    142
    -  # Ensure that tests behave nicely while missing bwrap and ostree
    
    143
    -  image: buildstream/testsuite-fedora:28-master-119-552f5fc6
    
    144
    -  <<: *tests
    
    145
    -
    
    146
    -  script:
    
    147
    -    # We remove the Bubblewrap and OSTree packages here so that we catch any
    
    148
    -    # codepaths that try to use them. Removing OSTree causes fuse-libs to
    
    149
    -    # disappear unless we mark it as user-installed.
    
    150
    -    - dnf mark install fuse-libs
    
    151
    -    - dnf erase -y bubblewrap ostree
    
    152
    -
    
    153
    -    - useradd -Um buildstream
    
    154
    -    - chown -R buildstream:buildstream .
    
    155
    -
    
    156
    -    - ${TEST_COMMAND}
    
    157
    -
    
    158
    -
    
    159
    -# Automatically build documentation for every commit, we want to know
    
    160
    -# if building documentation fails even if we're not deploying it.
    
    161
    -# Note: We still do not enforce a consistent installation of python3-sphinx,
    
    162
    -#       as it will significantly grow the backing image.
    
    163
    -docs:
    
    164
    -  stage: test
    
    165
    -  script:
    
    166
    -  - export BST_SOURCE_CACHE="$(pwd)/cache/integration-cache/sources"
    
    167
    -  # Currently sphinx_rtd_theme does not support Sphinx >1.8, this breaks search functionality
    
    168
    -  - pip3 install sphinx==1.7.9
    
    169
    -  - pip3 install sphinx-click
    
    170
    -  - pip3 install sphinx_rtd_theme
    
    171
    -  - cd dist && ./unpack.sh && cd buildstream
    
    172
    -  - make BST_FORCE_SESSION_REBUILD=1 -C doc
    
    173
    -  - cd ../..
    
    174
    -  - mv dist/buildstream/doc/build/html public
    
    175
    -  except:
    
    176
    -  - schedules
    
    177
    -  artifacts:
    
    178
    -    paths:
    
    179
    -    - public/
    
    180
    -
    
    181
    -.overnight-tests: &overnight-tests-template
    
    182
    -  stage: test
    
    183
    -  variables:
    
    184
    -    BST_EXT_URL: git+https://gitlab.com/BuildStream/bst-external.git
    
    185
    -    BST_EXT_REF: 573843768f4d297f85dc3067465b3c7519a8dcc3 # 0.7.0
    
    186
    -    FD_SDK_REF: 612f66e218445eee2b1a9d7dd27c9caba571612e # freedesktop-sdk-18.08.19-54-g612f66e2
    
    187
    -  before_script:
    
    188
    -  - |
    
    189
    -    mkdir -p "${HOME}/.config"
    
    190
    -    cat <<EOF >"${HOME}/.config/buildstream.conf"
    
    191
    -    scheduler:
    
    192
    -      fetchers: 2
    
    193
    -    EOF
    
    194
    -  - (cd dist && ./unpack.sh && cd buildstream && pip3 install .)
    
    195
    -  - pip3 install --user -e ${BST_EXT_URL}@${BST_EXT_REF}#egg=bst_ext
    
    196
    -  - git clone https://gitlab.com/freedesktop-sdk/freedesktop-sdk.git
    
    197
    -  - git -C freedesktop-sdk checkout ${FD_SDK_REF}
    
    198
    -  only:
    
    199
    -  - schedules
    
    200
    -
    
    201
    -overnight-tests:
    
    202
    -  <<: *overnight-tests-template
    
    203
    -  script:
    
    204
    -  - make -C freedesktop-sdk
    
    205
    -  tags:
    
    206
    -  - overnight-tests
    
    207
    -
    
    208
    -overnight-tests-no-cache:
    
    209
    -  <<: *overnight-tests-template
    
    210
    -  script:
    
    211
    -  - sed -i '/artifacts:/,+1 d' freedesktop-sdk/bootstrap/project.conf
    
    212
    -  - sed -i '/artifacts:/,+1 d' freedesktop-sdk/project.conf
    
    213
    -  - make -C freedesktop-sdk
    
    214
    -  tags:
    
    215
    -  - overnight-tests
    
    216
    -
    
    217
    -# Check code quality with gitlab's built-in feature.
    
    56
    +# Release to PyPI, only for tags.
    
    218 57
     #
    
    219
    -code_quality:
    
    220
    -  image: docker:stable
    
    221
    -  stage: test
    
    222
    -  variables:
    
    223
    -    DOCKER_DRIVER: overlay2
    
    224
    -  allow_failure: true
    
    225
    -  services:
    
    226
    -    - docker:stable-dind
    
    227
    -  script:
    
    228
    -    - export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
    
    229
    -    - docker run
    
    230
    -        --env SOURCE_CODE="$PWD"
    
    231
    -        --volume "$PWD":/code
    
    232
    -        --volume /var/run/docker.sock:/var/run/docker.sock
    
    233
    -        "registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
    
    234
    -  except:
    
    235
    -  - schedules
    
    236
    -  artifacts:
    
    237
    -    paths: [gl-code-quality-report.json]
    
    238
    -
    
    239
    -#####################################################
    
    240
    -#                    Post stage                     #
    
    241
    -#####################################################
    
    242
    -
    
    243
    -analysis:
    
    244
    -  stage: post
    
    245
    -  script:
    
    246
    -  - |
    
    247
    -    pip3 install radon
    
    248
    -    mkdir analysis
    
    249
    -
    
    250
    -  - |
    
    251
    -    echo "Calculating Maintainability Index"
    
    252
    -    radon mi -s -j buildstream > analysis/mi.json
    
    253
    -    radon mi -s buildstream
    
    254
    -
    
    255
    -  - |
    
    256
    -    echo "Calculating Cyclomatic Complexity"
    
    257
    -    radon cc -a -s -j buildstream > analysis/cc.json
    
    258
    -    radon cc -a -s buildstream
    
    259
    -
    
    260
    -  - |
    
    261
    -    echo "Calculating Raw Metrics"
    
    262
    -    radon raw -s -j buildstream > analysis/raw.json
    
    263
    -    radon raw -s buildstream
    
    264
    -
    
    265
    -  except:
    
    266
    -  - schedules
    
    267
    -  artifacts:
    
    268
    -    paths:
    
    269
    -    - analysis/
    
    270
    -
    
    271
    -# Collate coverage reports
    
    272
    -#
    
    273
    -coverage:
    
    274
    -  stage: post
    
    275
    -  coverage: '/TOTAL +\d+ +\d+ +(\d+\.\d+)%/'
    
    276
    -  script:
    
    277
    -    - cd dist && ./unpack.sh && cd buildstream
    
    278
    -    - pip3 install --no-index .
    
    279
    -    - mkdir report
    
    280
    -    - cd report
    
    281
    -    - cp ../../../coverage-unix/coverage.* .
    
    282
    -    - cp ../../../coverage-linux/coverage.* .
    
    283
    -    - ls coverage.*
    
    284
    -    - coverage combine --rcfile=../.coveragerc -a coverage.*
    
    285
    -    - coverage report --rcfile=../.coveragerc -m
    
    286
    -  dependencies:
    
    287
    -  - tests-debian-9
    
    288
    -  - tests-fedora-27
    
    289
    -  - tests-fedora-28
    
    290
    -  - tests-unix
    
    291
    -  - source_dist
    
    292
    -  except:
    
    293
    -  - schedules
    
    294
    -
    
    295
    -# Deploy, only for merges which land on master branch.
    
    58
    +# TODO: To begin with, we only upload to test.pypi. Later we should also push
    
    59
    +# to real PyPI after verifying that it can be installed correctly.
    
    296 60
     #
    
    297
    -pages:
    
    61
    +pypi_release:
    
    298 62
       stage: post
    
    299 63
       dependencies:
    
    300 64
       - source_dist
    
    301
    -  - docs
    
    302
    -  variables:
    
    303
    -    ACME_DIR: public/.well-known/acme-challenge
    
    304 65
       script:
    
    305
    -  - mkdir -p ${ACME_DIR}
    
    306
    -    # Required to finish the creation of the Let's Encrypt certificate,
    
    307
    -    # which allows using https://docs.buildstream.build/ for accessing
    
    308
    -    # the documentation.
    
    309
    -  - echo ${ACME_CHALLENGE} > ${ACME_DIR}/$(echo ${ACME_CHALLENGE} | cut -c1-43)
    
    310
    -  artifacts:
    
    311
    -    paths:
    
    312
    -    - public/
    
    313
    -  only:
    
    314
    -  #
    
    315
    -  # FIXME:
    
    316
    -  #
    
    317
    -  # Ideally we want to publish to a different subdir of
    
    318
    -  # pages depending on which stable branch we are building here,
    
    319
    -  # not currently automatically supported but can be worked around.
    
    320
    -  #
    
    321
    -  # See https://gitlab.com/gitlab-org/gitlab-ce/issues/35141
    
    322
    -  #
    
    323
    -  - master
    
    324
    -  except:
    
    325
    -  - schedules
    66
    +  - |
    
    67
    +    if [[ ! "$CI_COMMIT_TAG" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
    
    68
    +        echo "Not processing non-numeric tag: $CI_COMMIT_TAG for PyPI"
    
    69
    +    fi
    
    70
    +    minor_version="$(echo "$CI_COMMIT_TAG" | cut -d. -f2)"
    
    71
    +    if [[ "$(( minor_version %2 ))" -ne 0 ]]; then
    
    72
    +        echo "Not uploading development release: $CI_COMMIT_TAG to PyPI"
    
    73
    +    fi
    
    74
    +
    
    75
    +    # Credentials for PyPI are defined in secret CI variables "TWINE_USERNAME"
    
    76
    +    # and "TWINE_PASSWORD".
    
    77
    +    echo pip3 install twine
    
    78
    +    echo twine upload --repository-url "$TEST_PYPI_UPLOAD_URL" dist/*.tar.gz
    
    79
    +    echo pip3 install --extra-index-url "$TEST_PYPI_INDEX_URL" "BuildStream==$CI_COMMIT_TAG"
    
    80
    +    echo bst --version
    
    81
    +  # only:
    
    82
    +  # - tags



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