roapi/.github/workflows/build.yml
2022-08-13 11:18:24 -07:00

188 lines
5.5 KiB
YAML

name: build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
# NOTE: this env is also defined in roapi_http_release.yml and columnq_cli_release.yml
RUST_TC_NIGHTLY_VER: "2022-01-05"
jobs:
build:
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C target-cpu=skylake"
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
${{ runner.os }}-cargo-
- name: Install minimal stable with clippy and rustfmt
uses: actions-rs/toolchain@v1
with:
profile: default
toolchain: stable
override: true
- name: Check
run: cargo clippy
- name: Build
run: cargo build
- name: Run tests
run: cargo test
- name: Trim cache
run: |
which cargo-cache || cargo install cargo-cache
cargo cache trim -l 1G
simd_test:
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C target-cpu=skylake"
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: simd-3-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
restore-keys: |
simd-3-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
simd-3-${{ runner.os }}-cargo-
- name: Install nightly rust
uses: actions-rs/toolchain@v1
with:
profile: default
# toolchain: nightly
toolchain: nightly-${{ env.RUST_TC_NIGHTLY_VER }}
override: true
- name: Run tests
run: cargo test --features simd
- name: Trim cache
run: |
which cargo-cache || cargo install cargo-cache
cargo cache trim -l 1G
database_test:
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-C target-cpu=skylake"
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: database-1-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
restore-keys: |
database-1-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
database-1-${{ runner.os }}-cargo-
- name: Install nightly rust
uses: actions-rs/toolchain@v1
with:
profile: default
toolchain: nightly-${{ env.RUST_TC_NIGHTLY_VER }}
override: true
- name: Check
run: cargo clippy --features database
- name: Build
run: cargo build --features database
- name: Run tests
run: cargo test --features database
- name: Trim cache
run: |
which cargo-cache || cargo install cargo-cache
cargo cache trim -l 1G
# make sure native-tls always builds
openssl_build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install minimal stable with clippy and rustfmt
uses: actions-rs/toolchain@v1
with:
profile: default
toolchain: stable
override: true
- name: Check
run: cargo clippy --no-default-features --features=native-tls
- name: Trim cache
run: |
which cargo-cache || cargo install cargo-cache
cargo cache trim -l 1G
# cross compile from x86 mac to arm64, this is to make sure universal2
# release will build without error
mac_cross_build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: mac-1-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
restore-keys: |
mac-1-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
mac-1-${{ runner.os }}-cargo-
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-${{ env.RUST_TC_NIGHTLY_VER }}
target: aarch64-apple-darwin
profile: minimal
default: true
- name: Build binary - universal2
env:
DEVELOPER_DIR: /Applications/Xcode.app/Contents/Developer
MACOSX_DEPLOYMENT_TARGET: '10.9'
run: |
# set SDKROOT for C dependencies
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
cd roapi && \
cargo build --bin roapi --features database --target aarch64-apple-darwin
- name: Trim cache
run: |
which cargo-cache || cargo install cargo-cache
cargo cache trim -l 1G
docker_build:
name: Docker Image Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: false
load: true
tags: roapi:latest
- name: Test
run: |
docker run --rm roapi:latest --help