mirror of
https://github.com/roapi/roapi.git
synced 2026-06-05 21:04:02 +08:00
317 lines
11 KiB
YAML
317 lines
11 KiB
YAML
name: build
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
env:
|
|
# NOTE: the version is also defined in roapi_http_release.yml, columnq_cli_release.yml and Dockerfile
|
|
RUST_TC_NIGHTLY_VER: "2023-09-15"
|
|
|
|
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 --features database
|
|
- name: Format
|
|
run: cargo fmt --check
|
|
- 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
|
|
|
|
object_store_memory_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: s3-1-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
|
|
restore-keys: |
|
|
s3-1-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
|
|
s3-1-${{ 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: Setup minio server (S3)
|
|
run: |
|
|
bash ci/scripts/setup_minio.sh
|
|
bash ci/scripts/populate_minio.sh
|
|
- name: Setup fake gcs server (GCS)
|
|
run: |
|
|
bash ci/scripts/setup_gcs.sh
|
|
bash ci/scripts/populate_gcs.sh
|
|
- name: Setup Azure storage server (Azure)
|
|
run: |
|
|
bash ci/scripts/setup_azure.sh
|
|
bash ci/scripts/populate_azure.sh
|
|
- name: Start roapi and Query
|
|
env:
|
|
AWS_DEFAULT_REGION: "us-east-1"
|
|
AWS_ACCESS_KEY_ID: minioadmin
|
|
AWS_SECRET_ACCESS_KEY: minioadmin
|
|
AWS_ENDPOINT_URL: "http://127.0.0.1:9000"
|
|
GOOGLE_SERVICE_ACCOUNT: "/tmp/gcs.json"
|
|
AZURITE_BLOB_STORAGE_URL: "http://127.0.0.1:10000"
|
|
AZURE_STORAGE_USE_EMULATOR: "true"
|
|
AZURE_ALLOW_HTTP: "true"
|
|
# https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=visual-studio#http-connection-strings
|
|
AZURE_STORAGE_ACCOUNT_NAME: "devstoreaccount1"
|
|
AZURE_STORAGE_ACCOUNT_KEY: "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
|
|
uses: BerniWittmann/background-server-action@v1.0.4
|
|
with:
|
|
command: /home/runner/work/roapi/roapi/test_end_to_end/query_blogs.sh
|
|
build: cargo build
|
|
start: cargo run --bin roapi -- -c test_end_to_end/test_object_store_memory.yml
|
|
wait-on: "http://127.0.0.1:8000/api/schema"
|
|
# By default, wait-on will retry for 60 seconds. You can pass a custom timeout in seconds using wait-on-timeout.
|
|
# 10 minutes = 600 seconds
|
|
wait-on-timeout: 600
|
|
|
|
object_store_direct_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: s3-1-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
|
|
restore-keys: |
|
|
s3-1-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
|
|
s3-1-${{ 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: Setup minio server (S3)
|
|
run: |
|
|
bash ci/scripts/setup_minio.sh
|
|
bash ci/scripts/populate_minio.sh
|
|
- name: Setup fake gcs server (GCS)
|
|
run: |
|
|
bash ci/scripts/setup_gcs.sh
|
|
bash ci/scripts/populate_gcs.sh
|
|
- name: Setup Azure storage server (Azure)
|
|
run: |
|
|
bash ci/scripts/setup_azure.sh
|
|
bash ci/scripts/populate_azure.sh
|
|
- name: Start roapi and Query
|
|
env:
|
|
AWS_DEFAULT_REGION: "us-east-1"
|
|
AWS_ACCESS_KEY_ID: minioadmin
|
|
AWS_SECRET_ACCESS_KEY: minioadmin
|
|
AWS_ENDPOINT_URL: http://127.0.0.1:9000
|
|
GOOGLE_SERVICE_ACCOUNT: "/tmp/gcs.json"
|
|
AZURITE_BLOB_STORAGE_URL: "http://127.0.0.1:10000"
|
|
AZURE_STORAGE_USE_EMULATOR: "true"
|
|
AZURE_ALLOW_HTTP: "true"
|
|
# https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=visual-studio#http-connection-strings
|
|
AZURE_STORAGE_ACCOUNT_NAME: "devstoreaccount1"
|
|
AZURE_STORAGE_ACCOUNT_KEY: "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
|
|
uses: BerniWittmann/background-server-action@v1.0.4
|
|
with:
|
|
command: /home/runner/work/roapi/roapi/test_end_to_end/query_blogs.sh
|
|
build: cargo build
|
|
start: cargo run --bin roapi -- -c test_end_to_end/test_object_store_direct.yml
|
|
wait-on: "http://127.0.0.1:8000/api/schema"
|
|
# By default, wait-on will retry for 60 seconds. You can pass a custom timeout in seconds using wait-on-timeout.
|
|
# 10 minutes = 600 seconds
|
|
wait-on-timeout: 600
|
|
|
|
# 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-sqlite,database-mysql --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: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
- name: Build Docker image
|
|
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
|
|
with:
|
|
context: .
|
|
push: false
|
|
load: true
|
|
tags: roapi:latest
|
|
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/roapi:buildcache
|
|
- name: Test
|
|
run: |
|
|
docker run --rm roapi:latest --help
|
|
docker run --rm roapi:latest --version
|