Add Python Package #212
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
name: Rust-CI | |
on: | |
workflow_dispatch: | |
# schedule: | |
# - cron: "17 17 * * *" | |
pull_request: | |
# types: [labeled, review_requested] | |
push: | |
tags: | |
- "v*.*.*" | |
jobs: | |
build-and-test: | |
name: Build, Test and Update Coverage | |
if: github.actor == 'iesahin' | |
runs-on: macos-latest | |
timeout-minutes: 50 | |
strategy: | |
matrix: | |
build: [nightly] | |
include: | |
# - build: stable | |
# benches: true | |
# - build: beta | |
# rust: beta | |
- build: nightly | |
rust: nightly | |
test-args: --all-features --no-fail-fast | |
## for submitters other than me, I'll add another job here. | |
# test-args: --no-fail-fast | |
# test-args: --all-features | |
benches: true | |
coverage: true | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
DIGITAL_OCEAN_ACCESS_KEY_ID: ${{ secrets.DIGITAL_OCEAN_ACCESS_KEY_ID }} | |
DIGITAL_OCEAN_SECRET_ACCESS_KEY: ${{ secrets.DIGITAL_OCEAN_SECRET_ACCESS_KEY }} | |
WASABI_ACCESS_KEY_ID: ${{ secrets.WASABI_ACCESS_KEY_ID }} | |
WASABI_SECRET_ACCESS_KEY: ${{ secrets.WASABI_SECRET_ACCESS_KEY }} | |
GCS_ACCESS_KEY_ID: ${{ secrets.GCS_ACCESS_KEY_ID }} | |
GCS_SECRET_ACCESS_KEY: ${{ secrets.GCS_SECRET_ACCESS_KEY }} | |
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }} | |
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} | |
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
MINIO_ACCESS_KEY_ID: ${{ secrets.MINIO_ACCESS_KEY_ID }} | |
MINIO_SECRET_ACCESS_KEY: ${{ secrets.MINIO_SECRET_ACCESS_KEY }} | |
XVC_TEST_ONE_EMRESULT_COM_KEY: ${{ secrets.XVC_TEST_ONE_EMRESULT_COM_KEY }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
# - name: Install required packages | |
# | |
# run: sudo apt install -y inotify-tools ripgrep s3cmd | |
- name: Install required packages | |
run: | | |
brew install s3cmd | |
brew install ripgrep | |
brew install tree | |
- name: Git config for automated Git tests | |
run: git config --global user.name 'Xvc Rabbit' && git config --global user.email '[email protected]' && git config --global init.defaultBranch main | |
- name: Write the private key file for one.emresult.com connection | |
run: mkdir -p $HOME/.ssh/ && echo "${XVC_TEST_ONE_EMRESULT_COM_KEY}" > $HOME/.ssh/id_rsa ; chmod 600 ~/.ssh/id_rsa | |
- name: Write an ssh config to allow connection | |
run: echo 'Host *' >> $HOME/.ssh/config ; echo ' StrictHostKeyChecking no' >> $HOME/.ssh/config ; chmod 400 $HOME/.ssh/config | |
- name: List .ssh contents | |
run: ls -R $HOME/.ssh ; cat $HOME/.ssh/id_rsa ; cat $HOME/.ssh/config | |
- name: Install rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: ${{ matrix.rust || 'stable' }} | |
profile: minimal | |
components: llvm-tools-preview | |
override: true | |
- name: Build debug | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: ${{ matrix.build-args }} | |
env: | |
RUSTFLAGS: "-A dead_code" | |
- name: Test | |
if: matrix.coverage | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
args: ${{ matrix.test-args }} | |
env: | |
CARGO_INCREMENTAL: "0" | |
# To debug the output when commands fail | |
TRYCMD: "dump" | |
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off" | |
RUSTDOCFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off" | |
- name: Coverage | |
id: coverage | |
if: matrix.coverage | |
uses: actions-rs/[email protected] | |
- name: Test all benches | |
if: matrix.benches | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
args: --benches ${{ matrix.features }} | |
- name: Upload to codecov.io | |
if: matrix.coverage | |
uses: codecov/codecov-action@v2 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: ${{ steps.coverage.outputs.report }} | |
deploy-linux: | |
name: deploy-linux | |
needs: [build-and-test] | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: | |
[ | |
x86_64-unknown-linux-gnu | |
] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
- name: Install rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
target: ${{ matrix.target }} | |
- name: Build target | |
uses: actions-rs/cargo@v1 | |
with: | |
use-cross: false | |
command: build | |
args: --release --target ${{ matrix.target }} | |
- name: Package | |
shell: bash | |
run: | | |
#strip target/${{ matrix.target }}/release/xvc | |
cd target/${{ matrix.target }}/release | |
tar czvf ../../../xvc-${{ github.ref_name}}-${{ matrix.target }}.tar.gz xvc | |
cd - | |
- name: Publish | |
uses: softprops/action-gh-release@v1 | |
# TODO: if any of the build step fails, the release should be deleted. | |
with: | |
files: "xvc*" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
deploy-windows: | |
name: deploy-windows | |
needs: [build-and-test] | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
target: | |
[ | |
x86_64-pc-windows-gnu | |
] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
- name: Install rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
target: ${{ matrix.target }} | |
- name: Build target | |
uses: actions-rs/cargo@v1 | |
with: | |
use-cross: false | |
command: build | |
args: --release --target ${{ matrix.target }} | |
- name: Package | |
shell: bash | |
run: | | |
#strip target/${{ matrix.target }}/release/xvc | |
cd target/${{ matrix.target }}/release | |
tar czvf ../../../xvc-${{ github.ref_name}}-${{ matrix.target }}.tar.gz xvc | |
cd - | |
- name: Publish | |
uses: softprops/action-gh-release@v1 | |
# TODO: if any of the build step fails, the release should be deleted. | |
with: | |
files: "xvc*" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
deploy-macos: | |
name: deploy-macos | |
needs: [build-and-test] | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: macos-latest | |
strategy: | |
matrix: | |
target: | |
[ | |
x86_64-apple-darwin | |
] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
- name: Install rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
target: ${{ matrix.target }} | |
- name: Build target | |
uses: actions-rs/cargo@v1 | |
with: | |
use-cross: false | |
command: build | |
args: --release --target ${{ matrix.target }} | |
- name: Package | |
shell: bash | |
run: | | |
#strip target/${{ matrix.target }}/release/xvc | |
cd target/${{ matrix.target }}/release | |
tar czvf ../../../xvc-${{ github.ref_name}}-${{ matrix.target }}.tar.gz xvc | |
cd - | |
- name: Publish | |
uses: softprops/action-gh-release@v1 | |
# TODO: if any of the build step fails, the release should be deleted. | |
with: | |
files: "xvc*" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
python-linux: | |
runs-on: ubuntu-latest | |
needs: [build-and-test] | |
strategy: | |
matrix: | |
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
args: --release --out dist --manifest-path py/Cargo.toml | |
sccache: 'true' | |
manylinux: auto | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: dist | |
- name: pytest | |
if: ${{ startsWith(matrix.target, 'x86_64') }} | |
shell: bash | |
run: | | |
set -e | |
pip install xvc --find-links dist --force-reinstall | |
pip install pytest | |
cd py && pytest | |
- name: pytest | |
if: ${{ !startsWith(matrix.target, 'x86') && matrix.target != 'ppc64' }} | |
uses: uraimo/[email protected] | |
with: | |
arch: ${{ matrix.target }} | |
distro: ubuntu22.04 | |
githubToken: ${{ github.token }} | |
install: | | |
apt-get update | |
apt-get install -y --no-install-recommends python3 python3-pip | |
pip3 install -U pip pytest | |
run: | | |
set -e | |
pip3 install xvc --find-links dist --force-reinstall | |
cd py && pytest | |
python-windows: | |
runs-on: windows-latest | |
needs: [build-and-test] | |
strategy: | |
matrix: | |
target: [x64, x86] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
architecture: ${{ matrix.target }} | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
args: --release --out dist --manifest-path py/Cargo.toml | |
sccache: 'true' | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: dist | |
- name: pytest | |
if: ${{ !startsWith(matrix.target, 'aarch64') }} | |
shell: bash | |
run: | | |
set -e | |
pip install xvc --find-links dist --force-reinstall | |
pip install pytest | |
cd py && pytest | |
python-macos: | |
runs-on: macos-latest | |
needs: [build-and-test] | |
strategy: | |
matrix: | |
target: [x86_64, aarch64] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Build wheels | |
uses: PyO3/maturin-action@v1 | |
with: | |
target: ${{ matrix.target }} | |
args: --release --out dist --manifest-path py/Cargo.toml | |
sccache: 'true' | |
- name: Upload wheels | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: dist | |
- name: pytest | |
if: ${{ !startsWith(matrix.target, 'aarch64') }} | |
shell: bash | |
run: | | |
set -e | |
pip install xvc --find-links dist --force-reinstall | |
pip install pytest | |
cd py && pytest | |
python-sdist: | |
runs-on: ubuntu-latest | |
needs: [build-and-test] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build sdist | |
uses: PyO3/maturin-action@v1 | |
with: | |
command: sdist | |
args: --out dist --manifest-path py/Cargo.toml | |
- name: Upload sdist | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: dist | |
pypi-release: | |
name: Release | |
runs-on: ubuntu-latest | |
if: "startsWith(github.ref, 'refs/tags/')" | |
needs: [python-linux, python-windows, python-macos, python-sdist] | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: wheels | |
- name: Publish to PyPI | |
uses: PyO3/maturin-action@v1 | |
env: | |
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} | |
with: | |
command: upload | |
args: --non-interactive --skip-existing * |