name: ci
on:
push:
branches: [ main, stable ]
tags:
- 'v*'
paths-ignore:
- docs/**
- README.md
- CHANGELOG.md
pull_request:
branches: [ main, stable ]
paths-ignore:
- docs/**
- README.md
- CHANGELOG.md
permissions: read-all
env:
REGISTRY_IMAGE: reduct/store
MINIMAL_RUST_VERSION: ${{ vars.MINIMAL_RUST_VERSION }}
jobs:
rust_fmt:
runs-on: ubuntu-latest
name: Rust Linter
steps:
- uses: actions/checkout@v5
- name: Check code
run: cargo fmt --all -- --check
sdk_tests:
name: Client SDK Tests
runs-on: ubuntu-latest
strategy:
matrix:
reductstore_version: [ "main", "latest" ]
include:
- reductstore_version: main
features: "default,test-api-120"
- reductstore_version: latest
features: "default"
needs:
- rust_fmt
steps:
- uses: actions/checkout@v5
- name: Generate license
run: echo '${{secrets.LICENSE_KEY}}' > lic.key
- name: Run Database
run: docker run --network=host -v ${PWD}/misc:/misc
--env RS_API_TOKEN=TOKEN
--env RS_EXT_PATH=/tmp
--env RS_LICENSE_PATH=/misc/lic.key -d reduct/store:${{ matrix.reductstore_version }}
- name: Use cache for Cargo
uses: runs-on/cache@bd330c5a5f6cbb837823ee25864f3c71a211c2e3 with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-rust${{ env.MINIMAL_RUST_VERSION }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
env:
RUNS_ON_S3_BUCKET_CACHE: reduct-cache
RUNS_ON_S3_BUCKET_ENDPOINT: https://fsn1.your-objectstorage.com
AWS_ACCESS_KEY_ID: ${{ secrets.S3_CACHE_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_CACHE_SECRET_KEY }}
AWS_REGION: fsn1
AWS_DEFAULT_REGION: fsn1
- name: Run Client SDK tests
run: RS_API_TOKEN=TOKEN cargo test --features ${{ matrix.features }} -- --test-threads=1
sdk_examples:
name: Client SDK Examples
runs-on: ubuntu-latest
needs:
- rust_fmt
strategy:
matrix:
example: [ "hallo_world", "query" ]
steps:
- uses: actions/checkout@v5
- name: Run Database
run: docker run --network=host -v ${PWD}/misc:/misc -d ${{env.REGISTRY_IMAGE}}
- name: Run Client SDK tests
run: cargo run --example ${{matrix.example}}
dry_publish:
runs-on: ubuntu-latest
name: Dry run publish
if: startsWith(github.ref, 'refs/tags/')
needs:
- rust_fmt
steps:
- uses: actions/checkout@v5
- name: Set up Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 with:
toolchain: ${{ env.MINIMAL_RUST_VERSION }}
- name: Dry run publish reduct-rs
run: cargo publish --dry-run -p reduct-rs
check_tag:
runs-on: ubuntu-latest
name: Check tag
steps:
- uses: actions/checkout@v5
- name: Check tag
if: startsWith(github.ref, 'refs/tags/')
run: |
cargo install cargo-get
if [ "v$(cargo get package.version)" != "${GITHUB_REF#refs/*/}" ]; then
echo "Tag does not match version in $PKG_NAME/Cargo.toml"
exit 1
fi
publish_crate:
runs-on: ubuntu-latest
name: Publish crate
needs:
- sdk_tests
- sdk_examples
- check_tag - dry_publish
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v5
- name: Set up Rust
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 with:
toolchain: ${{ env.MINIMAL_RUST_VERSION }}
- uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b with:
version: '3.x'
repo-token: ${{ secrets.ACTION_GITHUB_TOKEN }}
- name: Login
run: |
cargo login ${{ secrets.CRATES_IO_TOKEN }}
- name: Publish reduct-rs
run: cargo publish -p reduct-rs