Skip to content

Commit 4d47528

Browse files
committed
open source initial commit
1 parent ac939f5 commit 4d47528

File tree

108 files changed

+19128
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+19128
-1
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target

.github/workflows/nodejs.yml

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: Nodejs - Test & Release Package
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
defaults:
9+
run:
10+
working-directory: toolchain/chidori
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
18+
nodejs-github-native:
19+
permissions: write-all
20+
name: nodejs-${{ matrix.node_version }}-${{ matrix.system.target }}-${{ matrix.system.os }}
21+
runs-on: ${{ matrix.system.os }}
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
node_version:
26+
- 14
27+
- 16
28+
system:
29+
- os: macos-11
30+
target: x86_64-apple-darwin
31+
- os: ubuntu-20.04
32+
target: x86_64-unknown-linux-gnu
33+
- os: windows-2022
34+
target: x86_64-pc-windows-msvc
35+
# Would like to have aarch64 support, but actions does not provide these yet.
36+
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
37+
steps:
38+
- uses: actions/checkout@v3
39+
with:
40+
ref: ${{ github.event.release.tag_name }}
41+
- name: Set release version
42+
# Set release version in all three os, the commented run should suffice for linux and mac.
43+
run: python3 -c "import os; tag = os.environ['GITHUB_REF'].split('/')[-1]; f = open(os.environ['GITHUB_ENV'], 'a'); f.write('RELEASE_VERSION='+tag); f.close();"
44+
# run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
45+
46+
- uses: actions/setup-node@v3
47+
with:
48+
node-version: ${{ matrix.node_version }}
49+
registry-url: 'https://registry.npmjs.org'
50+
- name: Set up cargo cache
51+
uses: actions/cache@v3
52+
continue-on-error: false
53+
with:
54+
path: |
55+
~/.cargo/bin/
56+
~/.cargo/registry/index/
57+
~/.cargo/registry/cache/
58+
~/.cargo/git/db/
59+
toolchain/target/
60+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
61+
restore-keys: ${{ runner.os }}-cargo-
62+
- name: Install modules
63+
working-directory: toolchain/chidori
64+
run: rm ../../package.json && yarn install
65+
- name: Tweak package.json
66+
working-directory: toolchain/chidori
67+
# This will update the package version to tag version. So artifacts uploaded to Github release will be named correctly.
68+
run: python3 -c "import os; import json; p = json.load(open('package.json')); p['version'] = os.environ['RELEASE_VERSION']; json.dump(p, open('package.json', 'w'), indent=2, ensure_ascii=False);"
69+
70+
- uses: actions-rs/toolchain@v1
71+
with:
72+
profile: minimal
73+
toolchain: stable
74+
target: ${{ matrix.system.target }}
75+
override: true
76+
77+
- name: Build native
78+
working-directory: toolchain/chidori
79+
run: yarn run build-release
80+
- name: Package the asset
81+
working-directory: toolchain/chidori
82+
# This will make a node-pre-gyp package.
83+
run: npx node-pre-gyp package
84+
- name: Upload to Github releases
85+
working-directory: toolchain/chidori
86+
# Use bash, even on Windows to make find available
87+
shell: bash
88+
# A release need to be created before upload
89+
run: gh release upload ${{ env.RELEASE_VERSION }} "$(find ./build -name *.tar.gz)" --clobber
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
93+
94+
nodejs-npm:
95+
name: nodejs-npm
96+
runs-on: ubuntu-latest
97+
# Prevent a situation where native build fails and an npm package is uploaded.
98+
needs: [ nodejs-github-native ]
99+
steps:
100+
- uses: actions/checkout@v3
101+
with:
102+
ref: ${{ github.event.release.tag_name }}
103+
- name: Set release version
104+
# Set release version in all three os, the commented run should suffice for linux and mac.
105+
run: python3 -c "import os; tag = os.environ['GITHUB_REF'].split('/')[-1]; f = open(os.environ['GITHUB_ENV'], 'a'); f.write('RELEASE_VERSION='+tag); f.close();"
106+
# run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
107+
108+
- uses: actions/setup-node@v3
109+
with:
110+
node-version: ${{ matrix.node_version }}
111+
# Url is important! This makes NODE_AUTH_TOKEN accessible to npm publish.
112+
registry-url: 'https://registry.npmjs.org'
113+
- name: Install modules
114+
working-directory: toolchain/chidori
115+
run: rm ../../package.json && yarn install
116+
- name: Tweak package.json
117+
working-directory: toolchain/chidori
118+
# This will update the package version to tag version and
119+
# add an install script in package.json so users who `npm i` this package
120+
# will trigger the node-pre-gyp to pull the os and arch specific binary.
121+
run: python3 -c "import os; import json; p = json.load(open('package.json')); p['scripts']['install'] = 'node-pre-gyp install'; p['version'] = os.environ['RELEASE_VERSION']; json.dump(p, open('package.json', 'w'), indent=2, ensure_ascii=False);"
122+
- name: Publish to npm
123+
working-directory: toolchain/chidori
124+
# `--access public` is used to publish to my account's scope.
125+
run: npm publish --access public
126+
env:
127+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
128+
129+

.github/workflows/python.yml

+257
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
name: Python - Test & Release Package
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
env:
13+
PACKAGE_NAME: chidori
14+
PYTHON_VERSION: "3.9" # to build abi3 wheels
15+
16+
jobs:
17+
python-macos:
18+
runs-on: macos-latest
19+
strategy:
20+
matrix:
21+
target: [x86_64]
22+
steps:
23+
- uses: actions/checkout@v3
24+
- uses: actions/setup-python@v4
25+
with:
26+
python-version: ${{ env.PYTHON_VERSION }}
27+
architecture: x64
28+
- name: Install Rust toolchain
29+
uses: actions-rs/toolchain@v1
30+
with:
31+
toolchain: stable
32+
profile: minimal
33+
default: true
34+
- name: Set up cargo cache
35+
uses: actions/cache@v3
36+
continue-on-error: false
37+
with:
38+
path: |
39+
~/.cargo/bin/
40+
~/.cargo/registry/index/
41+
~/.cargo/registry/cache/
42+
~/.cargo/git/db/
43+
toolchain/target/
44+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
45+
restore-keys: ${{ runner.os }}-cargo-
46+
- name: Build wheels - x86_64
47+
uses: messense/maturin-action@v1
48+
with:
49+
target: ${{ matrix.target }}
50+
args: --release --out dist --features python
51+
maturin-version: "v0.13.0"
52+
working-directory: toolchain/chidori
53+
sccache: true
54+
- name: Install built wheel - x86_64
55+
working-directory: toolchain/chidori
56+
run: |
57+
pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall
58+
pip install pytest pytest-mock pytest-asyncio
59+
pytest -v
60+
- name: Upload wheels
61+
uses: actions/upload-artifact@v3
62+
with:
63+
name: wheels
64+
path: toolchain/chidori/dist
65+
66+
python-macos-universal:
67+
runs-on: macos-latest
68+
strategy:
69+
matrix:
70+
target: [x86_64]
71+
steps:
72+
- uses: actions/checkout@v3
73+
- uses: actions/setup-python@v4
74+
with:
75+
python-version: ${{ env.PYTHON_VERSION }}
76+
architecture: x64
77+
- name: Install Rust toolchain
78+
uses: actions-rs/toolchain@v1
79+
with:
80+
toolchain: stable
81+
profile: minimal
82+
default: true
83+
- name: Set up cargo cache
84+
uses: actions/cache@v3
85+
continue-on-error: false
86+
with:
87+
path: |
88+
~/.cargo/bin/
89+
~/.cargo/registry/index/
90+
~/.cargo/registry/cache/
91+
~/.cargo/git/db/
92+
toolchain/target/
93+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
94+
restore-keys: ${{ runner.os }}-cargo-
95+
- name: Build wheels - universal2
96+
uses: messense/maturin-action@v1
97+
with:
98+
args: --release --universal2 --out dist --features python
99+
maturin-version: "v0.13.0"
100+
working-directory: toolchain/chidori
101+
sccache: true
102+
- name: Install built wheel - universal2
103+
working-directory: toolchain/chidori
104+
run: |
105+
pip install dist/${{ env.PACKAGE_NAME }}-*universal2.whl --force-reinstall
106+
pip install pytest pytest-mock pytest-asyncio
107+
pytest -v
108+
- name: Upload wheels
109+
uses: actions/upload-artifact@v3
110+
with:
111+
name: wheels
112+
path: toolchain/chidori/dist
113+
114+
python-windows:
115+
runs-on: windows-latest
116+
strategy:
117+
matrix:
118+
target: [x64]
119+
steps:
120+
- uses: actions/checkout@v3
121+
- uses: actions/setup-python@v4
122+
with:
123+
python-version: ${{ env.PYTHON_VERSION }}
124+
architecture: ${{ matrix.target }}
125+
- name: Install Rust toolchain
126+
uses: actions-rs/toolchain@v1
127+
with:
128+
toolchain: stable
129+
profile: minimal
130+
default: true
131+
- name: Set up cargo cache
132+
uses: actions/cache@v3
133+
continue-on-error: false
134+
with:
135+
path: |
136+
~/.cargo/bin/
137+
~/.cargo/registry/index/
138+
~/.cargo/registry/cache/
139+
~/.cargo/git/db/
140+
toolchain/target/
141+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
142+
restore-keys: ${{ runner.os }}-cargo-
143+
- name: Build wheels
144+
uses: messense/maturin-action@v1
145+
with:
146+
target: ${{ matrix.target }}
147+
args: --release --out dist --features python
148+
maturin-version: "v0.13.0"
149+
working-directory: toolchain/chidori
150+
sccache: true
151+
- name: Install built wheel
152+
shell: bash
153+
working-directory: toolchain/chidori
154+
run: |
155+
python -m pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall
156+
pip install pytest pytest-mock pytest-asyncio
157+
python -m pytest -v
158+
- name: Upload wheels
159+
uses: actions/upload-artifact@v3
160+
with:
161+
name: wheels
162+
path: toolchain/chidori/dist
163+
164+
python-linux:
165+
runs-on: ubuntu-latest
166+
strategy:
167+
matrix:
168+
target: [x86_64]
169+
steps:
170+
- uses: actions/checkout@v3
171+
- uses: actions/setup-python@v4
172+
with:
173+
python-version: ${{ env.PYTHON_VERSION }}
174+
architecture: x64
175+
- name: Build wheels
176+
uses: messense/maturin-action@v1
177+
with:
178+
target: ${{ matrix.target }}
179+
manylinux: auto
180+
args: --release --out dist --features python
181+
maturin-version: "v0.13.0"
182+
working-directory: toolchain/chidori
183+
sccache: true
184+
- name: Install built wheel
185+
working-directory: toolchain/chidori
186+
if: matrix.target == 'x86_64'
187+
run: |
188+
pip install dist/${{ env.PACKAGE_NAME }}-*.whl --force-reinstall
189+
pip install pytest pytest-mock pytest-asyncio
190+
pytest -v
191+
- name: Upload wheels
192+
uses: actions/upload-artifact@v3
193+
with:
194+
name: wheels
195+
path: toolchain/chidori/dist
196+
197+
# python-linux-cross:
198+
# runs-on: ubuntu-latest
199+
# strategy:
200+
# matrix:
201+
# target: [aarch64]
202+
# steps:
203+
# - uses: actions/checkout@v3
204+
# - uses: actions/setup-python@v4
205+
# with:
206+
# python-version: ${{ env.PYTHON_VERSION }}
207+
# - name: Build wheels
208+
# uses: messense/maturin-action@v1
209+
# with:
210+
# target: ${{ matrix.target }}
211+
# manylinux: auto
212+
# args: --release --out dist --features python
213+
# maturin-version: "v0.13.0"
214+
# working-directory: toolchain/chidori
215+
# sccache: true
216+
# - uses: uraimo/[email protected]
217+
# if: matrix.target != 'ppc64'
218+
# name: Install built wheel
219+
# with:
220+
# arch: ${{ matrix.target }}
221+
# distro: ubuntu20.04
222+
# githubToken: ${{ github.token }}
223+
# install: |
224+
# apt-get update
225+
# apt-get install -y --no-install-recommends python3 python3-pip
226+
# pip3 install -U pip
227+
# run: |
228+
# pip3 install ${{ env.PACKAGE_NAME }} --no-index --find-links dist/ --force-reinstall
229+
# pip install pytest pytest-mock pytest-asyncio
230+
# pytest -v
231+
# - name: Upload wheels
232+
# uses: actions/upload-artifact@v3
233+
# with:
234+
# name: wheels
235+
# path: toolchain/chidori/dist
236+
release:
237+
name: Release
238+
runs-on: ubuntu-latest
239+
needs:
240+
- python-macos
241+
- python-macos-universal
242+
- python-windows
243+
- python-linux
244+
# - python-linux-cross
245+
# if: ${{ github.ref == 'refs/heads/main' }}
246+
steps:
247+
- uses: actions/download-artifact@v3
248+
with:
249+
name: wheels
250+
- uses: actions/setup-python@v2
251+
- name: Publish to PyPi
252+
env:
253+
TWINE_USERNAME: __token__
254+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
255+
run: |
256+
pip install --upgrade twine
257+
twine upload --skip-existing *

0 commit comments

Comments
 (0)