Rust IPFS #1
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
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- trying | |
- staging | |
pull_request: | |
branches: '*' | |
schedule: | |
# added while removing the Cargo.lock to help combat dependency drift caused by too lenient Cargo.toml ranges | |
- cron: '0 3 * * 1' # every monday at 03:00 | |
name: Rust IPFS | |
jobs: | |
ci-matrix: | |
strategy: | |
fail-fast: false | |
matrix: | |
toolchain: | |
- rust: stable | |
platform: | |
- target: x86_64-unknown-linux-gnu | |
name: ubuntu | |
host: ubuntu-latest | |
cross: false | |
- target: x86_64-apple-darwin | |
name: macos | |
host: macos-latest | |
cross: false | |
- target: x86_64-pc-windows-msvc | |
name: windows | |
host: windows-2019 | |
cross: false | |
# Mobile platforms disabled until we get a good estimate of them being | |
# needed. Previous discussion to enable them was before github CI usage | |
# was metered. | |
# | |
# - target: armv7-linux-androideabi | |
# name: android (armv7) | |
# host: ubuntu-latest | |
# cross: true | |
# | |
# - target: aarch64-linux-android | |
# name: android (aarch64) | |
# host: ubuntu-latest | |
# cross: true | |
# | |
# - target: x86_64-apple-ios | |
# name: ios (x86_64) | |
# host: macos-latest | |
# cross: true | |
# | |
# - target: aarch64-apple-ios | |
# name: ios (aarch64) | |
# host: macos-latest | |
# cross: true | |
env: | |
RUST_BACKTRACE: 1 | |
CARGO_INCREMENTAL: 0 | |
LLVM_CONFIG_PATH: /usr/local/opt/llvm/bin/llvm-config | |
NDK_HOME: /usr/local/lib/android/sdk/ndk-bundle | |
GO_IPFS_PATH: /home/runner/work/rust-ipfs/rust-ipfs/go-ipfs/ipfs | |
VCPKGRS_DYNAMIC: 1 | |
DEBUG: ipfsd-ctl:* # enables all debug output from javascript 'debug' lib used by js-ipfsd-ctl | |
runs-on: ${{ matrix.platform.host }} | |
name: ${{ matrix.platform.name }} | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v2 | |
- name: Install dependencies (linux) | |
if: matrix.platform.host == 'ubuntu-latest' | |
run: sudo apt-get install llvm-dev libssl-dev pkg-config | |
- name: Install dependencies (macos) | |
if: matrix.platform.host == 'macos-latest' | |
run: brew install llvm openssl | |
- name: Install and cache vcpkg (windows) | |
uses: lukka/[email protected] | |
id: windows-runvcpkg | |
if: matrix.platform.host == 'windows-2019' | |
with: | |
vcpkgDirectory: '${{ runner.workspace }}/vcpkg' | |
vcpkgTriplet: 'x64-windows' | |
vcpkgGitCommitId: '261c458af6e3eed5d099144aff95d2b5035f656b' # unknown for openssl-sys v0.9.65 | |
setupOnly: true # required for caching | |
- name: Install depedencies (windows) | |
if: matrix.platform.host == 'windows-2019' | |
run: "$VCPKG_ROOT/vcpkg install openssl:x64-windows" | |
shell: bash | |
env: | |
VCPKGRS_DYNAMIC: 1 | |
- name: Install rust toolchain | |
uses: hecrj/[email protected] | |
with: | |
rust-version: ${{ matrix.toolchain.rust }} | |
targets: ${{ matrix.platform.target }} | |
- name: Rust cache | |
uses: Swatinem/rust-cache@v1 | |
with: | |
# So that cross-compiles don't share a cache. | |
key: ${{ matrix.platform.target }} | |
- name: Cargo build | |
if: matrix.platform.cross == false | |
run: cargo build --workspace --all-targets | |
- name: Cargo build (cross compile, android) | |
if: contains(matrix.platform.target, 'android') | |
run: | | |
cargo install --version '<2.0.0' cargo-ndk | |
cargo ndk --android-platform 29 --target ${{ matrix.platform.target }} build --workspace --exclude ipfs-http | |
# exclude http on android because openssl | |
- name: Cargo build (cross compile, non-android) | |
if: contains(matrix.platform.target, 'android') == false && matrix.platform.cross == true | |
run: cargo build --workspace --exclude ipfs-http --target ${{ matrix.platform.target }} | |
# exclude http on other cross compilation targets because openssl | |
- name: Cargo test | |
if: matrix.platform.cross == false | |
run: cargo test --workspace | |
- name: Interop DHT tests with go-ipfs (linux) | |
if: matrix.platform.host == 'ubuntu-latest' && matrix.platform.cross == false | |
run: | | |
curl -L https://github.com/ipfs/go-ipfs/releases/download/v0.7.0/go-ipfs_v0.7.0_linux-amd64.tar.gz --output go_ipfs.tar.gz | |
tar -xf go_ipfs.tar.gz | |
cargo test --features=test_go_interop dht | |
- name: "Conformance tests: cache config" | |
id: conformance-cache-config | |
if: matrix.platform.cross == false | |
run: | | |
echo "::set-output name=dir::$(npm config get cache)" | |
echo "::set-output name=ver::$(npm -v)" | |
- name: "Conformance tests: setup nodejs 14" | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14' | |
- name: "Conformance tests: cache" | |
id: conformance-cache | |
if: matrix.platform.cross == false | |
uses: actions/cache@v2 | |
with: | |
path: | | |
${{ steps.conformance-cache-config.outputs.dir }} | |
./conformance/node_modules | |
key: ${{ runner.os }}-conformance-${{ steps.conformance-cache-config.outputs.ver }} ${{ hashFiles('**/package-lock.json', '**/setup.sh', '**/*.patch') }} | |
- name: "Conformance tests: setup" | |
if: steps.conformance-cache.outputs.cache-hit != 'true' && matrix.platform.cross == false | |
run: ./setup.sh | |
shell: bash | |
working-directory: ./conformance | |
- name: "Conformance tests: run" | |
if: matrix.platform.cross == false | |
run: IPFS_RUST_EXEC=../target/debug/ipfs-http npm test | |
shell: bash | |
working-directory: ./conformance | |
# Work around for this issue: https://github.com/Swatinem/rust-cache/issues/26 | |
- name: Fix cache permissions (macos) | |
if: matrix.platform.cross == false && matrix.platform.host == 'macos-latest' | |
run: sudo chown -R $(whoami):$(id -ng) ./target | |
lint-rust: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v2 | |
- name: Install rust toolchain | |
uses: hecrj/[email protected] | |
with: | |
rust-version: stable | |
components: clippy, rustfmt | |
- name: Rust cache | |
uses: Swatinem/rust-cache@v1 | |
- name: Cargo fmt | |
run: cargo fmt --all -- --check | |
- name: Cargo clippy | |
run: cargo clippy --all-targets --workspace -- -D warnings | |
# adapted from https://github.com/taiki-e/pin-project/blob/5878410863f5f25e21f7cba97b035501749850f9/.github/workflows/ci.yml#L136-L167 | |
# further enchanced following solutions to | |
# https://github.com/bors-ng/bors-ng/issues/1115 -- bors now considers the | |
# skipped task a failure, or overrides the status for a task with a same name | |
# with the one which came later. | |
ci-success: | |
# this is read by bors | |
name: ci | |
if: github.event_name == 'push' && success() | |
needs: | |
- ci-matrix | |
- lint-rust | |
runs-on: ubuntu-latest | |
steps: | |
- name: Mark the job as a success | |
run: exit 0 |