Skip to content

Commit 10d3c47

Browse files
authored
Merge pull request #2 from LeetCode-OpenSource/infra
Improve Infrastructure
2 parents 4e75c99 + 225e786 commit 10d3c47

File tree

13 files changed

+214
-175
lines changed

13 files changed

+214
-175
lines changed

.bumpversion.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[bumpversion]
2+
current_version = 0.1.10
3+
commit = True
4+
tag = True
5+
6+
[bumpversion:file:setup.py]

.circleci/config.yml

Lines changed: 73 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
build: &build
2+
working_directory: /mnt/crate
3+
steps:
4+
- checkout
5+
- attach_workspace:
6+
at: "."
7+
- restore_cache:
8+
keys:
9+
- cargo-v1-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
10+
- run:
11+
name: Print version information
12+
command: rustc --version; cargo --version; python -V;
13+
- run:
14+
name: Build 35
15+
command: |
16+
pip install -r requirement-dev.txt && python compile.py build
17+
- run:
18+
name: Test 35
19+
command: |
20+
cp build/lib/py_sourcemap/*.so py_sourcemap/ && \
21+
nosetests
22+
- run:
23+
name: Prune the output files
24+
command: |
25+
for file in target/release/* target/release/.??*; do
26+
[ -d $file -o ! -x $file ] && rm -r $file
27+
done
28+
- persist_to_workspace:
29+
root: "."
30+
paths:
31+
- ./*
32+
33+
deploy: &deploy
34+
docker:
35+
- image: tsub/ghr:latest
36+
working_directory: /mnt/crate
37+
steps:
38+
- attach_workspace:
39+
at: "."
40+
- run:
41+
name: 'Deploy to Github Release'
42+
command: |
43+
export GIT_TAG="$(git describe --tags $(git rev-list --tags --max-count=1))"; \
44+
ghr -u "${CIRCLE_PROJECT_USERNAME}" -r "${CIRCLE_PROJECT_REPONAME}" "${GIT_TAG}" build/lib/py_sourcemap/*.so
45+
146
version: 2
247
jobs:
348
cargo_fetch:
@@ -25,128 +70,36 @@ jobs:
2570
- /usr/local/cargo/registry
2671
- /usr/local/cargo/git
2772
build35:
73+
<<: *build
2874
docker:
2975
- image: broooooklyn/rust-python:3.5
30-
working_directory: /mnt/crate
31-
steps:
32-
- checkout
33-
- attach_workspace:
34-
at: "."
35-
- restore_cache:
36-
keys:
37-
- cargo-v1-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
38-
- run:
39-
name: Print version information
40-
command: rustc --version; cargo --version
41-
- run:
42-
name: Build 35
43-
command: |
44-
python compile.py build
45-
- run:
46-
name: Prune the output files
47-
command: |
48-
for file in target/release/* target/release/.??*; do
49-
[ -d $file -o ! -x $file ] && rm -r $file
50-
done
51-
- persist_to_workspace:
52-
root: "."
53-
paths:
54-
- ./*
76+
5577
build36:
78+
<<: *build
5679
docker:
5780
- image: broooooklyn/rust-python:3.6
58-
working_directory: /mnt/crate
59-
steps:
60-
- checkout
61-
- attach_workspace:
62-
at: "."
63-
- restore_cache:
64-
keys:
65-
- cargo-v1-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
66-
- run:
67-
name: Print version information
68-
command: rustc --version; cargo --version
69-
- run:
70-
name: Build 36
71-
command: |
72-
python compile.py build
73-
- run:
74-
name: Prune the output files
75-
command: |
76-
for file in target/release/* target/release/.??*; do
77-
[ -d $file -o ! -x $file ] && rm -r $file
78-
done
79-
- persist_to_workspace:
80-
root: "."
81-
paths:
82-
- ./*
81+
8382
build37:
83+
<<: *build
8484
docker:
8585
- image: broooooklyn/rust-python:3.7
86-
working_directory: /mnt/crate
87-
steps:
88-
- checkout
89-
- attach_workspace:
90-
at: "."
91-
- restore_cache:
92-
keys:
93-
- cargo-v1-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
94-
- run:
95-
name: Print version information
96-
command: rustc --version; cargo --version
97-
- run:
98-
name: Build 37
99-
command: |
100-
python compile.py build
101-
- run:
102-
name: Prune the output files
103-
command: |
104-
for file in target/release/* target/release/.??*; do
105-
[ -d $file -o ! -x $file ] && rm -r $file
106-
done
107-
- persist_to_workspace:
108-
root: "."
109-
paths:
110-
- ./*
11186

112-
deploy35:
113-
docker:
114-
- image: tsub/ghr:latest
115-
working_directory: /mnt/crate
116-
steps:
117-
- attach_workspace:
118-
at: "."
119-
- run:
120-
name: 'Deploy to Github Release'
121-
command: |
122-
export GIT_TAG="$(git describe --tags $(git rev-list --tags --max-count=1))"; \
123-
ghr -u "${CIRCLE_PROJECT_USERNAME}" -r "${CIRCLE_PROJECT_REPONAME}" "${GIT_TAG}" build/lib/py_sourcemap/*.so
87+
deploy35: *deploy
12488

125-
deploy36:
126-
docker:
127-
- image: tsub/ghr:latest
128-
working_directory: /mnt/crate
129-
steps:
130-
- attach_workspace:
131-
at: "."
132-
- run:
133-
name: 'Deploy to Github Release'
134-
command: |
135-
export GIT_TAG="$(git describe --tags $(git rev-list --tags --max-count=1))"; \
136-
ghr -u "${CIRCLE_PROJECT_USERNAME}" -r "${CIRCLE_PROJECT_REPONAME}" "${GIT_TAG}" build/lib/py_sourcemap/*.so
89+
deploy36: *deploy
90+
91+
deploy37: *deploy
13792

138-
deploy37:
93+
pip_deploy:
13994
docker:
140-
- image: tsub/ghr:latest
95+
- image: broooooklyn/rust-python:latest
14196
working_directory: /mnt/crate
14297
steps:
14398
- attach_workspace:
14499
at: "."
145100
- run:
146101
name: 'Deploy to Github Release'
147-
command: |
148-
export GIT_TAG="$(git describe --tags $(git rev-list --tags --max-count=1))"; \
149-
ghr -u "${CIRCLE_PROJECT_USERNAME}" -r "${CIRCLE_PROJECT_REPONAME}" "${GIT_TAG}" build/lib/py_sourcemap/*.so
102+
command: pip install -r requirement-dev.txt && make release
150103

151104
nightly:
152105
machine: true
@@ -182,6 +135,8 @@ workflows:
182135
filters:
183136
tags:
184137
only: /.*/
138+
branches:
139+
only: master
185140
- build36:
186141
requires:
187142
- cargo_fetch
@@ -191,6 +146,8 @@ workflows:
191146
filters:
192147
tags:
193148
only: /.*/
149+
branches:
150+
only: master
194151
- build37:
195152
requires:
196153
- cargo_fetch
@@ -200,3 +157,15 @@ workflows:
200157
filters:
201158
tags:
202159
only: /.*/
160+
branches:
161+
only: master
162+
- pip_deploy:
163+
requires:
164+
- deploy35
165+
- deploy36
166+
- deploy37
167+
filters:
168+
tags:
169+
only: /.*/
170+
branches:
171+
only: master

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ build
66
*.so
77
.eggs
88
*.egg-info
9+
dist
910

1011
# editor related
1112
.vscode

.travis.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,26 @@ python:
44
- "3.6"
55
- "3.7"
66
os: osx
7+
osx_image: xcode9.3
78
cache: cargo
89
before_install:
910
- brew update
1011
- brew install rust
1112
- rustup default nightly
1213

14+
install:
15+
- pip install -r requirements-dev.txt
16+
1317
script: |
14-
python compile.py build
18+
python compile.py build && \
19+
cp build/lib/py_sourcemap/*.so py_sourcemap/ && \
20+
nosetests
1521
1622
deploy:
1723
provider: releases
1824
api_key:
1925
secure: $GITHUB_TOKEN
20-
file: build/lib/py_sourcemap/py_sourcemap.so
26+
file: build/lib/py_sourcemap/*.so
2127
skip_cleanup: true
2228
on:
2329
tags: true

Dockerfile

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
FROM ubuntu:16.04
2-
3-
ENV GHR_VERSION="0.9.0"
1+
FROM ubuntu:18.04
42

53
ARG PYTHON_VERSION=3.6
64

75
ENV RUSTUP_HOME=/usr/local/rustup \
86
CARGO_HOME=/usr/local/cargo \
97
PATH=/usr/local/cargo/bin:$PATH \
10-
RUST_VERSION=1.28.0
8+
RUST_VERSION=nightly
119

1210
RUN apt-get update && \
13-
apt-get install software-properties-common python-software-properties -y && \
11+
echo $PYTHON_VERSION && \
12+
apt-get install software-properties-common -y --no-install-recommends && \
1413
add-apt-repository ppa:deadsnakes/ppa -y && \
15-
apt-get update && \
16-
apt-get install python${PYTHON_VERSION} python3-pip wget git curl -y && \
14+
apt-get install python${PYTHON_VERSION} wget build-essential git curl -y --no-install-recommends && \
1715
apt-get upgrade -y && \
1816
apt-get autoremove -y && \
1917
ln -sf /usr/bin/python${PYTHON_VERSION} /usr/bin/python && \
20-
curl -fSL -o ghr.tar.gz "https://github.com/tcnksm/ghr/releases/download/v${GHR_VERSION}/ghr_v${GHR_VERSION}_linux_amd64.tar.gz" && \
21-
tar -xvzf ghr.tar.gz && \
22-
mv ghr_v0.9.0_linux_amd64/ghr /usr/local/bin && \
23-
chown root:root /usr/local/bin/ghr && \
24-
rm -r \
25-
ghr.tar.gz \
26-
ghr_v0.9.0_linux_amd64
18+
if [ $PYTHON_VERSION = '3.6' ]; \
19+
then \
20+
apt-get install python3-pip -y --no-install-recommends && \
21+
ln -sf /usr/bin/pip3 /usr/bin/pip; \
22+
else \
23+
curl https://bootstrap.pypa.io/get-pip.py | python${PYTHON_VERSION}; \
24+
fi && \
25+
pip install --upgrade pip
2726

2827
RUN set -eux; \
2928
dpkgArch="$(dpkg --print-architecture)"; \
@@ -44,4 +43,6 @@ RUN set -eux; \
4443
rustup default nightly && \
4544
rustup --version; \
4645
cargo --version; \
47-
rustc --version;
46+
rustc --version; \
47+
python -V; \
48+
pip -V;

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2018 LeetCode
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
format:
2+
yapf **/*.py -i
3+
4+
release:
5+
python3 setup.py sdist bdist_wheel
6+
twine upload --repository-url https://upload.pypi.org/legacy/ dist/* -u $PYPI_USERNAME -p $PYPI_PASSWORD

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# py-sourcemap
2+
23
A tiny [source-map-mappings](https://github.com/fitzgen/source-map-mappings) bindings for python using [PyO3](https://github.com/PyO3/pyo3)

compile.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,26 @@
33
from setuptools import setup
44

55
try:
6-
from setuptools_rust import Binding, RustExtension
6+
from setuptools_rust import Binding, RustExtension
77
except ImportError:
8-
import subprocess
8+
import subprocess
99

10-
errno = subprocess.call([sys.executable, "-m", "pip", "install", "setuptools-rust"])
11-
if errno:
12-
print("Please install setuptools-rust package")
13-
raise SystemExit(errno)
14-
else:
15-
from setuptools_rust import Binding, RustExtension
10+
errno = subprocess.call(
11+
[sys.executable, "-m", "pip", "install", "setuptools-rust"])
12+
if errno:
13+
print("Please install setuptools-rust package")
14+
raise SystemExit(errno)
15+
else:
16+
from setuptools_rust import Binding, RustExtension
1617

17-
setup(name='py-sourcemap',
18-
version='0.1',
19-
rust_extensions=[RustExtension('py_sourcemap.py_sourcemap',
20-
'Cargo.toml', binding=Binding.PyO3)],
21-
packages=['py_sourcemap'],
22-
setup_requires=['setuptools_rust>=0.10.2'],
23-
# rust extensions are not zip safe, just like C-extensions.
24-
zip_safe=False
25-
)
18+
setup(
19+
name='py-sourcemap',
20+
version='0.1',
21+
rust_extensions=[
22+
RustExtension(
23+
'py_sourcemap.py_sourcemap', 'Cargo.toml', binding=Binding.PyO3)
24+
],
25+
packages=['py_sourcemap'],
26+
setup_requires=['setuptools_rust>=0.10.2'],
27+
# rust extensions are not zip safe, just like C-extensions.
28+
zip_safe=False)

py_sourcemap/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
from .py_sourcemap import SourcemapParser
22

3+
name = 'py_sourcemap'
4+
35
__all__ = ["SourcemapParser"]

requirement-dev.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
yapf==0.23.0
2+
twine==1.11.0
3+
bumpversion==0.5.3
4+
nose==1.3.7

0 commit comments

Comments
 (0)