-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
148 lines (136 loc) · 5.21 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
stages:
- check-format
- build
- test
- export
default:
image: $DOCKER_REGISTRY/research/templates/cpp/ubuntu20
tags: ['shared']
check-format:
stage: check-format
script:
- pre-commit install-hooks
- |+
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.
NOTE FOR PROJECTS WITH C/C++ CODE:
pre-commit will by default use the correct version of every formatting tool
EXCEPT FOR clang-format. You need to ensure the version of clang-format you
use is EXACTLY version 6.0.0. This is available in Ubuntu 18 by default.
================================================================================
EOF
) && exit 1)
build-linux:
stage: build
needs: [check-format]
image: $DOCKER_REGISTRY/rewriting/mc-asm/llvm:14
artifacts:
name: "$CI_COMMIT_REF_NAME-$CI_JOB_NAME"
paths:
- mcasm*.whl
expire_in: 1 week
script:
- python3.7 -m build --wheel
- python3.8 -m build --wheel
- python3.9 -m build --wheel
- python3.10 -m build --wheel
- find dist -name \*.whl -print0 | xargs -0 -n1 auditwheel repair -w dist/wheelhouse
- cp dist/wheelhouse/*.whl ./
build-windows:
stage: build
tags: [mcasm-windows]
variables:
PYTHON_VERSIONS: "37 38 39 310"
artifacts:
paths:
- mcasm*.whl
script:
- for version in $PYTHON_VERSIONS; do
echo "Building wheel for Python $version";
pip="/cygdrive/c/Python${version}/Scripts/pip.exe";
pipx=$(cygpath -w "/cygdrive/c/Python${version}/Scripts/pipx.exe");
$pip install -r requirements-dev.txt;
$pip install pipx;
cmd /C "C:\\VS\\VC\\Auxiliary\\Build\\vcvars64.bat && $pipx run build --wheel" | tee /dev/null;
done
- cp dist/mcasm*.whl ./
.test-linux: &test_linux
stage: test
needs: [build-linux]
script:
- python -m pip install -r requirements-dev.txt
- python -m pip install --no-index --find-links ./ mcasm
- python -m pytest --junitxml=report.xml
artifacts:
when: always
reports:
junit: report.xml
test-linux-py37:
image: python:3.7-slim
<<: *test_linux
test-linux-py38:
image: python:3.9-slim
<<: *test_linux
test-linux-py39:
image: python:3.9-slim
<<: *test_linux
test-linux-py310:
image: python:3.10-slim
<<: *test_linux
# 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
needs: [build-linux, build-windows]
image: python:3.7-slim
script:
- pip3 install -r requirements-dev.txt
- pip3 install --no-index --find-links ./ mcasm
- VERSION=$(python3 -c "import mcasm; print(mcasm.__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 "mcasm>$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/*.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/*.whl
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
- if: '$CI_COMMIT_REF_NAME =~ /^release-.*/'
export_external:
stage: export
needs: [build-linux, build-windows]
image: python:3.7-slim
script:
- pip3 install -r requirements-dev.txt
- pip3 install --no-index --find-links ./ mcasm
- VERSION=$(python3 -c "import mcasm; print(mcasm.__version__);")
# Do not publish .dev versions on the public pypi
- if [[ "$VERSION" =~ \.dev[[:digit:]]*.*$ ]]; then exit 1; fi
- python3 -m twine upload --verbose $CI_PROJECT_DIR/*.whl -u __token__ -p $PYPI_API_KEY
rules:
- if: '$CI_COMMIT_REF_NAME =~ /^release-.*/'