Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

CI build mobile libs #21

Merged
merged 28 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3b6f1f0
build ios/android libs
Robert-Steiner Mar 9, 2021
d6b214a
fmt [skip ci]
Robert-Steiner Mar 12, 2021
20bf51a
[skip ci]
Robert-Steiner Mar 15, 2021
08e5965
test
Robert-Steiner Mar 17, 2021
e6ff656
fix
Robert-Steiner Mar 17, 2021
c6a94ae
download model
Robert-Steiner Mar 17, 2021
414f394
release
Robert-Steiner Mar 17, 2021
e6a62f5
test cache
Robert-Steiner Mar 17, 2021
fac9504
test podman
Robert-Steiner Mar 17, 2021
715c91f
test whole ci
Robert-Steiner Mar 17, 2021
807dd25
set fail-fast to false
Robert-Steiner Mar 17, 2021
974e8d9
install right toolchain
Robert-Steiner Mar 17, 2021
cea5fa7
fix cache key [skip ci]
Robert-Steiner Mar 17, 2021
173157f
rename cargo lipo job [skip ci]
Robert-Steiner Mar 18, 2021
239afbe
update ci working dir of xayn ai ffi [skip ci]
janpetschexain Mar 19, 2021
84e5567
add rust flags
Robert-Steiner Mar 19, 2021
9a1ee1e
install target
Robert-Steiner Mar 19, 2021
a5ad5a0
use env.RUST_STABLE version [skip ci]
Robert-Steiner Mar 19, 2021
f3f298b
enable deny on warnings [skip ci]
Robert-Steiner Mar 19, 2021
930a5bd
remove ndk related code [skip ci]
Robert-Steiner Mar 19, 2021
31eb2b0
print test execution time [skip ci]
Robert-Steiner Mar 19, 2021
cc911bd
simplify cargo lipo install
Robert-Steiner Mar 26, 2021
262dd27
link pr link to ci file [skip ci]
Robert-Steiner Mar 31, 2021
c4f5ac0
add nl
Robert-Steiner Apr 7, 2021
307cba3
Update .github/workflows/ci.yml [skip ci]
Robert-Steiner Apr 7, 2021
7d11453
remove todos
Robert-Steiner Apr 7, 2021
a98fc00
checksum binary
Robert-Steiner Apr 8, 2021
edd2e49
fmt
Robert-Steiner Apr 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
audit:
name: Rust Audit
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
Expand All @@ -16,8 +16,7 @@ jobs:

- name: Run rust-audit
id: rust-audit
run: |
acrrd marked this conversation as resolved.
Show resolved Hide resolved
cargo audit --deny warnings
run: cargo audit --deny warnings

- name: Notify on Slack
uses: 8398a7/action-slack@v3
Expand Down
183 changes: 154 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,68 @@
# You can find more information about the design decisions here:
# https://github.com/xaynetwork/xayn_ai/pull/21

name: Rust-CI

on:
on:
push:

env:
RUST_STABLE: 1.49.0
RUST_NIGHTLY: nightly-2021-01-31
CARGO_NDK: 2.2.0
ANDROID_PLATFORM_VERSION: 21
CARGO_LIPO: 3.1.1
# cmd: shasum -a 256 cross
CROSS_CHECKSUM: 18a3599273773a7d1e333b413751f0adc1a83ec8045d060fee4f0639bd6baaf0

jobs:
registry-cache:
# we use the latest stable rustc + cargo version that is already installed on the image
# https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-README.md#rust-tools
name: cargo-fetch
runs-on: ubuntu-20.04
timeout-minutes: 5
runs-on: ubuntu-latest
outputs:
cache-key: ${{ steps.cache-key.outputs.key }}
cache-date: ${{ steps.get-date.outputs.date }}
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install stable toolchain
id: rust-toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_STABLE }}
default: true

# We want to create a new cache after a week. Otherwise, the cache will
# take up too much space by caching old dependencies
- name: Year + ISO week number
- name: Generate Year + ISO week number key
id: get-date
run: echo "::set-output name=date::$(/bin/date -u "+%Y-%V")"
shell: bash
run: echo "::set-output name=date::$(/bin/date -u "+%Y-%V")"

- name: Cache key
- name: Generate cargo registry cache key
id: cache-key
run: echo "::set-output name=key::$(echo ${{ runner.os }}-cargo-registry-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/Cargo.lock') }})"
shell: bash
run: echo "::set-output name=key::$(echo ${{ runner.os }}-cargo-registry-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/Cargo.lock') }})"

- name: Cache cargo registry
uses: actions/cache@v2
- name: Restore cargo registry ${{ steps.cache-key.outputs.key }} cache
uses: actions/cache@v2.1.4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ steps.cache-key.outputs.key }}
restore-keys: ${{ runner.os }}-cargo-registry-${{ steps.get-date.outputs.date }}-

- name: cargo fetch
- name: Fetch dependencies
run: cargo fetch

format:
name: cargo-fmt
needs: registry-cache
runs-on: ubuntu-20.04
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install nightly toolchain
- name: Install ${{ env.RUST_NIGHTLY }} toolchain
id: rust-toolchain
uses: actions-rs/toolchain@v1
with:
Expand All @@ -84,13 +86,13 @@ jobs:
check:
name: cargo-check
needs: registry-cache
runs-on: ubuntu-20.04
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install stable toolchain
- name: Install ${{ env.RUST_STABLE }} toolchain
id: rust-toolchain
uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -123,13 +125,13 @@ jobs:
clippy:
name: cargo-clippy
needs: [registry-cache, check]
runs-on: ubuntu-20.04
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install stable toolchain
- name: Install ${{ env.RUST_STABLE }} toolchain
id: rust-toolchain
uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -161,13 +163,13 @@ jobs:
test:
name: cargo-test
needs: [registry-cache, check]
runs-on: ubuntu-20.04
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install stable toolchain
- name: Install ${{ env.RUST_STABLE }} toolchain
id: rust-toolchain
uses: actions-rs/toolchain@v1
with:
Expand All @@ -190,7 +192,6 @@ jobs:
key: ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.rustc }}-tests-${{ needs.registry-cache.outputs.cache-date }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.rustc }}-tests-${{ needs.registry-cache.outputs.cache-date }}-

# TODO: cache this as well to avoid frequent downloading
- name: Download data
run: sh download_data.sh

Expand All @@ -205,18 +206,19 @@ jobs:
coverage:
name: cargo-tarpaulin
needs: [registry-cache, test]
runs-on: ubuntu-20.04
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install stable toolchain
- name: Install ${{ env.RUST_STABLE }} toolchain
id: rust-toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_STABLE }}
profile: minimal
default: true

- name: Use cached cargo registry
uses: actions/cache@v2
Expand All @@ -233,7 +235,6 @@ jobs:
key: ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.rustc }}-tarpaulin-${{ needs.registry-cache.outputs.cache-date }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.rustc }}-tarpaulin-${{ needs.registry-cache.outputs.cache-date }}-

# TODO: cache this as well to avoid frequent downloading
- name: Download data
run: sh download_data.sh

Expand All @@ -242,3 +243,127 @@ jobs:
with:
version: '0.16.0'
args: '-v --all-features --force-clean --lib --ignore-tests --fail-under 70'

install-cargo-lipo:
# we use the latest stable rustc + cargo version that is already installed on the image
# https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md#rust-tools
name: install-cargo-lipo
runs-on: macos-10.15
outputs:
cache-key: ${{ steps.cache-key.outputs.key }}
timeout-minutes: 15
steps:
- name: Generate cargo-lipo cache key
id: cache-key
shell: bash
run: echo "::set-output name=key::$(echo ${{ runner.os }}-cargo-lipo-bin-${{ env.CARGO_LIPO }})"

- name: Restore ${{ steps.cache-key.outputs.key }} cache
uses: actions/[email protected]
id: cargo-lipo-cache
with:
path: ~/.cargo/bin/cargo-lipo
key: ${{ steps.cache-key.outputs.key }}

- name: Install cargo-lipo ${{ env.CARGO_LIPO }}
if: ${{ !steps.cargo-lipo-cache.outputs.cache-hit }}
run: cargo install cargo-lipo --version ${{ env.CARGO_LIPO }}

test-android-libs:
name: test-android-libs
needs: [registry-cache, test]
runs-on: ubuntu-20.04
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
target: [aarch64-linux-android, armv7-linux-androideabi, i686-linux-android, x86_64-linux-android]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install ${{ env.RUST_STABLE }} toolchain
id: rust-toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_STABLE }}
target: ${{ matrix.target }}
default: true

- name: Restore ${{ needs.registry-cache.outputs.cache-key }} cache
uses: actions/[email protected]
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ needs.registry-cache.outputs.cache-key }}

- name: Install Cross
shell: bash
run: |
wget -q -O - https://github.com/rust-embedded/cross/releases/download/v0.2.1/cross-v0.2.1-x86_64-unknown-linux-gnu.tar.gz | tar xvzf -
acrrd marked this conversation as resolved.
Show resolved Hide resolved
echo "${{ env.CROSS_CHECKSUM }} *cross" | shasum -c -
mv cross ~/.cargo/bin/

- name: Download data
run: sh download_data.sh
acrrd marked this conversation as resolved.
Show resolved Hide resolved

- name: Restore build artifacts
uses: actions/[email protected]
with:
path: ${{ github.workspace }}/target
key: ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.rustc }}-test-${{ matrix.target }}-${{ needs.registry-cache.outputs.cache-date }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.rustc }}-test-${{ matrix.target }}-${{ needs.registry-cache.outputs.cache-date }}-

- name: Test Android library ${{ matrix.target }}
env:
RUSTFLAGS: "-C opt-level=3 -C debug-assertions=yes -D warnings"
run: cross test --target ${{ matrix.target }} --all-targets -- -Z unstable-options --report-time

build-ios-libs:
name: build-ios-libs
needs: [registry-cache, install-cargo-lipo, test]
runs-on: macos-10.15
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
target: [aarch64-apple-ios, x86_64-apple-ios]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install ${{ env.RUST_STABLE }} toolchain with target ${{ matrix.target }}
id: rust-toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_STABLE }}
target: ${{ matrix.target }}
default: true

- name: Restore ${{ needs.registry-cache.outputs.cache-key }} cache
uses: actions/[email protected]
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ needs.registry-cache.outputs.cache-key }}

- name: Restore ${{ needs.install-cargo-lipo.outputs.cache-key }} cache
uses: actions/[email protected]
with:
path: ~/.cargo/bin/cargo-lipo
key: ${{ needs.install-cargo-lipo.outputs.cache-key }}

- name: Restore build artifacts
uses: actions/[email protected]
with:
path: ${{ github.workspace }}/target
key: ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.rustc }}-build-${{ matrix.target }}-${{ needs.registry-cache.outputs.cache-date }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-${{ steps.rust-toolchain.outputs.rustc }}-build-${{ matrix.target }}-${{ needs.registry-cache.outputs.cache-date }}-

- name: Build iOS library ${{ matrix.target }}
working-directory: ./xayn-ai-ffi-c
run: cargo lipo --targets ${{ matrix.target }}
2 changes: 2 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build.env]
passthrough = ["RUSTFLAGS"]