diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6f1e61..003e10d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,198 +2,152 @@ name: CI on: push: - tags: - - 'v*' - branches: - - 'master' - pull_request: -jobs: - check: - name: Check - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] - rust: [stable] - steps: - - name: Setup Rust Action - uses: hecrj/setup-rust-action@v1 - with: - rust-version: ${{ matrix.rust }} +env: + CARGO_TERM_COLOR: always - - name: Checkout sources - uses: actions/checkout@v2 - - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - - name: Run cargo check - uses: actions-rs/cargo@v1 - with: - command: check +defaults: + run: + # necessary for windows + shell: bash +jobs: test: - name: Test Suite - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] - rust: [stable] + runs-on: ubuntu-latest steps: - - name: Setup Rust Action - uses: hecrj/setup-rust-action@v1 - with: - rust-version: ${{ matrix.rust }} - - - name: Checkout sources - uses: actions/checkout@v2 - - - name: Install stable toolchain + - uses: actions/checkout@v2 + - name: Setup Rust toolcnain uses: actions-rs/toolchain@v1 with: - profile: minimal toolchain: stable - override: true - - - name: Run cargo test - uses: actions-rs/cargo@v1 + components: clippy + - name: Cargo cache + uses: actions/cache@v2 with: - command: test - - lints: - name: Lints - runs-on: ${{ matrix.os }} + path: | + ~/.cargo/registry + ./target + key: test-cargo-registry + - name: List + run: find ./ + - name: Run lint + run: cargo clippy + - name: Run tests + run: cargo test --verbose + + build: strategy: + fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] - rust: [stable] + # a list of all the targets + include: + - TARGET: x86_64-unknown-linux-gnu # tested in a debian container on a mac + OS: ubuntu-latest + - TARGET: x86_64-unknown-linux-musl # test in an alpine container on a mac + OS: ubuntu-latest + - TARGET: aarch64-unknown-linux-gnu # tested on aws t4g.nano + OS: ubuntu-latest + - TARGET: aarch64-unknown-linux-musl # tested on aws t4g.nano in alpine container + OS: ubuntu-latest + - TARGET: armv7-unknown-linux-gnueabihf # raspberry pi 2-3-4, not tested + OS: ubuntu-latest + - TARGET: armv7-unknown-linux-musleabihf # raspberry pi 2-3-4, not tested + OS: ubuntu-latest + - TARGET: arm-unknown-linux-gnueabihf # raspberry pi 0-1, not tested + OS: ubuntu-latest + - TARGET: arm-unknown-linux-musleabihf # raspberry pi 0-1, not tested + OS: ubuntu-latest + - TARGET: x86_64-apple-darwin # tested on a mac, is not properly signed so there are security warnings + OS: macos-latest + - TARGET: aarch64-apple-darwin + OS: macos-latest + - TARGET: x86_64-pc-windows-gnu # tested on a windows machine + OS: windows-latest + needs: test + runs-on: ${{ matrix.OS }} + env: + NAME: dify + TARGET: ${{ matrix.TARGET }} + OS: ${{ matrix.OS }} steps: - - name: Setup Rust Action - uses: hecrj/setup-rust-action@v1 - with: - rust-version: ${{ matrix.rust }} - - - name: Checkout sources - uses: actions/checkout@v2 - - - name: Install stable toolchain + - uses: actions/checkout@v2 + - name: Setup Rust toolcnain uses: actions-rs/toolchain@v1 with: - profile: minimal toolchain: stable - override: true - components: rustfmt, clippy - - - name: Run cargo fmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - - name: Run cargo clippy - uses: actions-rs/cargo@v1 - with: - command: clippy - args: -- -D warnings - - distribution: - name: Distribution - needs: [check, test, lints] - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-16.04, macOS-latest, windows-latest] - include: - - os: ubuntu-16.04 - name: dify-Linux-x86_64.tar.gz - - os: macOS-latest - name: dify-Darwin-x86_64.tar.gz - - os: windows-latest - name: dify-Windows-x86_64.zip - steps: - - name: Setup | Checkout code - uses: actions/checkout@v2 - - - name: Setup | Cache Cargo + - name: Cargo cache uses: actions/cache@v2 with: path: | ~/.cargo/registry - ~/.cargo/git - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - - name: Setup | Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - - name: Build | Build - if: startsWith(github.ref, 'refs/tags/') - uses: actions-rs/cargo@v1 - with: - command: build - args: --release - - - name: Package - if: startsWith(github.ref, 'refs/tags/') - shell: bash + ./target + key: build-cargo-registry-${{matrix.TARGET}} + - name: List + run: find ./ + - name: Install and configure dependencies + run: | + # dependencies are only needed on ubuntu as that's the only place where + # we make cross-compilation + if [[ $OS =~ ^ubuntu.*$ ]]; then + sudo apt-get install -qq crossbuild-essential-arm64 crossbuild-essential-armhf + fi + # some additional configuration for cross-compilation on linux + cat >>~/.cargo/config <