Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into na-clients-opt-of-f…
Browse files Browse the repository at this point in the history
…rom-tls
  • Loading branch information
niklasad1 committed Dec 3, 2021
2 parents fab8e24 + 66aa6c4 commit 0c64dd8
Show file tree
Hide file tree
Showing 79 changed files with 2,726 additions and 733 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:

- name: Checkout Sources
uses: actions/checkout@v2.3.5
uses: actions/checkout@v2.4.0

- name: Install Rust nightly toolchain
uses: actions-rs/toolchain@v1.0.7
Expand Down
96 changes: 14 additions & 82 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v2.4.0

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1.0.7
Expand All @@ -41,6 +41,7 @@ jobs:
uses: actions-rs/cargo@v1.0.3
with:
command: clippy
args: --all-targets

- name: Check rustdoc links
run: RUSTDOCFLAGS="--deny broken_intra_doc_links" cargo doc --verbose --workspace --no-deps --document-private-items
Expand All @@ -50,7 +51,7 @@ jobs:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2.3.5
- uses: actions/checkout@v2.4.0

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1.0.7
Expand All @@ -59,75 +60,21 @@ jobs:
toolchain: stable
override: true

- name: Install cargo-hack
run: cargo install cargo-hack

- name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0

- name: Cargo check all targets (use Cargo.toml in workspace)
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --all-targets

- name: Cargo check HTTP client
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path http-client/Cargo.toml

- name: Cargo check HTTP server
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path http-server/Cargo.toml

- name: Cargo check WS client
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path ws-client/Cargo.toml

- name: Cargo check WS server
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path ws-server/Cargo.toml

- name: Cargo check types
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path types/Cargo.toml

- name: Cargo check utils
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path utils/Cargo.toml

- name: Cargo check proc macros
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path proc-macros/Cargo.toml

- name: Cargo check test utils
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path test-utils/Cargo.toml

- name: Cargo check examples
uses: actions-rs/cargo@v1.0.3
with:
command: check
args: --manifest-path examples/Cargo.toml
- name: Cargo check all targets and features
run: cargo hack check --workspace --each-feature --all-targets

tests:
name: Run tests Ubuntu
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2.3.5
uses: actions/checkout@v2.4.0

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1.0.7
Expand All @@ -139,23 +86,18 @@ jobs:
- name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0

- name: Cargo build
uses: actions-rs/cargo@v1.0.3
with:
command: build
args: --workspace

- name: Cargo test
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: --workspace

tests_macos:
name: Run tests macos
runs-on: macos-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2.3.5
uses: actions/checkout@v2.4.0

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1.0.7
Expand All @@ -167,23 +109,18 @@ jobs:
- name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0

- name: Cargo build
uses: actions-rs/cargo@v1.0.3
with:
command: build
args: --workspace

- name: Cargo test
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: --workspace

tests_windows:
name: Run tests Windows
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2.3.5
uses: actions/checkout@v2.4.0

- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1.0.7
Expand All @@ -195,13 +132,8 @@ jobs:
- name: Rust Cache
uses: Swatinem/rust-cache@v1.3.0

- name: Cargo build
uses: actions-rs/cargo@v1.0.3
with:
command: build
args: --workspace

- name: Cargo test
uses: actions-rs/cargo@v1.0.3
with:
command: test
args: --workspace
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"
Loading

0 comments on commit 0c64dd8

Please sign in to comment.