This repository has been archived by the owner on Aug 6, 2024. It is now read-only.
Merge pull request #2 from datamole-ai/feature/migration-notice #6
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: SDK Build and Test | |
on: | |
push: | |
branches: [ main ] | |
tags: | |
- python-v* | |
- c-v* | |
pull_request: | |
workflow_dispatch: | |
env: | |
CARGO_INCREMENTAL: 0 | |
CARGO_PROFILE_DEV_DEBUG: 0 | |
RUSTFLAGS: "-D warnings" | |
jobs: | |
# lint-commits: | |
# name: Conventional commits | |
# runs-on: ubuntu-22.04 | |
# steps: | |
# - uses: actions/checkout@v4 | |
# with: | |
# fetch-depth: 0 | |
# - run: npm install -g @commitlint/cli @commitlint/config-conventional | |
# - run: commitlint --config .commitlintrc.json --from ${{ github.head_ref || github.ref }} | |
fetch: | |
name: Fetch Dependencies | |
# From what I tried Windows cannot get cache from ubuntu even though the key is the same. MacOS can though. | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-22.04 | |
- windows-2022 | |
steps: | |
- uses: actions/checkout@v4 | |
# We want to use sparse registry but for that we need nightly | |
- name: Generate Cargo.lock | |
run: cargo generate-lockfile | |
# Generating the lockfile can clone git repositories and tar can then fail for the cache | |
- name: Cleanup Cargo Home | |
run: rm -rf ~/.cargo/registry ~/.cargo/git | |
shell: bash | |
- name: Cache Registry | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
- name: Fetch | |
run: cargo fetch --locked | |
if: steps.cache.outputs.cache-hit != 'true' | |
# We need the other jobs in this workflow to download this version of cargo.lock | |
# We cannot force cache update even if we wanted to so we use artifacts instead | |
- name: Upload Cargo.lock | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }} | |
path: Cargo.lock | |
format-rust: | |
name: Format | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- run: cargo fmt --all -- --check | |
lint-rust: | |
name: Clippy | |
needs: | |
- fetch | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download cargo.lock | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }} | |
- name: Cache Registry | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache Compiled Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}-stable-dev | |
- name: Clippy | |
run: cargo clippy --frozen --all-targets -- -D warnings | |
build: | |
name: Build | |
needs: | |
- fetch | |
runs-on: ${{ startsWith(matrix.os_runtime, 'unknown-linux-gnu') && 'ubuntu-22.04' || matrix.os_runtime == 'pc-windows-msvc' && 'windows-2022' || 'macos-13' }} | |
strategy: | |
fail-fast: false | |
# Run all 4 builds on ubuntu (nightly - stable x dev - release) | |
# Run only stable builds on Windows and MacOS to save up on compilation times | |
# Does not stop the pipeline if only nightly builds fail | |
matrix: | |
cpu: | |
- x86_64 | |
os_runtime: | |
- unknown-linux-gnu | |
toolchain: | |
- stable | |
- nightly | |
configuration: | |
- release | |
- dev | |
artifact_name: | |
- linux-x64 | |
include: | |
- cpu: i686 | |
os_runtime: unknown-linux-gnu | |
toolchain: stable | |
configuration: release | |
artifact_name: linux-x86 | |
- cpu: aarch64 | |
os_runtime: unknown-linux-gnu | |
toolchain: stable | |
configuration: release | |
artifact_name: linux-aarch64 | |
- cpu: armv7 | |
os_runtime: unknown-linux-gnueabihf | |
toolchain: stable | |
configuration: release | |
artifact_name: linux-armv7 | |
- cpu: x86_64 | |
os_runtime: pc-windows-msvc | |
toolchain: stable | |
configuration: release | |
artifact_name: win-x64 | |
- cpu: x86_64 | |
os_runtime: apple-darwin | |
toolchain: stable | |
configuration: release | |
artifact_name: osx-x64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download cargo.lock | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }} | |
- name: Cache Registry | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache Compiled Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.toolchain }}-${{ matrix.configuration }} | |
if: ${{ matrix.cpu == 'x86_64' }} | |
- name: Install libraries for cross compilation to 32bit | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y g++-i686-linux-gnu libc6-dev-i386-cross | |
if: ${{ matrix.cpu == 'i686' }} | |
- name: Set up environment variables for cross compilation to 32bit | |
run: | | |
cat << EOF >> $GITHUB_ENV | |
CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=i686-linux-gnu-gcc | |
CC_i686_unknown_linux_gnu=i686-linux-gnu-gcc | |
CXX_i686_unknown_linux_gnu=i686-linux-gnu-g++ | |
EOF | |
if: ${{ matrix.cpu == 'i686' }} | |
- name: Install libraries for cross compilation to AArch64 | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross | |
if: ${{ matrix.cpu == 'aarch64' }} | |
- name: Set up environment variables for cross compilation to AArch64 | |
run: | | |
cat << EOF >> $GITHUB_ENV | |
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc | |
CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc | |
CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ | |
EOF | |
if: ${{ matrix.cpu == 'aarch64' }} | |
- name: Install libraries for cross compilation to ARMv7 | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y g++-arm-linux-gnueabihf libc6-dev-armhf-cross | |
if: ${{ matrix.cpu == 'armv7' }} | |
- name: Set up environment variables for cross compilation to ARMv7 | |
run: | | |
cat << EOF >> $GITHUB_ENV | |
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc | |
CC_armv7_unknown_Linux_gnueabihf=arm-linux-gnueabihf-gcc | |
CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ | |
EOF | |
if: ${{ matrix.cpu == 'armv7' }} | |
- name: Install Target | |
run: rustup target add ${{ matrix.cpu }}-${{ matrix.os_runtime }} | |
if: ${{ matrix.cpu != 'x86_64' }} | |
# We can use only the CPU that matches the runner | |
- name: Select Toolchain | |
run: rustup default ${{ matrix.toolchain }}-${{ matrix.cpu }}-${{ matrix.os_runtime }} | |
if: ${{ matrix.cpu == 'x86_64' }} | |
- name: Build | |
# Skip spotflow-py if we're building on macOS or other CPU than x64. It does not work because of linkage issues, maturin builds correctly | |
run: cargo build --all-targets --target ${{ matrix.cpu }}-${{ matrix.os_runtime }} ${{ matrix.cpu == 'x86_64' && '--offline' || '' }} --verbose --profile ${{ matrix.configuration }} --workspace ${{ (runner.os == 'macOS' || matrix.cpu != 'x86_64') && '--exclude spotflow-py' || '' }} | |
env: | |
CARGO_PROFILE_DEV_DEBUG: 0 | |
continue-on-error: ${{ matrix.toolchain == 'nightly' }} | |
- name: Pack C interface | |
shell: pwsh | |
run: spotflow-c/pack.ps1 -Os ${{ runner.os }} -TargetDir ../target/${{ matrix.cpu }}-${{ matrix.os_runtime }}/release | |
if: ${{ matrix.toolchain == 'stable' && matrix.configuration == 'release' }} | |
- name: Upload C interface | |
uses: actions/upload-artifact@v4 | |
with: | |
name: c-${{ matrix.artifact_name }} | |
path: target/${{ matrix.cpu }}-${{ matrix.os_runtime }}/release/c | |
if: ${{ matrix.toolchain == 'stable' && matrix.configuration == 'release' }} | |
# Prevents from caching and causing weird errors when modifying the pipeline, such as "target/release/c already exists" | |
- name: Clean up C interface | |
shell: pwsh | |
run: Remove-Item -Recurse -Force target/${{ matrix.cpu }}-${{ matrix.os_runtime }}/release/c | |
if: ${{ matrix.toolchain == 'stable' && matrix.configuration == 'release' }} | |
test: | |
name: Test | |
needs: | |
- build | |
permissions: | |
contents: read | |
id-token: write | |
environment: platform-test | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
toolchain: | |
- stable | |
configuration: | |
- release | |
timeout-minutes: 20 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download cargo.lock | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }} | |
- name: Cache Registry | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache Compiled Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ matrix.toolchain }}-${{ matrix.configuration }} | |
- name: ⛓ Select Toolchain | |
run: rustup default ${{ matrix.toolchain }} | |
- name: Test no run | |
run: cargo test --offline --verbose --profile ${{ matrix.configuration }} --no-run | |
- name: Azure Login | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.DATAMOLE_AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.DATAMOLE_AZURE_TENANT_ID }} | |
allow-no-subscriptions: true | |
- name: Test | |
run: cargo test --offline --verbose --profile ${{ matrix.configuration }} | |
continue-on-error: ${{ matrix.toolchain == 'nightly' }} | |
if: ${{ matrix.toolchain == 'stable' && matrix.configuration == 'release' }} | |
env: | |
SPOTFLOW_DEVICE_SDK_TEST_INSTANCE: ${{ secrets.TEST_INSTANCE }} | |
SPOTFLOW_DEVICE_SDK_TEST_PROVISIONING_TOKEN: ${{ secrets.TEST_PROVISIONING_TOKEN }} | |
SPOTFLOW_DEVICE_SDK_TEST_WORKSPACE_ID: ${{ secrets.TEST_WORKSPACE_ID }} | |
- name: Allow failures for nightly | |
run: true | |
# Skip until we have actual documentation to be checked | |
# check-docs: | |
# name: Documentation | |
# runs-on: ubuntu-22.04 | |
# env: | |
# RUSTDOCFLAGS: -D warnings | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - run: cargo doc --no-deps --document-private-items | |
test-c: | |
name: Test C Library | |
needs: | |
- build | |
strategy: | |
fail-fast: false | |
matrix: | |
cpu: | |
- x86_64 | |
os: | |
- ubuntu-22.04 | |
- windows-2022 | |
# - macos-13 # Skip until it is fixed | |
include: | |
- cpu: i686 | |
os: ubuntu-22.04 | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 10 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download C interface | |
uses: actions/download-artifact@v4 | |
with: | |
name: c-${{ matrix.os == 'ubuntu-22.04' && 'linux' || matrix.os == 'windows-2022' && 'win' || 'osx' }}-x64 | |
path: target/release/c | |
- name: Compile GCC dynamic library project with Make | |
run: make | |
working-directory: target/release/c/examples/gcc_makefile_dynamic | |
if: ${{ runner.os == 'Linux'}} | |
- name: Compile GCC static library project with Make | |
run: make | |
working-directory: target/release/c/examples/gcc_makefile_static | |
if: ${{ runner.os == 'Linux'}} | |
- name: Compile Visual Studio dynamic library project with MSBuild | |
shell: cmd | |
run: ${{ '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" && msbuild' }} | |
working-directory: target/release/c/examples/vs2022_dynamic | |
if: ${{ runner.os == 'Windows' }} | |
- name: Compile Visual Studio static library project with MSBuild | |
shell: cmd | |
run: ${{ '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" && msbuild' }} | |
working-directory: target/release/c/examples/vs2022_static | |
if: ${{ runner.os == 'Windows' }} | |
- name: Compile Clang dynamic library project with Make | |
run: make run | |
working-directory: target/release/c/examples/clang_makefile_dynamic | |
if: ${{ runner.os == 'macOS' }} | |
- name: Compile Clang static library project with Make | |
run: make run | |
working-directory: target/release/c/examples/clang_makefile_static | |
if: ${{ runner.os == 'macOS' }} | |
build-c: | |
name: Build and test C Library using CMake | |
if: ${{ false }} # Skip until the CMake build is fixed | |
needs: | |
- build | |
permissions: | |
contents: read | |
id-token: write | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-22.04 | |
- windows-2022 | |
- macos-13 | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 10 | |
environment: platform-test | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download cargo.lock | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }} | |
- name: Cache Registry | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
# Cache cannot be reused from the build steps since CMake will just build it in its own directory. | |
# Rather it probably can be but it will require some effort around moving the target directory around. | |
# This will most likely not work in its simplest form because of dep-info files | |
- name: Prepare C Example | |
run: cmake -S . -B build | |
working-directory: examples/c | |
# if: ${{ matrix.os == 'ubuntu-22.04' && matrix.toolchain == 'stable' && matrix.configuration == 'release' }} | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
architecture: x64 | |
- run: pip install azure.identity | |
- name: Azure Login | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.DATAMOLE_AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.DATAMOLE_AZURE_TENANT_ID }} | |
allow-no-subscriptions: true | |
- name: Run C Example | |
run: cmake --build build | |
working-directory: examples/c | |
env: | |
SPOTFLOW_TEST_DEVICE_ID: test-device-c-${{ matrix.os }} | |
build-python-linux: | |
runs-on: ubuntu-22.04 | |
needs: | |
- build | |
defaults: | |
run: | |
working-directory: spotflow-py | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download cargo.lock | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }} | |
- name: Cache Registry | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache Compiled Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-stable-release | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
architecture: x64 | |
# Install maturin with patchelf because the utility in ubuntu repo is outdated and has a bug | |
- name: Set up Maturin | |
run: pip install maturin[patchelf] | |
- run: maturin build --offline --release --sdist -o dist | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-linux-x64 | |
path: spotflow-py/dist | |
build-python-windows: | |
runs-on: windows-latest | |
needs: | |
- build | |
defaults: | |
run: | |
working-directory: spotflow-py | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download cargo.lock | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }} | |
- name: Cache Registry | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache Compiled Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-stable-release | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
architecture: x64 | |
- name: Set up Maturin | |
run: pip install maturin | |
- run: maturin build --offline --release -o dist | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-win-x64 | |
path: spotflow-py/dist | |
build-python-macos: | |
runs-on: macos-13 | |
needs: | |
- build | |
defaults: | |
run: | |
working-directory: spotflow-py | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download cargo.lock | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }} | |
- name: Cache Registry | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
- name: Cache Compiled Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-stable-release | |
- run: rustup target list --installed | |
- run: rustup target add aarch64-apple-darwin | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
architecture: x64 | |
- name: Set up Maturin | |
run: pip install maturin | |
- run: maturin build --offline --release -o dist --target universal2-apple-darwin | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-macos-x64 | |
path: spotflow-py/dist | |
build-python-aarch64: | |
runs-on: ubuntu-22.04 | |
needs: | |
- build | |
defaults: | |
run: | |
working-directory: spotflow-py | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download cargo.lock | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }} | |
- name: Cache Registry | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
# There are no other steps that would use aarch64 compiled binaries so we will not cache them | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
# Install maturin with patchelf because the utility in ubuntu repo is outdated and has a bug | |
- name: Set up Maturin | |
run: pip install maturin[patchelf] | |
- run: | | |
sudo apt-get update | |
sudo apt-get install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross | |
- run: rustup target add aarch64-unknown-linux-gnu | |
- run: | | |
cat << EOF >> $GITHUB_ENV | |
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc | |
CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc | |
CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ | |
EOF | |
- run: maturin build -o dist --target aarch64-unknown-linux-gnu | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-linux-aarch64 | |
path: spotflow-py/dist | |
build-python-armv7: | |
runs-on: ubuntu-22.04 | |
needs: | |
- build | |
defaults: | |
run: | |
working-directory: spotflow-py | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download cargo.lock | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ runner.os == 'Windows' && 'cargo-lock-win' || 'cargo-lock-linuxormac' }} | |
- name: Cache Registry | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
key: ${{ runner.os == 'Windows' && 'windows' || 'linuxormac' }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
# There are no other steps that would use armv7 compiled binaries so we will not cache them | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
# Install maturin with patchelf because the utility in ubuntu repo is outdated and has a bug | |
- name: Set up Maturin | |
run: pip install maturin[patchelf] | |
- run: | | |
sudo apt-get update | |
sudo apt-get install -y g++-arm-linux-gnueabihf libc6-dev-armhf-cross | |
- run: rustup target add armv7-unknown-linux-gnueabihf | |
- run: | | |
cat << EOF >> $GITHUB_ENV | |
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc | |
CC_armv7_unknown_Linux_gnueabihf=arm-linux-gnueabihf-gcc | |
CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ | |
EOF | |
- run: maturin build -o dist --target armv7-unknown-linux-gnueabihf | |
- name: Upload wheels | |
uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-linux-armv7 | |
path: spotflow-py/dist | |
release-python-packages: | |
name: Release Python Packages | |
runs-on: ubuntu-22.04 | |
environment: pypi | |
if: startsWith(github.event.ref, 'refs/tags/python-v') | |
needs: | |
- build | |
- test | |
- build-python-macos | |
- build-python-windows | |
- build-python-armv7 | |
- build-python-aarch64 | |
- test-python-linux | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
architecture: x64 | |
- name: Set up Maturin | |
run: pip install maturin | |
- uses: actions/download-artifact@v4 | |
with: | |
pattern: wheels-* | |
- run: maturin upload --username "__token__" --password ${{ secrets.PYPI_TOKEN }} *.whl | |
release-c-packages: | |
name: Release C Packages | |
runs-on: ubuntu-22.04 | |
environment: cdn | |
if: startsWith(github.event.ref, 'refs/tags/c-v') | |
needs: | |
- build | |
- test | |
- test-c | |
permissions: | |
actions: read | |
contents: read | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
path: c/artifacts | |
pattern: c-* | |
- uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.CDN_SUBSCRIPTION_ID }} | |
- name: Publish C interface | |
shell: pwsh | |
run: > | |
spotflow-c/publish.ps1 | |
-ArtifactsDir c/artifacts | |
-StagingDir c/staging | |
-GitHubRef '${{ github.event.ref }}' | |
-AccountName '${{ secrets.CDN_STORAGE_ACCOUNT_NAME }}' | |
-ContainerName '${{ secrets.CDN_STORAGE_CONTAINER_NAME }}' | |
- name: Wait before purging CDN | |
run: sleep 60 | |
- name: Purge CDN | |
run: > | |
az cdn endpoint purge | |
-g '${{ secrets.CDN_RESOURCE_GROUP_NAME }}' | |
--profile-name '${{ secrets.CDN_PROFILE_NAME }}' | |
-n '${{ secrets.CDN_ENDPOINT_NAME }}' | |
--content-paths '/*' | |
test-python-linux: | |
if: ${{ false }} # Skip until Python tests are fixed | |
runs-on: ubuntu-22.04 | |
needs: build-python-linux | |
environment: platform-test | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: wheels-linux-x64 | |
path: wheels | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
architecture: x64 | |
- name: Azure Login | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.DATAMOLE_AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.DATAMOLE_AZURE_TENANT_ID }} | |
allow-no-subscriptions: true | |
- name: Set up Maturin | |
run: pip install wheels/spotflow_device-*-manylinux_2_*.whl | |
- run: pip install azure.identity | |
- run: python examples/python/messages.py | |
env: | |
SPOTFLOW_DEVICE_SDK_TEST_INSTANCE: ${{ secrets.TEST_INSTANCE }} | |
SPOTFLOW_DEVICE_SDK_TEST_PROVISIONING_TOKEN: ${{ secrets.TEST_PROVISIONING_TOKEN }} | |
SPOTFLOW_DEVICE_SDK_TEST_WORKSPACE_ID: ${{ secrets.TEST_WORKSPACE_ID }} |