Skip to content

Merge pull request #85 from alchemaxinc/fix/auto/update-docker-images… #270

Merge pull request #85 from alchemaxinc/fix/auto/update-docker-images…

Merge pull request #85 from alchemaxinc/fix/auto/update-docker-images… #270

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PRETTIER_VERSION: "3.3.3"
COMMITLINT_CLI_VERSION: "20.2.0"
jobs:
install-commitlint:
runs-on: ubuntu-latest
steps:
- &checkout-code
name: Checkout code (shallow)
uses: actions/checkout@v6
- &cache-commitlint
name: Cache Commitlint
id: cache-commitlint
uses: actions/cache@v5
with:
path: node_modules
key: v4-commitlint-${{ env.COMMITLINT_CLI_VERSION }}
- name: Install Commitlint
if: steps.cache-commitlint.outputs.cache-hit != 'true'
run: npm i -D @commitlint/cli@${{ env.COMMITLINT_CLI_VERSION }} @commitlint/config-conventional
run-commitlint:
runs-on: ubuntu-latest
needs: install-commitlint
steps:
- name: Checkout code (full)
uses: actions/checkout@v6
with:
fetch-depth: 0
- *cache-commitlint
- name: Run commitlint
run: |
git checkout main
git checkout -
./node_modules/.bin/commitlint --from main --to HEAD --verbose
install-prettier:
runs-on: ubuntu-latest
steps:
- *checkout-code
- &cache-prettier
name: Cache Prettier
id: cache-prettier
uses: actions/cache@v5
with:
path: node_modules
key: v1-prettier-${{ env.PRETTIER_VERSION }}
- name: Install Prettier
if: steps.cache-prettier.outputs.cache-hit != 'true'
run: npm i -D prettier@${{ env.PRETTIER_VERSION }}
lint-rust:
name: lint-rust (${{ matrix.name }})
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: wrapper
manifest: wrapper/Cargo.toml
target: wrapper/target
lockfile: wrapper/Cargo.lock
steps:
- *checkout-code
- &read-rust-version
name: Read Rust toolchain version
id: rust-version
run: echo "version=$(grep '^channel' rust-toolchain.toml | sed 's/.*"\(.*\)".*/\1/')" >> "$GITHUB_OUTPUT"
- &install-rust
name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.rust-version.outputs.version }}
components: clippy, rustfmt
- name: Cache Cargo dependencies
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
${{ matrix.target }}
key: v1-cargo-${{ matrix.name }}-${{ hashFiles('rust-toolchain.toml') }}-${{ hashFiles(matrix.lockfile) }}
restore-keys: v1-cargo-${{ matrix.name }}-${{ hashFiles('rust-toolchain.toml') }}-
- name: Run clippy
run: cargo clippy --manifest-path ${{ matrix.manifest }} --all-targets -- -D warnings
- name: Check formatting
run: cargo fmt --manifest-path ${{ matrix.manifest }} -- --check
lint-prettier:
runs-on: ubuntu-latest
needs: install-prettier
steps:
- *checkout-code
- *cache-prettier
- name: Run Prettier
run: npx prettier --check .
test-unit:
runs-on: ubuntu-latest
needs: lint-rust
steps:
- *checkout-code
- *read-rust-version
- *install-rust
- &cache-cargo
name: Cache Cargo dependencies
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
wrapper/target
key: v1-cargo-${{ hashFiles('rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
v1-cargo-${{ hashFiles('rust-toolchain.toml') }}-
v1-cargo-wrapper-${{ hashFiles('rust-toolchain.toml') }}-
- name: Run unit tests
run: make test-unit
test-integration:
runs-on: ubuntu-latest
needs: [lint-rust, lint-prettier, run-commitlint, test-unit]
if: "!startsWith(github.event.pull_request.title, 'chore')"
steps:
- *checkout-code
- *read-rust-version
- *install-rust
- *cache-cargo
# BuildKit enables advanced cache backends (required for GHA cache below)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
# Build Docker image with GHA cache to avoid recompiling Rust dependencies.
# cache-from pulls cached layers, cache-to pushes them back (mode=max caches
# intermediate layers too, so the dependency layer from our split Dockerfile
# is preserved across runs).
- name: Build Docker image
uses: docker/build-push-action@v7
with:
context: .
load: true
tags: meilisearch-lambda-wrapper-api:test
build-args: |
RUST_VERSION=${{ steps.rust-version.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Start meili-wrapper
run: docker compose -f wrapper/tests/docker-compose.yml up -d --wait
- name: Run integration tests
env:
MEILI_MASTER_KEY: test-master-key-12345
run: |
cargo test \
--manifest-path wrapper/Cargo.toml \
--features integration \
--test integration_test -- --test-threads=1
- name: Cleanup
if: always()
run: docker compose -f wrapper/tests/docker-compose.yml down
ci-passed:
name: CI Passed
runs-on: ubuntu-latest
if: always()
needs: [lint-rust, run-commitlint, test-unit, test-integration]
steps:
- name: Verify all jobs passed or were skipped
run: |
results=(
"${{ needs.lint-rust.result }}"
"${{ needs.run-commitlint.result }}"
"${{ needs.test-unit.result }}"
"${{ needs.test-integration.result }}"
)
for result in "${results[@]}"; do
if [[ "$result" == "failure" || "$result" == "cancelled" ]]; then
echo "Job failed or was cancelled: $result"
exit 1
fi
done
echo "All jobs passed or were skipped"