Skip to content

Commit

Permalink
Create gitlab pipeline (#534)
Browse files Browse the repository at this point in the history
* add badge to readme

* first version of pipeline

* Update .gitlab-ci.yml

Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>

* add pre-cache script

* fmt and clippy stable

* add check and test

* remove output text file from bench

* Update scripts/ci/pre_cache.sh

Co-authored-by: David <dvdplm@gmail.com>

* Update .gitlab-ci.yml

Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>

* small fix

* fix test and schedule

* CI: verbose is a surplus

* CI: separately check rustdoc linx

* fix refs

* add bench to gh-pages

* fix refs

* fix benchmarks

* added vault to ci

* fix vars

* comment bench

* fix benches name

* added script to push benchmark results to VM

* make script executable

* change bench psuh executor

* changed benchmark task to run on a dedicated node pool

* change prometheus metric name for benchmarks

* send 2 metrics with benchmark results

* disable non-schedule jobs from schedule run

* empty commit for benchmark test

* change metric name

* empty commit for benchmark test

* empty commit for benchmark test

* add cirunner label to vm metric

* split vm metric to 2 metrics

* change runner description to runner tag in ci scripts

* add pass runner tags from benchmark to publish job

* change runner tag to runner description

* add debug message

* empty commit for test

* empty commit for test

* Update .scripts/ci/push_bench_results.sh

Co-authored-by: Denis Pisarev <17856421+TriplEight@users.noreply.github.com>

* add defaults, remove dups, change ci image for publish-bench

* remove pre_cache.sh

* move interruptible to defaults

* add issue to fixme comment

Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
Co-authored-by: David <dvdplm@gmail.com>
Co-authored-by: Denis P <denis.pisarev@parity.io>
Co-authored-by: Denis Pisarev <17856421+TriplEight@users.noreply.github.com>
  • Loading branch information
5 people authored Dec 2, 2021
1 parent be6f64a commit 66aa6c4
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 3 deletions.
149 changes: 149 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
default:
interruptible: true
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure

stages:
- lint
- test
- benchmark
- publish

variables: &default-vars
GIT_STRATEGY: fetch
GIT_DEPTH: 100
CARGO_INCREMENTAL: 0
CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
CI_IMAGE: "paritytech/ci-linux:production"
VAULT_SERVER_URL: "https://vault.parity-mgmt-vault.parity.io"
VAULT_AUTH_PATH: "gitlab-parity-io-jwt"
VAULT_AUTH_ROLE: "cicd_gitlab_parity_${CI_PROJECT_NAME}"

.vault-secrets: &vault-secrets
secrets:
GITHUB_TOKEN:
vault: cicd/gitlab/parity/GITHUB_TOKEN@kv
file: false
GITHUB_USER:
vault: cicd/gitlab/parity/GITHUB_USER@kv
file: false

.common-refs: &common-refs
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_COMMIT_REF_NAME == "main"
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs

# run nightly by schedule
.schedule-refs: &schedule-refs
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"

.rust-info-script: &rust-info-script
- rustup show
- cargo --version
- rustup +nightly show
- cargo +nightly --version
- bash --version
- sccache -s

.docker-env: &docker-env
image: "${CI_IMAGE}"
before_script:
- *rust-info-script
- sccache -s
tags:
- linux-docker

.kubernetes-env: &kubernetes-env
image: "${CI_IMAGE}"
tags:
- kubernetes-parity-build

.collect-artifacts: &collect-artifacts
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
when: on_success
expire_in: 28 days
paths:
- ./artifacts/
reports:
dotenv: runner.env
#### stage: lint

fmt:
stage: lint
<<: *docker-env
<<: *common-refs
script:
# FIXME: remove component add after https://github.com/paritytech/substrate/issues/10411 is fixed
- rustup component add rustfmt
- cargo fmt --all -- --check

clippy:
stage: lint
<<: *docker-env
<<: *common-refs
script:
# FIXME: remove component add after https://github.com/paritytech/substrate/issues/10411 is fixed
- rustup component add clippy
- cargo clippy --all-targets

check-rustdoc-links:
stage: lint
<<: *docker-env
<<: *common-refs
script:
- RUSTDOCFLAGS="--deny broken_intra_doc_links" cargo doc --workspace --no-deps --document-private-items

#### stage: test

check-code:
stage: test
<<: *docker-env
<<: *common-refs
script:
- cargo install cargo-hack
- cargo hack check --workspace --each-feature

test:
stage: test
<<: *docker-env
<<: *common-refs
script:
- cargo test

benchmarks:
stage: benchmark
<<: *docker-env
<<: *collect-artifacts
<<: *schedule-refs
script:
- cargo bench -p jsonrpsee-benchmarks -- --output-format bencher | tee output.txt
- mkdir artifacts
- cp output.txt artifacts/
- echo ${CI_RUNNER_DESCRIPTION}
- echo "RUNNER_NAME=${CI_RUNNER_DESCRIPTION}" > runner.env
tags:
- linux-docker-benches

publish-bench:
stage: publish
variables:
CI_IMAGE: "paritytech/tools:latest"
<<: *kubernetes-env
<<: *schedule-refs
needs:
- job: benchmarks
artifacts: true
script:
- echo $RUNNER_NAME
- .scripts/ci/push_bench_results.sh artifacts/output.txt

28 changes: 28 additions & 0 deletions .scripts/ci/push_bench_results.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# The script takes output.txt, removes every line that doesn't have "test"
# in it and pushes benchmark result to Victoria Metrics
# Benchmark name should have underscores in the name instead of spaces (e.g. async/http_concurrent_round_trip/8)

RESULT_FILE=$1
CURRENT_DIR=$(pwd)

if [ -z "$RESULT_FILE" ]
then
RESULT_FILE="output.txt"
fi

cat $RESULT_FILE | grep test > $CURRENT_DIR/output_redacted.txt

INPUT="output_redacted.txt"

while IFS= read -r line
do
BENCH_NAME=$(echo $line | cut -f 2 -d ' ')
BENCH_RESULT=$(echo $line | cut -f 5 -d ' ')
# send metric with common results
curl -d 'parity_benchmark_common_result_ns{project="'${CI_PROJECT_NAME}'",benchmark="'$BENCH_NAME'"} '$BENCH_RESULT'' \
-X POST 'http://vm-longterm.parity-build.parity.io/api/v1/import/prometheus'
# send metric with detailed results
curl -d 'parity_benchmark_specific_result_ns{project="'${CI_PROJECT_NAME}'",benchmark="'$BENCH_NAME'",commit="'${CI_COMMIT_SHORT_SHA}'",cirunner="'${RUNNER_NAME}'"} '$BENCH_RESULT'' \
-X POST 'http://vm-longterm.parity-build.parity.io/api/v1/import/prometheus'
done < "$INPUT"
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![GitLab Status](https://gitlab.parity.io/parity/jsonrpsee/badges/master/pipeline.svg)](https://gitlab.parity.io/parity/jsonrpsee/pipelines)

# jsonrpsee

JSON-RPC library designed for async/await in Rust.
Expand Down
6 changes: 3 additions & 3 deletions benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ trait RequestBencher {
let rt = TokioRuntime::new().unwrap();
let (url, _server) = rt.block_on(helpers::http_server(rt.handle().clone()));
let client = Arc::new(HttpClientBuilder::default().max_concurrent_requests(1024 * 1024).build(&url).unwrap());
run_round_trip_with_batch(&rt, crit, client, "http batch requests", Self::REQUEST_TYPE);
run_round_trip_with_batch(&rt, crit, client, "http_batch_requests", Self::REQUEST_TYPE);
}

fn websocket_requests(crit: &mut Criterion) {
Expand All @@ -113,7 +113,7 @@ trait RequestBencher {
let (url, _server) = rt.block_on(helpers::ws_server(rt.handle().clone()));
let client =
Arc::new(rt.block_on(WsClientBuilder::default().max_concurrent_requests(1024 * 1024).build(&url)).unwrap());
run_round_trip_with_batch(&rt, crit, client, "ws batch requests", Self::REQUEST_TYPE);
run_round_trip_with_batch(&rt, crit, client, "ws_batch_requests", Self::REQUEST_TYPE);
}

fn subscriptions(crit: &mut Criterion) {
Expand Down Expand Up @@ -188,7 +188,7 @@ fn run_sub_round_trip(rt: &TokioRuntime, crit: &mut Criterion, client: Arc<impl
});
}

/// Benchmark http batch requests over batch sizes of 2, 5, 10, 50 and 100 RPCs in each batch.
/// Benchmark http_batch_requests over batch sizes of 2, 5, 10, 50 and 100 RPCs in each batch.
fn run_round_trip_with_batch(
rt: &TokioRuntime,
crit: &mut Criterion,
Expand Down

3 comments on commit 66aa6c4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 66aa6c4 Previous: be6f64a Ratio
subscriptions/subscribe_response 22254 ns/iter (± 4188) 6199 ns/iter (± 1563) 3.59

This comment was automatically generated by workflow using github-action-benchmark.

CC: @niklasad1 @maciejhirsz

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 66aa6c4 Previous: be6f64a Ratio
subscriptions/subscribe_response 16911 ns/iter (± 1998) 6199 ns/iter (± 1563) 2.73

This comment was automatically generated by workflow using github-action-benchmark.

CC: @niklasad1 @maciejhirsz

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 66aa6c4 Previous: be6f64a Ratio
subscriptions/subscribe_response 15995 ns/iter (± 1129) 6199 ns/iter (± 1563) 2.58

This comment was automatically generated by workflow using github-action-benchmark.

CC: @niklasad1 @maciejhirsz

Please sign in to comment.