Skip to content

Commit 267161e

Browse files
committed
try to add ci
1 parent ca1f32d commit 267161e

File tree

4 files changed

+244
-0
lines changed

4 files changed

+244
-0
lines changed

.circleci/config.yml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
version: 2
2+
jobs:
3+
cargo_fetch:
4+
docker:
5+
- image: broooooklyn/rust-python:latest
6+
working_directory: /mnt/crate
7+
steps:
8+
- checkout
9+
- restore_cache:
10+
keys:
11+
- cargo-v1-{{ checksum "Cargo.toml" }}-
12+
- cargo-v1-
13+
- run:
14+
name: fetch and update
15+
command: |
16+
cargo update && \
17+
cargo fetch
18+
- persist_to_workspace:
19+
root: "."
20+
paths:
21+
- Cargo.lock
22+
- save_cache:
23+
key: cargo-v1-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
24+
paths:
25+
- /usr/local/cargo/registry
26+
- /usr/local/cargo/git
27+
build35:
28+
docker:
29+
- 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: Upload binary
47+
command: |
48+
ghr $CIRCLE_TAG build/lib/py_sourcemap/*.so
49+
- run:
50+
name: Prune the output files
51+
command: |
52+
for file in target/release/* target/release/.??*; do
53+
[ -d $file -o ! -x $file ] && rm -r $file
54+
done
55+
- persist_to_workspace:
56+
root: "."
57+
paths:
58+
- target/release/*
59+
build36:
60+
docker:
61+
- image: broooooklyn/rust-python:3.6
62+
working_directory: /mnt/crate
63+
steps:
64+
- checkout
65+
- attach_workspace:
66+
at: "."
67+
- restore_cache:
68+
keys:
69+
- cargo-v1-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
70+
- run:
71+
name: Print version information
72+
command: rustc --version; cargo --version
73+
- run:
74+
name: Build 36
75+
command: |
76+
python compile.py build
77+
- run:
78+
name: Upload binary
79+
command: |
80+
ghr $CIRCLE_TAG build/lib/py_sourcemap/*.so
81+
- run:
82+
name: Prune the output files
83+
command: |
84+
for file in target/release/* target/release/.??*; do
85+
[ -d $file -o ! -x $file ] && rm -r $file
86+
done
87+
- persist_to_workspace:
88+
root: "."
89+
paths:
90+
- target/release/*
91+
build37:
92+
docker:
93+
- image: broooooklyn/rust-python:3.7
94+
working_directory: /mnt/crate
95+
steps:
96+
- checkout
97+
- attach_workspace:
98+
at: "."
99+
- restore_cache:
100+
keys:
101+
- cargo-v1-{{ checksum "Cargo.toml" }}-{{ checksum "Cargo.lock" }}
102+
- run:
103+
name: Print version information
104+
command: rustc --version; cargo --version
105+
- run:
106+
name: Build 37
107+
command: |
108+
python compile.py build
109+
- run:
110+
name: Upload binary
111+
command: |
112+
ghr $CIRCLE_TAG build/lib/py_sourcemap/*.so
113+
- run:
114+
name: Prune the output files
115+
command: |
116+
for file in target/release/* target/release/.??*; do
117+
[ -d $file -o ! -x $file ] && rm -r $file
118+
done
119+
- persist_to_workspace:
120+
root: "."
121+
paths:
122+
- target/release/*
123+
124+
nightly:
125+
machine: true
126+
triggers:
127+
- schedule:
128+
cron: "0 0 * * *"
129+
filters:
130+
branches:
131+
only:
132+
- master
133+
steps:
134+
- checkout
135+
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS
136+
- run: docker build . -t broooooklyn/rust-python:3.5 --build-arg PYTHON_VERSION=3.5
137+
- run: docker push broooooklyn/rust-python:3.5
138+
- run: docker build . -t broooooklyn/rust-python:3.6 --build-arg PYTHON_VERSION=3.6
139+
- run: docker push broooooklyn/rust-python:3.6
140+
- run: docker build . -t broooooklyn/rust-python:3.7 --build-arg PYTHON_VERSION=3.7
141+
- run: docker tag broooooklyn/rust-python:3.7 broooooklyn/rust-python:latest
142+
- run: docker push broooooklyn/rust-python:3.7
143+
- run: docker push broooooklyn/rust-python:latest
144+
workflows:
145+
version: 2
146+
build_all_versions:
147+
jobs:
148+
- cargo_fetch
149+
- build35:
150+
requires:
151+
- cargo_fetch
152+
- build36:
153+
requires:
154+
- cargo_fetch
155+
- build37:
156+
requires:
157+
- cargo_fetch

.travis.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
language: python
2+
python:
3+
- "3.5"
4+
- "3.6"
5+
- "3.7"
6+
os: osx
7+
cache: cargo
8+
before_install:
9+
- brew update
10+
- brew install rust
11+
- rustup default nightly
12+
13+
install:
14+
- pip install -r requirements-dev.txt
15+
16+
script: |
17+
python compile.py build
18+
19+
deploy:
20+
provider: releases
21+
api_key:
22+
secure: $GITHUB_TOKEN
23+
file: build/lib/py_sourcemap/py_sourcemap.so
24+
skip_cleanup: true
25+
on:
26+
tags: true

Dockerfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM ubuntu:16.04
2+
3+
ENV GHR_VERSION="0.9.0"
4+
5+
ARG PYTHON_VERSION=3.6
6+
7+
ENV RUSTUP_HOME=/usr/local/rustup \
8+
CARGO_HOME=/usr/local/cargo \
9+
PATH=/usr/local/cargo/bin:$PATH \
10+
RUST_VERSION=1.28.0
11+
12+
RUN apt-get update && \
13+
apt-get install software-properties-common python-software-properties -y && \
14+
add-apt-repository ppa:deadsnakes/ppa -y && \
15+
apt-get update && \
16+
apt-get install python${PYTHON_VERSION} python3-pip wget git curl -y && \
17+
apt-get upgrade -y && \
18+
apt-get autoremove -y && \
19+
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
27+
28+
RUN set -eux; \
29+
dpkgArch="$(dpkg --print-architecture)"; \
30+
case "${dpkgArch##*-}" in \
31+
amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='f69dafcca62fe70d7882113e21bb96a2cbdf4fc4636d25337d6de9191bdec8da' ;; \
32+
armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='eee969b9fd128e8dc9b4ec44acde46735cf8e612d06495e9d022517849aba2d6' ;; \
33+
arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='cdc48b7882582fd8475107a406dd86df85c7d72e5deea99ff8940c8e11531285' ;; \
34+
i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='3bad3945452509ac28ba4113e198323daab57488d6885bb31ac30c9eecd88825' ;; \
35+
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
36+
esac; \
37+
url="https://static.rust-lang.org/rustup/archive/1.13.0/${rustArch}/rustup-init"; \
38+
wget "$url"; \
39+
echo "${rustupSha256} *rustup-init" | sha256sum -c -; \
40+
chmod +x rustup-init; \
41+
./rustup-init -y --no-modify-path --default-toolchain $RUST_VERSION; \
42+
rm rustup-init; \
43+
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
44+
rustup default nightly && \
45+
rustup --version; \
46+
cargo --version; \
47+
rustc --version;

compile.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1+
import sys
2+
13
from setuptools import setup
24
from setuptools_rust import Binding, RustExtension
35

6+
try:
7+
from setuptools_rust import RustExtension
8+
except ImportError:
9+
import subprocess
10+
11+
errno = subprocess.call([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 RustExtension
17+
418
setup(name='py-sourcemap',
519
version='0.1',
620
rust_extensions=[RustExtension('py_sourcemap.py_sourcemap',

0 commit comments

Comments
 (0)