Skip to content

Commit

Permalink
feat(all): refactor all
Browse files Browse the repository at this point in the history
  • Loading branch information
devillove084 committed Mar 8, 2024
1 parent a65b992 commit 5c2e2fa
Show file tree
Hide file tree
Showing 279 changed files with 6,316 additions and 21,346 deletions.
24 changes: 24 additions & 0 deletions .config/hakari.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This file contains settings for `cargo hakari`.
# See https://docs.rs/cargo-hakari/latest/cargo_hakari/config for a full list of options.

hakari-package = "workspace-hack"

dep-format-version = "4"
workspace-hack-line-style = "workspace-dotted"

# Setting workspace.resolver = "2" in the root Cargo.toml is HIGHLY recommended.
# Hakari works much better with the new feature resolver.
# For more about the new feature resolver, see:
# https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html#cargos-new-feature-resolver
resolver = "2"

# Add triples corresponding to platforms commonly used by developers here.
# https://doc.rust-lang.org/rustc/platform-support.html
platforms = [
"x86_64-unknown-linux-gnu",
"x86_64-apple-darwin",
# "x86_64-pc-windows-msvc",
]

# Write out exact versions rather than a semver range. (Defaults to false.)
exact-versions = true
46 changes: 46 additions & 0 deletions .config/templatedb.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[profile.default]
final-status-level = "slow"

[[profile.default.overrides]]
# test_subprocess_doesnt_exit runs a sleep command for 360 seconds. If integration tests take longer
# than 180 seconds, it likely means that nextest is stuck waiting for the sleep command to exit.
# This is a bug.
filter = 'package(integration-tests)'
slow-timeout = { period = "60s", terminate-after = 3 }
test-group = "my-group"
junit.store-success-output = true

[profile.ci]
# Don't fail fast in CI to run the full test suite.
fail-fast = false

[[profile.ci.overrides]]
# These tests are a bit flaky on Mac GHA CI runners due to resource exhaustion.
platform = 'cfg(target_os = "macos")'
filter = '(package(nextest-runner) and binary(integration)) or package(integration-tests)'
retries = { count = 3, backoff = "fixed", delay = "1s" }

[profile.test-slow]
# This is a test profile with a quick slow timeout.
slow-timeout = "1s"

[profile.test-slow-with-timeout]
slow-timeout = { period = "1s", terminate-after = 2 }
retries = 2

[profile.with-junit]
junit = { path = "report.xml" }

[profile.serial]
test-threads = 1

[[profile.serial.overrides]]
filter = 'test(foo)'
retries = 3

# Added for testing.
[test-groups.my-group]
max-threads = 8

[test-groups.unused-group]
max-threads = 8
138 changes: 59 additions & 79 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,92 +1,72 @@
# Copyright 2022 The template Authors.
#
# 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

env:
RUSTUP_MAX_RETRIES: 10
CARGO_NET_RETRY: 10
CARGO_INCREMENTAL: 0 # reduce an extra dependency-tracking overhead added by incremental
CARGO_PROFILE_DEV_DEBUG: 0 # disable debug info for reducing binary size
CI: 1

on:
push:
branches: [main]
pull_request:
paths-ignore:
- "docs/**"
- "**.md"
- "scripts/**"
- "conf/**"
branches:
- main

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
name: CI
env:
RUSTFLAGS: -D warnings
CARGO_TERM_COLOR: always

jobs:
license:
name: Check license header
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: apache/skywalking-eyes/header@501a28d2fb4a9b962661987e50cf0219631b32ff
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: dtolnay/rust-toolchain@stable
with:
config: tools/ci/licenserc.yml
components: rustfmt, clippy
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2
- name: Lint (clippy)
run: cargo clippy --all-features --all-targets
- name: Lint (rustfmt)
run: cargo xfmt --check

test:
name: Run tests
build:
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
os:
- ubuntu-latest
# macos-14 for M1 runners
- macos-14
rust-version: [nightly]
fail-fast: false
steps:
- uses: abelfodil/protoc-action@v1
with:
protoc-version: '3.19.4'
enable-dart: false
- uses: actions/checkout@v2
- name: Install cargo-nextest
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-nextest
- name: Checkout repository
uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- name: Cargo build
uses: actions-rs/cargo@v1
with:
command: build
- name: Check diff
run: git diff --exit-code
- name: Check clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --tests --all-features -- -D warnings
- name: Check format
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Cargo test
uses: actions-rs/cargo@v1
with:
command: nextest
args: run
- name: Run miri tests
uses: actions-rs/cargo@v1
with:
command: miri
args: nextest run
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2
with:
# Matrix instances (other than OS) need to be added to this explicitly
key: ${{ matrix.rust-version }}
- name: Install latest nextest release
uses: taiki-e/install-action@nextest
- name: Build quick-junit
run: cargo build --package quick-junit
- name: Build nextest-metadata
run: cargo build --package nextest-metadata
- name: Build cargo-nextest without self-update
run: cargo build --package cargo-nextest --no-default-features --features default-no-update
- name: Build cargo-nextest
run: cargo build --package cargo-nextest
- name: Build all targets
run: cargo build --all-targets
- name: Build all targets with all features
run: cargo build --all-targets --all-features
- name: Doctests
run: cargo test --doc
- name: Test with locally built nextest
run: cargo local-nt run --profile ci
- name: Test with latest nextest release
run: cargo nextest run --profile ci
- name: Test without double-spawning
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'macos-14' }}
env:
NEXTEST_DOUBLE_SPAWN: 0
run: cargo local-nt run --profile ci
43 changes: 43 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
on:
push:
branches: [main]
pull_request:
branches:
- main

name: Test coverage

jobs:
coverage:
name: Collect test coverage
runs-on: ubuntu-latest
# nightly rust might break from time to time
continue-on-error: true
env:
RUSTFLAGS: -D warnings
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
# Nightly Rust is used for cargo llvm-cov --doc below.
- uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools-preview
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2

- name: Install latest nextest release
uses: taiki-e/install-action@nextest
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Collect coverage data
# Generate separate reports for nextest and doctests, and combine them.
run: |
cargo llvm-cov --no-report nextest
cargo llvm-cov --no-report --doc
cargo llvm-cov report --doctests --lcov --output-path lcov.info
- name: Upload coverage data to codecov
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: lcov.info
27 changes: 27 additions & 0 deletions .github/workflows/hakari.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
push:
branches:
- main
pull_request:
branches:
- main

name: cargo hakari

jobs:
workspace-hack-check:
name: Check workspace-hack
runs-on: ubuntu-latest
env:
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: dtolnay/rust-toolchain@stable
- name: Install cargo-hakari
uses: taiki-e/install-action@715c07ff046a1badca82fa42e5708f37e405a997 # v2
with:
tool: cargo-hakari
- name: Check workspace-hack Cargo.toml is up-to-date
run: cargo hakari generate --diff
- name: Check all crates depend on workspace-hack
run: cargo hakari manage-deps --dry-run
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# TemplateKV Change Log
# TemplateDB Change Log

All notable changes to this project are documented in this file.
Loading

0 comments on commit 5c2e2fa

Please sign in to comment.