mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 18:17:39 +08:00
Merge #3467
3467: Identify builds git tagged with `prototype-...` in CLI and analytics r=curquiza a=dureuill # Pull Request ## What does this PR do? - Parses the last git tag to extract a prototype name if: - Current build uses the prototype tag (not after the tag) precisely - The prototype tag name respects the following conditions: 1. starts with `prototype-` 2. ends with a number 3. the hyphen-separated segment right before the number is not a number (required to reject commits after the tag). - Display the prototype name in the launch summary in the CLI - Send the prototype name to analytics if any - Update prototypes instructions in CONTRIBUTING.md |`VERGEN_GIT_SEMVER_LIGHTWEIGHT` value | Prototype | |---|---| | `Some("prototype-geo-bounding-box-0-139-gcde89018")` | `None` (does not end with a number) | | `Some("prototype-geo-bounding-box-0-139-89018")` | `None` (before the last segment is a number) | | `Some("prototype-geo-bounding-box-0")` | `Some("prototype-geo-bounding-box-0")` | | `Some("prototype-geo-bounding-box")` | `None` (does not end with a number") | | `Some("geo-bounding-box-0")` | `None` (does not start with "prototype") | | `None` | `None` | Co-authored-by: Louis Dureuil <louis@meilisearch.com>
This commit is contained in:
commit
c91bfeaf15
3
.github/uffizzi/Dockerfile
vendored
3
.github/uffizzi/Dockerfile
vendored
@ -7,7 +7,8 @@ WORKDIR /meilisearch
|
|||||||
|
|
||||||
ARG COMMIT_SHA
|
ARG COMMIT_SHA
|
||||||
ARG COMMIT_DATE
|
ARG COMMIT_DATE
|
||||||
ENV COMMIT_SHA=${COMMIT_SHA} COMMIT_DATE=${COMMIT_DATE}
|
ARG GIT_TAG
|
||||||
|
ENV COMMIT_SHA=${COMMIT_SHA} COMMIT_DATE=${COMMIT_DATE} VERGEN_GIT_SEMVER_LIGHTWEIGHT=${GIT_TAG}
|
||||||
ENV RUSTFLAGS="-C target-feature=-crt-static"
|
ENV RUSTFLAGS="-C target-feature=-crt-static"
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
1
.github/workflows/publish-docker-images.yml
vendored
1
.github/workflows/publish-docker-images.yml
vendored
@ -92,6 +92,7 @@ jobs:
|
|||||||
build-args: |
|
build-args: |
|
||||||
COMMIT_SHA=${{ github.sha }}
|
COMMIT_SHA=${{ github.sha }}
|
||||||
COMMIT_DATE=${{ steps.build-metadata.outputs.date }}
|
COMMIT_DATE=${{ steps.build-metadata.outputs.date }}
|
||||||
|
GIT_TAG=${{ github.ref_name }}
|
||||||
|
|
||||||
# /!\ Don't touch this without checking with Cloud team
|
# /!\ Don't touch this without checking with Cloud team
|
||||||
- name: Send CI information to Cloud team
|
- name: Send CI information to Cloud team
|
||||||
|
@ -121,15 +121,19 @@ The full Meilisearch release process is described in [this guide](https://github
|
|||||||
Depending on the developed feature, you might need to provide a prototyped version of Meilisearch to make it easier to test by the users.
|
Depending on the developed feature, you might need to provide a prototyped version of Meilisearch to make it easier to test by the users.
|
||||||
|
|
||||||
The prototype name must follow this convention: `prototype-X-Y` where
|
The prototype name must follow this convention: `prototype-X-Y` where
|
||||||
- `X` is the feature name formatted in `kebab-case`
|
- `X` is the feature name formatted in `kebab-case`. It should not end with a single number.
|
||||||
- `Y` is the version of the prototype, starting from `0`.
|
- `Y` is the version of the prototype, starting from `0`.
|
||||||
|
|
||||||
Example: `prototype-auto-resize-0`.
|
✅ Example: `prototype-auto-resize-0`. </br>
|
||||||
|
❌ Bad example: `auto-resize-0`: lacks the `prototype` prefix. </br>
|
||||||
|
❌ Bad example: `prototype-auto-resize`: lacks the version suffix. </br>
|
||||||
|
❌ Bad example: `prototype-auto-resize-0-0`: feature name ends with a single number.
|
||||||
|
|
||||||
Steps to create a prototype:
|
Steps to create a prototype:
|
||||||
|
|
||||||
1. In your terminal, go to the last commit of your branch (the one you want to provide as a prototype).
|
1. In your terminal, go to the last commit of your branch (the one you want to provide as a prototype).
|
||||||
2. Create a tag following the convention: `git tag prototype-X-Y`
|
2. Create a tag following the convention: `git tag prototype-X-Y`
|
||||||
|
3. Run Meilisearch and check that its launch summary features a line: `Prototype: prototype-X-Y` (you may need to switch branches and back after tagging for this to work).
|
||||||
3. Push the tag: `git push origin prototype-X-Y`
|
3. Push the tag: `git push origin prototype-X-Y`
|
||||||
4. Check the [Docker CI](https://github.com/meilisearch/meilisearch/actions/workflows/publish-docker-images.yml) is now running.
|
4. Check the [Docker CI](https://github.com/meilisearch/meilisearch/actions/workflows/publish-docker-images.yml) is now running.
|
||||||
|
|
||||||
@ -138,7 +142,7 @@ More information about [how to run Meilisearch with Docker](https://docs.meilise
|
|||||||
|
|
||||||
⚙️ However, no binaries will be created. If the users do not use Docker, they can go to the `prototype-X-Y` tag in the Meilisearch repository and compile from the source code.
|
⚙️ However, no binaries will be created. If the users do not use Docker, they can go to the `prototype-X-Y` tag in the Meilisearch repository and compile from the source code.
|
||||||
|
|
||||||
⚠️ When sharing a prototype with users, prevent them from using it in production. Prototypes are only for test purposes.
|
⚠️ When sharing a prototype with users, remind them to not use it in production. Prototypes are solely for test purposes.
|
||||||
|
|
||||||
### Release assets
|
### Release assets
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ WORKDIR /meilisearch
|
|||||||
|
|
||||||
ARG COMMIT_SHA
|
ARG COMMIT_SHA
|
||||||
ARG COMMIT_DATE
|
ARG COMMIT_DATE
|
||||||
ENV VERGEN_GIT_SHA=${COMMIT_SHA} VERGEN_GIT_COMMIT_TIMESTAMP=${COMMIT_DATE}
|
ARG GIT_TAG
|
||||||
|
ENV VERGEN_GIT_SHA=${COMMIT_SHA} VERGEN_GIT_COMMIT_TIMESTAMP=${COMMIT_DATE} VERGEN_GIT_SEMVER_LIGHTWEIGHT=${GIT_TAG}
|
||||||
ENV RUSTFLAGS="-C target-feature=-crt-static"
|
ENV RUSTFLAGS="-C target-feature=-crt-static"
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
use vergen::{vergen, Config};
|
use vergen::{vergen, Config, SemverKind};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if let Err(e) = vergen(Config::default()) {
|
// Note: any code that needs VERGEN_ environment variables should take care to define them manually in the Dockerfile and pass them
|
||||||
|
// in the corresponding GitHub workflow (publish_docker.yml).
|
||||||
|
// This is due to the Dockerfile building the binary outside of the git directory.
|
||||||
|
let mut config = Config::default();
|
||||||
|
// allow using non-annotated tags
|
||||||
|
*config.git_mut().semver_kind_mut() = SemverKind::Lightweight;
|
||||||
|
|
||||||
|
if let Err(e) = vergen(config) {
|
||||||
println!("cargo:warning=vergen: {}", e);
|
println!("cargo:warning=vergen: {}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,12 +401,19 @@ impl Segment {
|
|||||||
if let Ok(stats) =
|
if let Ok(stats) =
|
||||||
create_all_stats(index_scheduler.into(), auth_controller, &SearchRules::default())
|
create_all_stats(index_scheduler.into(), auth_controller, &SearchRules::default())
|
||||||
{
|
{
|
||||||
|
// Replace the version number with the prototype name if any.
|
||||||
|
let version = if let Some(prototype) = crate::prototype_name() {
|
||||||
|
prototype
|
||||||
|
} else {
|
||||||
|
env!("CARGO_PKG_VERSION")
|
||||||
|
};
|
||||||
|
|
||||||
let _ = self
|
let _ = self
|
||||||
.batcher
|
.batcher
|
||||||
.push(Identify {
|
.push(Identify {
|
||||||
context: Some(json!({
|
context: Some(json!({
|
||||||
"app": {
|
"app": {
|
||||||
"version": env!("CARGO_PKG_VERSION").to_string(),
|
"version": version.to_string(),
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
user: self.user.clone(),
|
user: self.user.clone(),
|
||||||
|
@ -427,3 +427,30 @@ pub fn configure_metrics_route(config: &mut web::ServiceConfig, enable_metrics_r
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Parses the output of
|
||||||
|
/// [`VERGEN_GIT_SEMVER_LIGHTWEIGHT`](https://docs.rs/vergen/latest/vergen/struct.Git.html#instructions)
|
||||||
|
/// as a prototype name.
|
||||||
|
///
|
||||||
|
/// Returns `Some(prototype_name)` if the following conditions are met on this value:
|
||||||
|
///
|
||||||
|
/// 1. starts with `prototype-`,
|
||||||
|
/// 2. ends with `-<some_number>`,
|
||||||
|
/// 3. does not end with `<some_number>-<some_number>`.
|
||||||
|
///
|
||||||
|
/// Otherwise, returns `None`.
|
||||||
|
pub fn prototype_name() -> Option<&'static str> {
|
||||||
|
let prototype: &'static str = option_env!("VERGEN_GIT_SEMVER_LIGHTWEIGHT")?;
|
||||||
|
|
||||||
|
if !prototype.starts_with("prototype-") {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut rsplit_prototype = prototype.rsplit('-');
|
||||||
|
// last component MUST be a number
|
||||||
|
rsplit_prototype.next()?.parse::<u64>().ok()?;
|
||||||
|
// before than last component SHALL NOT be a number
|
||||||
|
rsplit_prototype.next()?.parse::<u64>().err()?;
|
||||||
|
|
||||||
|
Some(prototype)
|
||||||
|
}
|
||||||
|
@ -8,7 +8,7 @@ use actix_web::web::Data;
|
|||||||
use actix_web::HttpServer;
|
use actix_web::HttpServer;
|
||||||
use index_scheduler::IndexScheduler;
|
use index_scheduler::IndexScheduler;
|
||||||
use meilisearch::analytics::Analytics;
|
use meilisearch::analytics::Analytics;
|
||||||
use meilisearch::{analytics, create_app, setup_meilisearch, Opt};
|
use meilisearch::{analytics, create_app, prototype_name, setup_meilisearch, Opt};
|
||||||
use meilisearch_auth::{generate_master_key, AuthController, MASTER_KEY_MIN_SIZE};
|
use meilisearch_auth::{generate_master_key, AuthController, MASTER_KEY_MIN_SIZE};
|
||||||
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
|
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
|
||||||
|
|
||||||
@ -137,6 +137,9 @@ pub fn print_launch_resume(
|
|||||||
eprintln!("Commit SHA:\t\t{:?}", commit_sha.to_string());
|
eprintln!("Commit SHA:\t\t{:?}", commit_sha.to_string());
|
||||||
eprintln!("Commit date:\t\t{:?}", commit_date.to_string());
|
eprintln!("Commit date:\t\t{:?}", commit_date.to_string());
|
||||||
eprintln!("Package version:\t{:?}", env!("CARGO_PKG_VERSION").to_string());
|
eprintln!("Package version:\t{:?}", env!("CARGO_PKG_VERSION").to_string());
|
||||||
|
if let Some(prototype) = prototype_name() {
|
||||||
|
eprintln!("Prototype:\t\t{:?}", prototype);
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(all(not(debug_assertions), feature = "analytics"))]
|
#[cfg(all(not(debug_assertions), feature = "analytics"))]
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user