-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
87 lines (81 loc) · 3.6 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
variables:
GIT_SUBMODULE_STRATEGY: recursive
GIT_STRATEGY: clone
stages:
- check-format
- test
- export
default:
image: python:3.7-slim
tags: ['shared']
check-format:
stage: check-format
script:
- apt update -y && apt install -y git
- pip3 install pre-commit
- |+
pre-commit run --all-files --show-diff-on-failure || ( (cat <<EOF
================================================================================
If this stage fails, the formatting of your changes may be incorrect.
To automatically format your files, install pre-commit:
pip3 install pre-commit
pre-commit install
pre-commit will now automatically format any files before commit.
To fix any misformatted files, run:
pre-commit run --all-files
And then commit any changes.
More information regarding pre-commit can be found at https://pre-commit.com.
================================================================================
EOF
) && exit 1)
test:
stage: test
script:
- pip3 install -r requirements-dev.txt
- pip3 install -e .
- pytest --cov=gtirb_test_helpers --cov-fail-under=90
# Only gtirb 0.10.6 has type information
- pip3 install --upgrade 'gtirb >= 0.10.6.dev0' --extra-index-url $EXTRA_INDEX_URL
- mypy gtirb_test_helpers
# This job ensures that:
# - Release branches never publish -dev packages, and packages
# on release branches are never overwritten. This behavior coincides
# with that of the external export job, where on the public pypi, packages
# cannot be overwritten.
# - master therefore only ever publishes '-dev' packages
# - The -dev package on master is always the newest version in the repository
export_internal:
stage: export
script:
- pip install -r requirements-dev.txt
- python3 setup.py bdist_wheel --dist-dir=$CI_PROJECT_DIR/dist
- VERSION=$(python3 -c "from imp import load_source; pkginfo = load_source('pkginfo.version', 'gtirb_test_helpers/version.py'); print(pkginfo.__version__)")
- if [[ "$VERSION" =~ \.dev[[:digit:]]*.*$ && "$CI_COMMIT_REF_NAME" =~ ^release-.* ]]; then exit 1; fi
# this job is not using $CI_JOB_TOKEN because it only has read access
# https://gitlab.com/gitlab-org/gitlab/-/issues/35067
# this job is also not using $CI_DEPLOY_USER and $CI_DEPLOY_PASSWORD because it only has write access
- if [[ "$CI_COMMIT_BRANCH" == "master" ]]; then
if [[ ! "$VERSION" =~ \.dev[[:digit:]]*$ ]]; then
echo "[ERROR] On the master branch, we must be exporting a -dev version."
exit 1;
fi;
if pip3 install --extra-index-url=$EXTRA_INDEX_URL "gtirb-test-helpers>$VERSION" 2>/dev/null; then
echo "[ERROR] The package version being published on master should always be >= the version in the repository.";
exit 1;
fi;
ls $CI_PROJECT_DIR/dist/*.whl | xargs python3 $CI_PROJECT_DIR/delete_remote_packages.py $GL_PKG_API_TOKEN;
fi
- sed "s/password = <access token>/password = $GL_PKG_API_TOKEN/" $CI_PROJECT_DIR/.pypirc > ~/.pypirc
- python3 -m twine upload --verbose --repository repypi $CI_PROJECT_DIR/dist/*.whl
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
- if: '$CI_COMMIT_REF_NAME =~ /^release-.*/'
export_external:
stage: export
script:
- pip install -r requirements-dev.txt
- python3 setup.py bdist_wheel --dist-dir=$CI_PROJECT_DIR/dist
- python3 -m twine check $CI_PROJECT_DIR/dist/*;
- python3 -m twine upload $CI_PROJECT_DIR/dist/* -u __token__ -p $PYPI_API_KEY;
rules:
- if: '$CI_COMMIT_REF_NAME =~ /^release-.*/'