Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun committed Mar 9, 2024
1 parent fbcaa08 commit 8433aac
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 16 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2023 Greptime Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: CI

on:
Expand Down Expand Up @@ -39,23 +53,16 @@ concurrency:
cancel-in-progress: true

jobs:
lint:
name: Lint
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: korandoru/hawkeye@v4
- uses: Swatinem/rust-cache@v2
- uses: crate-ci/typos@v1.0.4
- uses: crate-ci/typos@v1.19.0
- run: cargo fmt --all -- --check
- run: cargo clippy --all-targets -- -D warnings

check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- run: cargo check

coverage:
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2023 Greptime Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Release
run-name: publish packages by @${{ github.actor }}

Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/semantic-pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2023 Greptime Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Semantic Pull Request

on:
Expand Down
14 changes: 14 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2023 Greptime Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[package]
name = "promql-parser"
readme = "README.md"
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ To parse a simple instant vector selector expression:
``` rust
use promql_parser::parser;

let promql = r#"http_requests_total{environment=~"staging|testing|development",method!="GET"} offset 5m"#;
let promql = r#"
http_requests_total{
environment=~"staging|testing|development",
method!="GET"
} offset 5m
"#;

match parser::parse(promql) {
Ok(expr) => {
Expand Down
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2023 Greptime Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

coverage:
status:
project:
Expand Down
7 changes: 6 additions & 1 deletion examples/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
use promql_parser::parser;

fn main() {
let promql = r#"http_requests_total{environment=~"staging|testing|development",method!="GET"} offset 5m"#;
let promql = r#"
http_requests_total{
environment=~"staging|testing|development",
method!="GET"
} offset 5m
"#;

match parser::parse(promql) {
Ok(expr) => {
Expand Down
14 changes: 14 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright 2023 Greptime Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[toolchain]
channel = "stable"
components = ["cargo", "rustfmt", "clippy", "rust-analyzer"]
4 changes: 2 additions & 2 deletions src/parser/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ pub enum Expr {
Call(Call),

/// Extension represents an extension expression. It is for user to attach additional
/// informations to the AST. This parser won't generate Extension node.
/// information to the AST. This parser won't generate Extension node.
Extension(Extension),
}

Expand Down Expand Up @@ -1427,7 +1427,7 @@ fn check_ast_for_vector_selector(ex: VectorSelector) -> Result<Expr, String> {
#[cfg(test)]
mod tests {
use super::*;
use crate::label::{MatchOp, Matcher, Matchers};
use crate::label::{MatchOp, Matcher};

#[test]
fn test_valid_at_modifier() {
Expand Down
2 changes: 1 addition & 1 deletion src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub trait Prettier: std::fmt::Display {
}
}

/// override format if expr needs to be splited into multiple lines
/// override format if expr needs to be split into multiple lines
fn format(&self, level: usize, _max: usize) -> String {
format!("{}{self}", indent(level))
}
Expand Down
2 changes: 1 addition & 1 deletion src/parser/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn parse(input: &str) -> Result<Expr, String> {
///
/// - all cases SHOULD be covered, and the same literal float and literal
/// string SHOULD be the same with the original prometheus.
/// - all cases will be splitted into different blocks based on the type of parsed Expr.
/// - all cases will be split into different blocks based on the type of parsed Expr.
#[cfg(test)]
mod tests {
use regex::Regex;
Expand Down

0 comments on commit 8433aac

Please sign in to comment.