forked from ngrok/ngrok-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d0231d6
Showing
114 changed files
with
10,757 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
docker: | ||
required: false | ||
type: string | ||
host: | ||
required: true | ||
type: string | ||
if: | ||
description: 'Whether to run this job' | ||
required: false | ||
default: true | ||
type: boolean | ||
publish: | ||
required: false | ||
type: string | ||
setup: | ||
required: false | ||
type: string | ||
target: | ||
required: true | ||
type: string | ||
jobs: | ||
reusable-build: | ||
if: ${{ inputs.if }} | ||
name: stable - ${{ inputs.target }} - node@18 | ||
runs-on: ${{ inputs.host }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Cache cargo | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
.cargo-cache | ||
target/ | ||
key: ${{ inputs.target }}-cargo-${{ inputs.host }} | ||
- uses: goto-bus-stop/setup-zig@v2 | ||
if: ${{ inputs.target == 'armv7-unknown-linux-gnueabihf' }} | ||
with: | ||
version: 0.10.0 | ||
- name: Setup toolchain | ||
run: ${{ inputs.setup }} | ||
if: ${{ inputs.setup }} | ||
shell: bash | ||
- name: Build in docker | ||
uses: addnab/docker-run-action@v3 | ||
if: ${{ inputs.docker }} | ||
with: | ||
image: ${{ inputs.docker }} | ||
options: '-e SHOULD_PUBLISH=${{ inputs.publish }} --user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build' | ||
run: | | ||
pwd | ||
ls -lah | ||
whoami | ||
env | ||
apk update | ||
apk add --no-cache python3 py3-pip | ||
python3 -m venv .env | ||
. .env/bin/activate && pip install -r requirements.txt | ||
. .env/bin/activate && pip install patchelf | ||
if [ "${SHOULD_PUBLISH}" == 'true' ]; then | ||
echo "~~~~ maturin publishing" | ||
. .env/bin/activate && maturin publish --no-sdist -u __token__ -p ${{ secrets.MATURIN_PASSWORD }} | ||
else | ||
echo "~~~~ maturin building" | ||
. .env/bin/activate && maturin build | ||
fi | ||
- name: Build aarch64-linux-android | ||
if: ${{ inputs.target == 'aarch64-linux-android' }} | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
target: ${{ inputs.target }} | ||
args: --release -i python3.9 -m Cargo.toml | ||
docker-options: | | ||
--mount type=bind,source=/usr/local/lib/android/sdk/ndk/25.2.9519653,target=/usr/local/lib/android/sdk/ndk/25.2.9519653 | ||
-e CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang | ||
-e CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-androideabi24-clang | ||
-e CC=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang | ||
-e CXX=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang++ | ||
-e AR=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar | ||
-e ANDROID_NDK=/usr/local/lib/android/sdk/ndk/25.2.9519653 | ||
- name: Build armv7-linux-androideabi | ||
if: ${{ inputs.target == 'armv7-linux-androideabi' }} | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
target: ${{ inputs.target }} | ||
args: --release -i python3.9 -m Cargo.toml | ||
docker-options: | | ||
--mount type=bind,source=/usr/local/lib/android/sdk/ndk/25.2.9519653,target=/usr/local/lib/android/sdk/ndk/25.2.9519653 | ||
-e CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang | ||
-e CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang | ||
-e CC=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang | ||
-e CXX=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang++ | ||
-e AR=/usr/local/lib/android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar | ||
-e ANDROID_NDK=/usr/local/lib/android/sdk/ndk/25.2.9519653 | ||
- name: Setup x86 Python | ||
if: ${{ inputs.target == 'i686-pc-windows-msvc' }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.9" | ||
architecture: "x86" | ||
- name: Build | ||
if: ${{ inputs.publish != 'true' && !inputs.docker && !contains(inputs.target,'android') }} | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
target: ${{ inputs.target }} | ||
args: --release -i python3.9 -m Cargo.toml | ||
- name: Publish | ||
if: ${{ inputs.publish == 'true' && !inputs.docker && !contains(inputs.target,'android') }} | ||
uses: PyO3/maturin-action@v1 | ||
with: | ||
command: publish | ||
target: ${{ inputs.target }} | ||
args: --no-sdist -i python3.9 -m Cargo.toml -u __token__ -p ${{ secrets.MATURIN_PASSWORD }} | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: bindings-${{ inputs.target }} | ||
path: target/wheels/*.whl | ||
if-no-files-found: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
name: CI | ||
env: | ||
DEBUG: napi:* | ||
APP_NAME: ngrok | ||
MACOSX_DEPLOYMENT_TARGET: '10.13' | ||
'on': | ||
push: | ||
branches: | ||
- main | ||
tags-ignore: | ||
- '**' | ||
paths-ignore: | ||
- '**/*.md' | ||
- LICENSE | ||
- '**/*.gitignore' | ||
- .editorconfig | ||
- docs/** | ||
pull_request: null | ||
jobs: | ||
udeps: | ||
name: Udeps | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: jrobsonchase/[email protected] | ||
- uses: ./.github/workflows/rust-cache | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: udeps | ||
args: '--workspace --all-targets --all-features' | ||
fmt: | ||
name: Rustfmt | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: jrobsonchase/[email protected] | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: '--all -- --check' | ||
clippy: | ||
name: Clippy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: jrobsonchase/[email protected] | ||
- uses: ./.github/workflows/rust-cache | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: clippy | ||
args: '--all-targets --all-features --workspace -- -D warnings' | ||
test: | ||
name: Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: jrobsonchase/[email protected] | ||
- uses: ./.github/workflows/rust-cache | ||
- name: Run Tests | ||
run: | | ||
NGROK_AUTHTOKEN=${{ secrets.NGROK_AUTHTOKEN }} make testfast | ||
decide: | ||
name: Decide on Publishing | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Decide | ||
id: decide | ||
run: | | ||
echo "github.ref: ${{ github.ref }}" | ||
echo "git log:" | ||
git log -1 --pretty=%B | ||
if [ '${{ github.ref }}' == 'refs/heads/main' ] && git log -1 --pretty=%B | grep "^[0-9]\+\.[0-9]\+\.[0-9]\+$"; then | ||
echo "SHOULD_PUBLISH=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "SHOULD_PUBLISH=false" >> $GITHUB_OUTPUT | ||
fi | ||
cat $GITHUB_OUTPUT | ||
outputs: | ||
publish: ${{ steps.decide.outputs.SHOULD_PUBLISH }} | ||
|
||
build: | ||
needs: | ||
- clippy | ||
- decide | ||
- fmt | ||
- test | ||
- udeps | ||
uses: ./.github/workflows/build.yml | ||
secrets: inherit | ||
with: | ||
docker: ${{ matrix.settings.docker }} | ||
host: ${{ matrix.settings.host }} | ||
if: ${{ matrix.settings.if }} | ||
publish: ${{ needs.decide.outputs.publish || 'false' }} | ||
setup: ${{ matrix.settings.setup }} | ||
target: ${{ matrix.settings.target }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
settings: | ||
- host: macos-latest | ||
target: x86_64-apple-darwin | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
- host: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
if: true | ||
- host: windows-latest | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
target: i686-pc-windows-msvc | ||
- host: ubuntu-latest | ||
if: true | ||
target: x86_64-unknown-linux-gnu | ||
- host: ubuntu-latest | ||
compiler: gcc | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
target: x86_64-unknown-linux-musl | ||
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine | ||
- host: macos-latest | ||
if: true | ||
target: aarch64-apple-darwin | ||
- host: macos-latest | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
target: universal2-apple-darwin | ||
- host: ubuntu-latest | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
target: aarch64-unknown-linux-gnu | ||
- host: ubuntu-latest | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
target: armv7-unknown-linux-gnueabihf | ||
setup: | | ||
sudo apt-get update | ||
sudo apt-get install gcc-arm-linux-gnueabihf -y | ||
- host: ubuntu-latest | ||
# need to build python against the android ndk | ||
if: false | ||
target: aarch64-linux-android | ||
- host: ubuntu-latest | ||
# need to build python against the android ndk | ||
if: false | ||
target: armv7-linux-androideabi | ||
- host: ubuntu-latest | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
target: aarch64-unknown-linux-musl | ||
- host: windows-latest | ||
target: aarch64-pc-windows-msvc | ||
# target not supported by the 'ring' rust dependency (ssl library partially built by gcc) | ||
# https://github.com/briansmith/ring/issues/1167 | ||
if: false | ||
build-freebsd: | ||
if: github.ref == 'refs/heads/main' | ||
needs: decide | ||
runs-on: macos-12 | ||
name: Build FreeBSD | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Build | ||
id: build | ||
uses: vmactions/freebsd-vm@v0 | ||
env: | ||
DEBUG: napi:* | ||
RUSTUP_HOME: /usr/local/rustup | ||
CARGO_HOME: /usr/local/cargo | ||
RUSTUP_IO_THREADS: 1 | ||
SHOULD_PUBLISH: ${{ needs.decide.outputs.publish }} | ||
with: | ||
envs: DEBUG RUSTUP_HOME CARGO_HOME RUSTUP_IO_THREADS SHOULD_PUBLISH | ||
usesh: true | ||
mem: 3000 | ||
prepare: | | ||
pkg install -y -f curl libnghttp2 python3 yarn | ||
alias curl="curl --retry 5 --retry-all-errors" | ||
curl https://sh.rustup.rs -sSf --output rustup.sh | ||
sh rustup.sh -y --profile minimal --default-toolchain beta | ||
export PATH="/usr/local/cargo/bin:$PATH" | ||
echo "~~~~ rustc --version ~~~~" | ||
rustc --version | ||
echo "~~~~ node -v ~~~~" | ||
node -v | ||
echo "~~~~ yarn --version ~~~~" | ||
yarn --version | ||
run: | | ||
export PATH="/usr/local/cargo/bin:$PATH" | ||
pwd | ||
ls -lah | ||
whoami | ||
env | ||
freebsd-version | ||
python3 -m venv .env | ||
. .env/bin/activate && pip install -r requirements.txt | ||
if [ "${SHOULD_PUBLISH}" == 'true' ]; then | ||
echo "~~~~ maturin just building since pypi doesn't support BSD wheels" | ||
# https://discuss.python.org/t/pypi-org-unsupported-platform-tag-openbsd-7-0-amd64/16302 | ||
# . .env/bin/activate && maturin publish --no-sdist -u __token__ -p ${{ secrets.MATURIN_PASSWORD }} | ||
. .env/bin/activate && maturin build | ||
else | ||
echo "~~~~ maturin building" | ||
. .env/bin/activate && maturin build | ||
fi | ||
# make the rsync back faster | ||
rm -rf .env/ target/debug/ target/release/ | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: bindings-freebsd | ||
path: target/wheels/*.whl | ||
if-no-files-found: error | ||
tag: | ||
if: ${{ github.ref == 'refs/heads/main' && needs.decide.outputs.publish == 'true' }} | ||
needs: | ||
- decide | ||
- build | ||
runs-on: ubuntu-latest | ||
name: Tag Release | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: jrobsonchase/[email protected] | ||
- name: Tag | ||
run: | | ||
version="$(extract-crate-version ngrok)" | ||
git config user.name "GitHub Action" | ||
git config user.email [email protected] | ||
git tag -a -m "Version ${version}" v${version} | ||
git push --tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: 'rust cache setup' | ||
description: 'Set up cargo and sccache caches' | ||
inputs: {} | ||
outputs: {} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: configure sccache | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); | ||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); | ||
core.exportVariable('SCCACHE_GHA_CACHE_TO', 'sccache-${{runner.os}}-${{github.ref_name}}'); | ||
core.exportVariable('SCCACHE_GHA_CACHE_FROM', 'sccache-${{runner.os}}-main,sccache-${{runner.os}}-'); | ||
- name: cargo registry cache | ||
uses: actions/cache@v3 | ||
with: | ||
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-${{ github.sha }} | ||
restore-keys: | | ||
cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}- | ||
cargo-${{ runner.os }}- | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git |
Oops, something went wrong.