ci: switch to GitHub actions (#10)

- ppc64le is not checked as there is no ppc64le runners.
- valgrind is removed.
- no_std check is removed

Signed-off-by: Jay Lee <BusyJayLee@gmail.com>
This commit is contained in:
Jay 2021-08-05 01:08:14 +08:00 committed by GitHub
parent 6494cc8660
commit e5f53b1441
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 97 additions and 162 deletions

View File

@ -1,17 +1,81 @@
name: CI
on: [push]
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
test:
name: ${{ matrix.name }}
strategy:
matrix:
include:
- name: aarch64-unknown-linux-gnu
target: aarch64-unknown-linux-gnu
nobgt: 0
no_tests: 1
tag: arm64
- name: x86_64-unknown-linux-gnu (nightly)
target: x86_64-unknown-linux-gnu
nobgt: 0
no_tests: 0
rust: nightly
tag: ubuntu-latest
- name: x86_64-unknown-linux-gnu (stable)
target: x86_64-unknown-linux-gnu
nobgt: 0
no_tests: 0
rust: stable
tag: ubuntu-latest
- name: x86_64-unknown-linux-musl
target: x86_64-unknown-linux-musl
nobgt: 1
no_tests: 1
tag: ubuntu-latest
- name: x86_64-apple-darwin (stable)
target: x86_64-apple-darwin
nobgt: 0
no_tests: 1
tag: macos-latest
runs-on: ${{ matrix.tag }}
env:
TARGET: ${{ matrix.target }}
NO_JEMALLOC_TESTS: ${{ matrix.no_tests }}
NOBGT: ${{ matrix.nobgt }}
steps:
- uses: actions/checkout@v1
- name: Run a one-line script
run: echo Hello, world!
- name: Run a multi-line script
- uses: actions/checkout@v2
with:
submodules: true
- name: install
run: |
echo Add other actions to build,
echo test, and deploy your project.
if [[ "${{ matrix.rust }}" == "nightly" ]]; then
rustup default nightly
fi
rustup target add ${{ matrix.target }}
if [[ "$TARGET" == "x86_64-unknown-linux-musl" ]]; then
sudo apt install -y musl-tools
fi
- name: test
run: sh ci/run.sh
test_bench:
name: Benchmarks using x86_64-unknown-linux-gnu (nightly)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- run: rustup default nightly
- run: cargo test --bench roundtrip
check:
name: Rustfmt and Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- run: rustup component add rustfmt clippy
- run: cargo fmt --all -- --check
- run: cargo clippy -p tikv-jemalloc-sys -- -D clippy::all
- run: cargo clippy -p tikv-jemallocator -- -D clippy::all
- run: cargo clippy -p tikv-jemallocator-global -- -D clippy::all
- run: cargo clippy -p tikv-jemalloc-ctl -- -D clippy::all
- run: env RUSTDOCFLAGS="--cfg jemallocator_docs" cargo doc
- run: shellcheck ci/*.sh

View File

@ -1,90 +0,0 @@
language: rust
rust: nightly
services: docker
jobs:
include:
# Linux
- name: "aarch64-unknown-linux-gnu"
env: TARGET=aarch64-unknown-linux-gnu NO_JEMALLOC_TESTS=1
arch: arm64
- name: "powerpc64le-unknown-linux-gnu"
env: TARGET=powerpc64le-unknown-linux-gnu NO_JEMALLOC_TESTS=1
arch: ppc64le
- name: "x86_64-unknown-linux-gnu (nightly)"
env: TARGET=x86_64-unknown-linux-gnu VALGRIND=1
install: rustup component add llvm-tools-preview
addons: &valgrind
apt:
packages:
- valgrind
- name: "x86_64-unknown-linux-gnu (stable)"
env: TARGET=x86_64-unknown-linux-gnu VALGRIND=1
rust: stable
install: rustup component add llvm-tools-preview
addons: *valgrind
- name: "Benchmarks using x86_64-unknown-linux-gnu (nightly)"
env: TARGET=x86_64-unknown-linux-gnu
install: true
script:
- cargo test --bench roundtrip
# FIXME: Re-enable this when allocator API is stable.
# - cargo test --features=alloc_trait --bench roundtrip
- name: "x86_64-unknown-linux-musl"
env: TARGET=x86_64-unknown-linux-musl NOBGT=1 NO_JEMALLOC_TESTS=1
install: rustup target add x86_64-unknown-linux-musl
addons:
apt:
packages:
musl-tools
# OSX
# FIXME: cannot jemalloc tests fail due to:
# https://github.com/jemalloc/jemalloc/issues/1320
# https://github.com/gnzlbg/jemallocator/issues/85
# FIXME: valgrind fails on OSX
# https://github.com/gnzlbg/jemallocator/issues/86
- name: "x86_64-apple-darwin (nightly)"
env: TARGET=x86_64-apple-darwin NO_JEMALLOC_TESTS=1
os: osx
osx_image: xcode10
install: rustup component add llvm-tools-preview
install: rustup component add llvm-tools-preview
- name: "x86_64-apple-darwin (stable)"
env: TARGET=x86_64-apple-darwin NO_JEMALLOC_TESTS=1
os: osx
osx_image: xcode10
rust: stable
install: rustup component add llvm-tools-preview
# TOOLING
- name: "Documentation"
install: true
script: RUSTDOCFLAGS="--cfg jemallocator_docs" cargo doc
- name: "rustfmt"
install: true
rust: nightly
script: |
if rustup component add rustfmt-preview ; then
cargo fmt --all -- --check
fi
- name: "clippy"
install: true
rust: nightly
# allow(clippy::all) fails in the syscrate, so we can't use --all here:
script: |
if rustup component add clippy-preview ; then
cargo clippy -p tikv-jemalloc-sys -- -D clippy::all
cargo clippy -p tikv-jemallocator -- -D clippy::all
cargo clippy -p tikv-jemallocator-global -- -D clippy::all
cargo clippy -p tikv-jemalloc-ctl -- -D clippy::all
fi
- name: "Shellcheck"
install: true
script: shellcheck ci/*.sh
install: rustup target add ${TARGET}
script: sh ci/run.sh
notifications:
email:
on_success: never

View File

@ -1,6 +1,6 @@
# tikv-jemallocator
[![Travis-CI Status]][travis] [![Latest Version]][crates.io] [![docs]][docs.rs]
[![ci]][github actions] [![Latest Version]][crates.io] [![docs]][docs.rs]
This project is a simplified fork of [jemallocator](https://github.com/gnzlbg/jemallocator) focus on server.
@ -53,18 +53,17 @@ The following table describes the supported platforms:
* `build`: does the library compile for the target?
* `run`: do `tikv-jemallocator` and `tikv-jemalloc-sys` tests pass on the target?
* `jemalloc`: do `tikv-jemalloc`'s tests pass on the target?
* `valgrind`: do the tests pass under valgrind?
Tier 1 targets are tested on all Rust channels (stable, beta, and nightly). All
other targets are only tested on Rust nightly.
| Linux targets: | build | run | jemalloc | valgrind |
|-------------------------------------|-----------|---------|--------------|--------------|
| `aarch64-unknown-linux-gnu` | ✓ | ✓ | ✗ | ✗ |
| `powerpc64le-unknown-linux-gnu` | ✓ | ✓ | ✗ | ✗ |
| `x86_64-unknown-linux-gnu` (tier 1) | ✓ | ✓ | ✓ | ✓ |
| **MacOSX targets:** | **build** | **run** | **jemalloc** | **valgrind** |
| `x86_64-apple-darwin` (tier 1) | ✓ | ✓ | ✗ | ✗ |
| Linux targets: | build | run | jemalloc |
|-------------------------------------|-----------|---------|--------------|
| `aarch64-unknown-linux-gnu` | ✓ | ✓ | ✗ |
| `powerpc64le-unknown-linux-gnu` | ✓ | ✓ | ✗ |
| `x86_64-unknown-linux-gnu` (tier 1) | ✓ | ✓ | ✓ |
| **MacOSX targets:** | **build** | **run** | **jemalloc** |
| `x86_64-apple-darwin` (tier 1) | ✓ | ✓ | ✗ |
## Features
@ -88,9 +87,9 @@ Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in `tikv-jemallocator` by you, as defined in the Apache-2.0 license,
shall be dual licensed as above, without any additional terms or conditions.
[travis]: https://travis-ci.com/tikv/jemallocator
[Travis-CI Status]: https://travis-ci.com/tikv/jemallocator.svg?branch=master
[Latest Version]: https://img.shields.io/crates/v/tikv-jemallocator.svg
[crates.io]: https://crates.io/crates/tikv-jemallocator
[docs]: https://docs.rs/tikv-jemallocator/badge.svg
[docs.rs]: https://docs.rs/tikv-jemallocator/
[ci]: https://github.com/tikv/jemallocator/actions/workflows/main.yml/badge.svg
[github actions]: https://github.com/tikv/jemallocator/actions

View File

@ -24,44 +24,7 @@ else
export JEMALLOC_SYS_RUN_JEMALLOC_TESTS=1
fi
if [ "${VALGRIND}" = "1" ]
then
case "${TARGET}" in
"x86_64-unknown-linux-gnu")
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER=valgrind
;;
"x86_64-apple-darwin")
export CARGO_TARGET_X86_64_APPLE_DARWIN_RUNNER=valgrind
;;
*)
echo "Specify how to run valgrind for TARGET=${TARGET}"
exit 1
;;
esac
fi
if [ "${TARGET}" = "x86_64-unknown-linux-gnu" ] || [ "${TARGET}" = "x86_64-apple-darwin" ]
then
# Not using tee to avoid too much logs that exceeds travis' limit.
if ! cargo build -vv --target "${TARGET}" > build_no_std.txt 2>&1; then
tail -n 1024 build_no_std.txt
exit 1
fi
# Check that the no-std builds are not linked against a libc with default
# features or the `use_std` feature enabled:
! grep -q "default" build_no_std.txt
! grep -q "use_std" build_no_std.txt
RUST_SYS_ROOT=$(rustc --target="${TARGET}" --print sysroot)
RUST_LLVM_NM="${RUST_SYS_ROOT}/lib/rustlib/${TARGET}/bin/llvm-nm"
find target/ -iname '*jemalloc*.rlib' | while read -r rlib; do
echo "${RUST_LLVM_NM} ${rlib}"
! $RUST_LLVM_NM "${rlib}" | grep "std"
done
fi
cargo build --target "${TARGET}"
cargo test --target "${TARGET}"
cargo test --target "${TARGET}" --features profiling
cargo test --target "${TARGET}" --features debug
@ -103,7 +66,10 @@ case "${TARGET}" in
;;
esac
if rustc --version | grep -v nightly >/dev/null; then
# systest can't be built on nightly
cargo test --target "${TARGET}" -p systest
fi
cargo test --target "${TARGET}" --manifest-path jemallocator-global/Cargo.toml
cargo test --target "${TARGET}" \
--manifest-path jemallocator-global/Cargo.toml \

View File

@ -223,7 +223,7 @@ pub unsafe fn update<T>(name: &[u8], mut value: T) -> Result<T> {
/// which is undefined behavior.
pub unsafe fn read_str_mib(mib: &[usize]) -> Result<&'static [u8]> {
let ptr: *const c_char = read_mib(mib)?;
ptr2str(ptr)
Ok(ptr2str(ptr))
}
/// Uses the MIB `mib` as key to the _MALLCTL NAMESPACE_ and writes its `value`.
@ -274,7 +274,7 @@ pub unsafe fn update_str_mib(
value: &'static [u8],
) -> Result<&'static [u8]> {
let ptr: *const c_char = update_mib(mib, value.as_ptr() as *const c_char)?;
ptr2str(ptr)
Ok(ptr2str(ptr))
}
/// Uses the null-terminated string `name` as key to the _MALLCTL NAMESPACE_ and
@ -302,7 +302,7 @@ pub unsafe fn update_str_mib(
/// which is undefined behavior.
pub unsafe fn read_str(name: &[u8]) -> Result<&'static [u8]> {
let ptr: *const c_char = read(name)?;
ptr2str(ptr)
Ok(ptr2str(ptr))
}
/// Uses the null-terminated string `name` as key to the _MALLCTL NAMESPACE_ and
@ -344,7 +344,7 @@ pub unsafe fn update_str(
value: &'static [u8],
) -> Result<&'static [u8]> {
let ptr: *const c_char = update(name, value.as_ptr() as *const c_char)?;
ptr2str(ptr)
Ok(ptr2str(ptr))
}
/// Converts a non-empty null-terminated character string at `ptr` into a valid
@ -358,13 +358,13 @@ pub unsafe fn update_str(
///
/// If `ptr` does not point to a null-terminated character string the behavior
/// is undefined.
unsafe fn ptr2str(ptr: *const c_char) -> Result<&'static [u8]> {
unsafe fn ptr2str(ptr: *const c_char) -> &'static [u8] {
assert!(
!ptr.is_null(),
"attempt to convert a null-ptr to a UTF-8 string"
);
let len = libc::strlen(ptr);
Ok(slice::from_raw_parts(ptr as *const u8, len + 1))
slice::from_raw_parts(ptr as *const u8, len + 1)
}
fn validate_name(name: &[u8]) {
@ -396,16 +396,12 @@ mod tests {
{
let cstr = b"\0";
let rstr = ptr2str(cstr as *const _ as *const c_char);
assert!(rstr.is_ok());
let rstr = rstr.unwrap();
assert_eq!(rstr.len(), 1);
assert_eq!(rstr, b"\0");
}
{
let cstr = b"foo baaar\0";
let rstr = ptr2str(cstr as *const _ as *const c_char);
assert!(rstr.is_ok());
let rstr = rstr.unwrap();
assert_eq!(rstr.len(), b"foo baaar\0".len());
assert_eq!(rstr, b"foo baaar\0");
}

View File

@ -275,7 +275,7 @@ unsafe impl Alloc for Jemalloc {
/// and the size reported by this function should not be depended on,
/// since such behavior is entirely implementation-dependent.
///
/// # Unsafety
/// # Safety
///
/// `ptr` must have been allocated by `Jemalloc` and must not have been freed yet.
pub unsafe fn usable_size<T>(ptr: *const T) -> usize {