Merge branch 'main' into fix-3037-new

This commit is contained in:
jiangbo212 2022-12-12 21:36:10 +08:00
commit 169682d3ec
98 changed files with 133 additions and 104 deletions

48
.github/scripts/is-latest-release.sh vendored Normal file
View File

@ -0,0 +1,48 @@
#!/bin/sh
# Used in our CIs to publish the latest Docker image.
# Checks if the current tag ($GITHUB_REF) corresponds to the latest release tag on GitHub
# Returns "true" or "false" (as a string).
GITHUB_API='https://api.github.com/repos/meilisearch/meilisearch/releases'
PNAME='meilisearch'
# FUNCTIONS
# Returns the version of the latest stable version of Meilisearch by setting the $latest variable.
get_latest() {
# temp_file is needed because the grep would start before the download is over
temp_file=$(mktemp -q /tmp/$PNAME.XXXXXXXXX)
latest_release="$GITHUB_API/latest"
if [ $? -ne 0 ]; then
echo "$0: Can't create temp file."
exit 1
fi
if [ -z "$GITHUB_PAT" ]; then
curl -s "$latest_release" > "$temp_file" || return 1
else
curl -H "Authorization: token $GITHUB_PAT" -s "$latest_release" > "$temp_file" || return 1
fi
latest="$(cat "$temp_file" | grep '"tag_name":' | cut -d ':' -f2 | tr -d '"' | tr -d ',' | tr -d ' ')"
rm -f "$temp_file"
return 0
}
# MAIN
current_tag="$(echo $GITHUB_REF | tr -d 'refs/tags/')"
get_latest
if [ "$current_tag" != "$latest" ]; then
# The current release tag is not the latest
echo "false"
else
# The current release tag is the latest
echo "true"
fi
exit 0

View File

@ -1,33 +0,0 @@
---
on:
workflow_dispatch:
name: Execute code coverage
jobs:
nightly-coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
with:
command: clean
- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --no-fail-fast
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=unwind -Zpanic_abort_tests"
- uses: actions-rs/grcov@v0.1
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ${{ steps.coverage.outputs.report }}
yml: ./codecov.yml
fail_ci_if_error: true

View File

@ -3,7 +3,7 @@ name: Update latest git tag
on:
workflow_dispatch:
release:
types: [released]
types: [published]
jobs:
check-version:

View File

@ -31,8 +31,6 @@ jobs:
runs-on: ubuntu-latest
outputs:
is-patch: ${{ steps.check-patch.outputs.is-patch }}
env:
MILESTONE_VERSION: ${{ github.event.milestone.title }}
steps:
- uses: actions/checkout@v3
- name: Check if this release is a patch release only

View File

@ -2,7 +2,7 @@ name: Publish to APT repository & Homebrew
on:
release:
types: [released]
types: [published]
jobs:
check-version:
@ -25,7 +25,7 @@ jobs:
run: cargo install cargo-deb
- uses: actions/checkout@v3
- name: Build deb package
run: cargo deb -p meilisearch-http -o target/debian/meilisearch.deb
run: cargo deb -p meilisearch -o target/debian/meilisearch.deb
- name: Upload debian pkg to release
uses: svenstaro/upload-release-action@2.3.0
with:

View File

@ -1,7 +1,5 @@
---
on:
schedule:
- cron: '0 4 * * *' # Every day at 4:00am
push:
# Will run for every tag pushed except `latest`
# When the `latest` git tag is created with this [CI](../latest-git-tag.yml)
@ -9,6 +7,10 @@ on:
# The `latest` Docker image push is already done in this CI when releasing a stable version of Meilisearch.
tags-ignore:
- latest
# Both `schedule` and `workflow_dispatch` build the nightly tag
schedule:
- cron: '0 23 * * *' # Every day at 11:00pm
workflow_dispatch:
name: Publish tagged images to Docker Hub
@ -18,27 +20,43 @@ jobs:
steps:
- uses: actions/checkout@v3
# Check if the tag has the v<nmumber>.<number>.<number> format. If yes, it means we are publishing an official release.
# If we are running a cron or manual job ('schedule' or 'workflow_dispatch' event), it means we are publishing the `nightly` tag, so not considered stable.
# If we have pushed a tag, and the tag has the v<nmumber>.<number>.<number> format, it means we are publishing an official release, so considered stable.
# In this situation, we need to set `output.stable` to create/update the following tags (additionally to the `vX.Y.Z` Docker tag):
# - a `vX.Y` (without patch version) Docker tag
# - a `latest` Docker tag
- name: Check tag format
if: github.event_name != 'schedule'
# For any other tag pushed, this is not considered stable.
- name: Define if stable and latest release
id: check-tag-format
env:
# To avoid request limit with the .github/scripts/is-latest-release.sh script
GITHUB_PATH: ${{ secrets.MEILI_BOT_GH_PAT }}
run: |
escaped_tag=$(printf "%q" ${{ github.ref_name }})
echo "latest=false" >> $GITHUB_OUTPUT
if [[ $escaped_tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
if [[ ${{ github.event_name }} != 'push' ]]; then
echo "stable=false" >> $GITHUB_OUTPUT
elif [[ $escaped_tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "stable=true" >> $GITHUB_OUTPUT
echo "latest=$(sh .github/scripts/is-latest-release.sh)" >> $GITHUB_OUTPUT
else
echo "stable=false" >> $GITHUB_OUTPUT
fi
# Check only the validity of the tag for official releases (not for pre-releases or other tags)
# Check only the validity of the tag for stable releases (not for pre-releases or other tags)
- name: Check release validity
if: github.event_name != 'schedule' && steps.check-tag-format.outputs.stable == 'true'
if: steps.check-tag-format.outputs.stable == 'true'
run: bash .github/scripts/check-release.sh
- name: Set build-args for Docker buildx
id: build-metadata
run: |
# Extract commit date
commit_date=$(git show -s --format=%cd --date=iso-strict ${{ github.sha }})
echo "date=$commit_date" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
@ -46,7 +64,6 @@ jobs:
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
if: github.event_name != 'schedule'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
@ -57,25 +74,28 @@ jobs:
uses: docker/metadata-action@v4
with:
images: getmeili/meilisearch
# The latest and `vX.Y` tags are only pushed for the official Meilisearch releases
# See https://github.com/docker/metadata-action#latest-tag
# Prevent `latest` to be updated for each new tag pushed.
# We need latest and `vX.Y` tags to only be pushed for the stable Meilisearch releases.
flavor: latest=false
tags: |
type=ref,event=tag
type=raw,value=nightly,enable=${{ github.event_name != 'push' }}
type=semver,pattern=v{{major}}.{{minor}},enable=${{ steps.check-tag-format.outputs.stable == 'true' }}
type=raw,value=latest,enable=${{ steps.check-tag-format.outputs.stable == 'true' }}
type=raw,value=latest,enable=${{ steps.check-tag-format.outputs.stable == 'true' && steps.check-tag-format.outputs.latest == 'true' }}
- name: Build and push
uses: docker/build-push-action@v3
with:
# We do not push tags for the cron jobs, this is only for test purposes
push: ${{ github.event_name != 'schedule' }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
build-args: |
COMMIT_SHA=${{ github.sha }}
COMMIT_DATE=${{ steps.build-metadata.outputs.date }}
# /!\ Don't touch this without checking with Cloud team
- name: Send CI information to Cloud team
if: github.event_name != 'schedule'
# Do not send if nightly build (i.e. 'schedule' or 'workflow_dispatch' event)
if: github.event_name == 'push'
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.MEILI_BOT_GH_PAT }}

View File

@ -83,7 +83,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
toolchain: nightly
override: true
components: rustfmt
- name: Cache dependencies

50
Cargo.lock generated
View File

@ -1101,7 +1101,7 @@ dependencies = [
[[package]]
name = "dump"
version = "0.30.1"
version = "1.0.0"
dependencies = [
"anyhow",
"big_s",
@ -1310,7 +1310,7 @@ dependencies = [
[[package]]
name = "file-store"
version = "0.30.1"
version = "1.0.0"
dependencies = [
"faux",
"tempfile",
@ -1767,7 +1767,7 @@ dependencies = [
[[package]]
name = "index-scheduler"
version = "0.30.1"
version = "1.0.0"
dependencies = [
"anyhow",
"big_s",
@ -2156,7 +2156,7 @@ checksum = "d4d2456c373231a208ad294c33dc5bff30051eafd954cd4caae83a712b12854d"
[[package]]
name = "lmdb-rkv-sys"
version = "0.15.1"
source = "git+https://github.com/meilisearch/lmdb-rs#5592bf5a812905cf0c633404ef8f8f4057112c65"
source = "git+https://github.com/meilisearch/lmdb-rs#0144fb2bac524cdc2897d7750681ed3fff2dc3ac"
dependencies = [
"cc",
"libc",
@ -2258,7 +2258,7 @@ checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
[[package]]
name = "meili-snap"
version = "0.30.1"
version = "1.0.0"
dependencies = [
"insta",
"md5",
@ -2266,24 +2266,7 @@ dependencies = [
]
[[package]]
name = "meilisearch-auth"
version = "0.30.1"
dependencies = [
"enum-iterator",
"hmac",
"meilisearch-types",
"rand",
"roaring",
"serde",
"serde_json",
"sha2",
"thiserror",
"time",
"uuid 1.2.1",
]
[[package]]
name = "meilisearch-http"
name = "meilisearch"
version = "0.30.1"
dependencies = [
"actix-cors",
@ -2365,9 +2348,26 @@ dependencies = [
"zip",
]
[[package]]
name = "meilisearch-auth"
version = "1.0.0"
dependencies = [
"enum-iterator",
"hmac",
"meilisearch-types",
"rand",
"roaring",
"serde",
"serde_json",
"sha2",
"thiserror",
"time",
"uuid 1.2.1",
]
[[package]]
name = "meilisearch-types"
version = "0.30.1"
version = "1.0.0"
dependencies = [
"actix-web",
"anyhow",
@ -2759,7 +2759,7 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]]
name = "permissive-json-pointer"
version = "0.30.1"
version = "1.0.0"
dependencies = [
"big_s",
"serde_json",

View File

@ -1,7 +1,7 @@
[workspace]
resolver = "2"
members = [
"meilisearch-http",
"meilisearch",
"meilisearch-types",
"meilisearch-auth",
"meili-snap",

View File

@ -7,7 +7,7 @@ WORKDIR /meilisearch
ARG COMMIT_SHA
ARG COMMIT_DATE
ENV COMMIT_SHA=${COMMIT_SHA} COMMIT_DATE=${COMMIT_DATE}
ENV VERGEN_GIT_SHA=${COMMIT_SHA} VERGEN_GIT_COMMIT_TIMESTAMP=${COMMIT_DATE}
ENV RUSTFLAGS="-C target-feature=-crt-static"
COPY . .

View File

@ -61,7 +61,7 @@ You may also want to check out [Meilisearch 101](https://docs.meilisearch.com/le
## ☁️ Meilisearch cloud
Join the closed beta for Meilisearch cloud by filling out [this form](https://meilisearch.typeform.com/to/VI2cI2rv).
Let us manage your infrastructure so you can focus on integrating a great search experience. Try [Meilisearch Cloud](https://meilisearch.com/pricing) today.
## 🧰 SDKs & integration tools

View File

@ -1,6 +1,6 @@
[package]
name = "dump"
version = "0.30.1"
version = "1.0.0"
edition = "2021"
[dependencies]

View File

@ -1,6 +1,6 @@
[package]
name = "file-store"
version = "0.30.1"
version = "1.0.0"
edition = "2021"
[dependencies]

View File

@ -1,6 +1,6 @@
[package]
name = "index-scheduler"
version = "0.30.1"
version = "1.0.0"
edition = "2021"
[dependencies]

View File

@ -1,6 +1,6 @@
[package]
name = "meili-snap"
version = "0.30.1"
version = "1.0.0"
edition = "2021"
[dependencies]

View File

@ -1,6 +1,6 @@
[package]
name = "meilisearch-auth"
version = "0.30.1"
version = "1.0.0"
edition = "2021"
[dependencies]

View File

@ -1,6 +1,6 @@
[package]
name = "meilisearch-types"
version = "0.30.1"
version = "1.0.0"
authors = ["marin <postma.marin@protonmail.com>"]
edition = "2021"

View File

@ -3,12 +3,8 @@ authors = ["Quentin de Quelen <quentin@dequelen.me>", "Clément Renault <clement
description = "Meilisearch HTTP server"
edition = "2021"
license = "MIT"
name = "meilisearch-http"
version = "0.30.1"
[[bin]]
name = "meilisearch"
path = "src/main.rs"
version = "0.30.1"
[dependencies]
actix-cors = "0.6.3"

View File

@ -6,9 +6,9 @@ use actix_web::http::KeepAlive;
use actix_web::web::Data;
use actix_web::HttpServer;
use index_scheduler::IndexScheduler;
use meilisearch::analytics::Analytics;
use meilisearch::{analytics, create_app, setup_meilisearch, Opt};
use meilisearch_auth::AuthController;
use meilisearch_http::analytics::Analytics;
use meilisearch_http::{analytics, create_app, setup_meilisearch, Opt};
#[global_allocator]
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;

View File

@ -734,7 +734,7 @@ mod test {
#[ignore]
fn test_meilli_config_file_path_valid() {
temp_env::with_vars(
vec![("MEILI_CONFIG_FILE_PATH", Some("../config.toml"))], // Relative path in meilisearch_http package
vec![("MEILI_CONFIG_FILE_PATH", Some("../config.toml"))], // Relative path in meilisearch package
|| {
assert!(Opt::try_build().is_ok());
},

View File

@ -10,9 +10,9 @@ pub use server::{default_settings, Server};
#[macro_export]
macro_rules! test_post_get_search {
($server:expr, $query:expr, |$response:ident, $status_code:ident | $block:expr) => {
let post_query: meilisearch_http::routes::search::SearchQueryPost =
let post_query: meilisearch::routes::search::SearchQueryPost =
serde_json::from_str(&$query.clone().to_string()).unwrap();
let get_query: meilisearch_http::routes::search::SearchQuery = post_query.into();
let get_query: meilisearch::routes::search::SearchQuery = post_query.into();
let get_query = ::serde_url_params::to_string(&get_query).unwrap();
let ($response, $status_code) = $server.search_get(&get_query).await;
let _ = ::std::panic::catch_unwind(|| $block)

View File

@ -8,8 +8,8 @@ use actix_web::dev::ServiceResponse;
use actix_web::http::StatusCode;
use byte_unit::{Byte, ByteUnit};
use clap::Parser;
use meilisearch_http::option::{IndexerOpts, MaxMemory, Opt};
use meilisearch_http::{analytics, create_app, setup_meilisearch};
use meilisearch::option::{IndexerOpts, MaxMemory, Opt};
use meilisearch::{analytics, create_app, setup_meilisearch};
use once_cell::sync::Lazy;
use serde_json::{json, Value};
use tempfile::TempDir;

View File

@ -5,8 +5,8 @@ use actix_web::http::StatusCode;
use actix_web::test;
use actix_web::test::TestRequest;
use index_scheduler::IndexScheduler;
use meilisearch::{analytics, create_app, Opt};
use meilisearch_auth::AuthController;
use meilisearch_http::{analytics, create_app, Opt};
use serde_json::Value;
use crate::common::encoder::Encoder;

View File

@ -1,6 +1,6 @@
mod data;
use meilisearch_http::Opt;
use meilisearch::Opt;
use serde_json::json;
use self::data::GetDump;

View File

@ -1,6 +1,6 @@
use std::time::Duration;
use meilisearch_http::Opt;
use meilisearch::Opt;
use tokio::time::sleep;
use crate::common::server::default_settings;

View File

@ -1,6 +1,6 @@
[package]
name = "permissive-json-pointer"
version = "0.30.1"
version = "1.0.0"
edition = "2021"
description = "A permissive json pointer"
readme = "README.md"