Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Add be…
Browse files Browse the repository at this point in the history
…nchmark support to CI
  • Loading branch information
jaymell committed Jul 1, 2023
1 parent 8420228 commit 986ee4c
Showing 1 changed file with 163 additions and 159 deletions.
322 changes: 163 additions & 159 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,135 +11,135 @@ env:
REDIS_RS_REDIS_JSON_PATH: "/tmp/librejson.so"

jobs:
# build:

# runs-on: ubuntu-latest
# strategy:
# fail-fast: false
# matrix:
# redis:
# - 6.2.4
# - 7.0.0
# rust:
# - stable
# - beta
# - nightly
# - 1.60.0

# steps:

# - name: Cache redis
# id: cache-redis
# uses: actions/cache@v3
# with:
# path: |
# ~/redis-cli
# ~/redis-server
# key: ${{ runner.os }}-${{ matrix.redis }}-redis

# - name: Cache RedisJSON
# id: cache-redisjson
# uses: actions/cache@v3
# with:
# path: |
# /tmp/librejson.so
# key: ${{ runner.os }}-redisjson

# - name: Install redis
# if: steps.cache-redis.outputs.cache-hit != 'true'
# run: |
# sudo apt-get update
# wget https://github.com/redis/redis/archive/${{ matrix.redis }}.tar.gz;
# tar -xzvf ${{ matrix.redis }}.tar.gz;
# pushd redis-${{ matrix.redis }} && BUILD_TLS=yes make && sudo mv src/redis-server src/redis-cli $HOME && popd;
# echo $PATH

# - name: set PATH
# run: |
# echo "$HOME" >> $GITHUB_PATH

# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: ${{ matrix.rust }}
# override: true
# components: rustfmt

# - uses: Swatinem/rust-cache@v1

# - uses: actions/checkout@v3

# - name: Run tests
# run: make test

# - name: Checkout RedisJSON
# if: steps.cache-redisjson.outputs.cache-hit != 'true'
# uses: actions/checkout@v2
# with:
# repository: "RedisJSON/RedisJSON"
# path: "./__ci/redis-json"
# set-safe-directory: false

# # When cargo is invoked, it'll go up many directories to see if it can find a workspace
# # This will avoid this issue in what is admittedly a bit of a janky but still fully functional way
# #
# # 1. Copy the untouched file (into Cargo.toml.actual)
# # 2. Exclude ./__ci/redis-json from the workspace
# # (preventing it from being compiled as a workspace module)
# # 3. Build RedisJSON
# # 4. Move the built RedisJSON Module (librejson.so) to /tmp
# # 5. Restore Cargo.toml to its untouched state
# # 6. Remove the RedisJSON Source code so it doesn't interfere with tests
# #
# # This shouldn't cause issues in the future so long as no profiles or patches
# # are applied to the workspace Cargo.toml file
# - name: Compile RedisJSON
# if: steps.cache-redisjson.outputs.cache-hit != 'true'
# run: |
# cp ./Cargo.toml ./Cargo.toml.actual
# echo $'\nexclude = [\"./__ci/redis-json\"]' >> Cargo.toml
# cargo +stable build --release --manifest-path ./__ci/redis-json/Cargo.toml
# mv ./__ci/redis-json/target/release/librejson.so /tmp/librejson.so
# rm ./Cargo.toml; mv ./Cargo.toml.actual ./Cargo.toml
# rm -rf ./__ci/redis-json

# - name: Run module-specific tests
# run: make test-module

# - name: Check features
# run: |
# cargo check --benches --all-features
# cargo check --no-default-features --features tokio-comp
# # Remove dev-dependencies so they do not enable features accidentally
# # https://github.com/rust-lang/cargo/issues/4664
# sed -i '/dev-dependencies/,/dev-dependencies/d' Cargo.toml
# cargo check --all-features

# cargo check --no-default-features --features async-std-comp

# lint:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: stable
# override: true
# components: rustfmt, clippy
# - uses: Swatinem/rust-cache@v1
# - uses: actions-rs/cargo@v1
# with:
# command: fmt
# args: --all -- --check
# - uses: actions-rs/cargo@v1
# with:
# command: clippy
# args: --all-features --all-targets -- -D warnings
# - name: doc
# run: cargo doc --no-deps --document-private-items
# env:
# RUSTDOCFLAGS: -Dwarnings
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
redis:
- 6.2.4
- 7.0.0
rust:
- stable
- beta
- nightly
- 1.60.0

steps:

- name: Cache redis
id: cache-redis
uses: actions/cache@v3
with:
path: |
~/redis-cli
~/redis-server
key: ${{ runner.os }}-${{ matrix.redis }}-redis

- name: Cache RedisJSON
id: cache-redisjson
uses: actions/cache@v3
with:
path: |
/tmp/librejson.so
key: ${{ runner.os }}-redisjson

- name: Install redis
if: steps.cache-redis.outputs.cache-hit != 'true'
run: |
sudo apt-get update
wget https://github.com/redis/redis/archive/${{ matrix.redis }}.tar.gz;
tar -xzvf ${{ matrix.redis }}.tar.gz;
pushd redis-${{ matrix.redis }} && BUILD_TLS=yes make && sudo mv src/redis-server src/redis-cli $HOME && popd;
echo $PATH
- name: set PATH
run: |
echo "$HOME" >> $GITHUB_PATH
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt

- uses: Swatinem/rust-cache@v1

- uses: actions/checkout@v3

- name: Run tests
run: make test

- name: Checkout RedisJSON
if: steps.cache-redisjson.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: "RedisJSON/RedisJSON"
path: "./__ci/redis-json"
set-safe-directory: false

# When cargo is invoked, it'll go up many directories to see if it can find a workspace
# This will avoid this issue in what is admittedly a bit of a janky but still fully functional way
#
# 1. Copy the untouched file (into Cargo.toml.actual)
# 2. Exclude ./__ci/redis-json from the workspace
# (preventing it from being compiled as a workspace module)
# 3. Build RedisJSON
# 4. Move the built RedisJSON Module (librejson.so) to /tmp
# 5. Restore Cargo.toml to its untouched state
# 6. Remove the RedisJSON Source code so it doesn't interfere with tests
#
# This shouldn't cause issues in the future so long as no profiles or patches
# are applied to the workspace Cargo.toml file
- name: Compile RedisJSON
if: steps.cache-redisjson.outputs.cache-hit != 'true'
run: |
cp ./Cargo.toml ./Cargo.toml.actual
echo $'\nexclude = [\"./__ci/redis-json\"]' >> Cargo.toml
cargo +stable build --release --manifest-path ./__ci/redis-json/Cargo.toml
mv ./__ci/redis-json/target/release/librejson.so /tmp/librejson.so
rm ./Cargo.toml; mv ./Cargo.toml.actual ./Cargo.toml
rm -rf ./__ci/redis-json
- name: Run module-specific tests
run: make test-module

- name: Check features
run: |
cargo check --benches --all-features
cargo check --no-default-features --features tokio-comp
# Remove dev-dependencies so they do not enable features accidentally
# https://github.com/rust-lang/cargo/issues/4664
sed -i '/dev-dependencies/,/dev-dependencies/d' Cargo.toml
cargo check --all-features
cargo check --no-default-features --features async-std-comp
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features --all-targets -- -D warnings
- name: doc
run: cargo doc --no-deps --document-private-items
env:
RUSTDOCFLAGS: -Dwarnings

benchmark:
name: Benchmark
Expand All @@ -149,39 +149,43 @@ jobs:
rust_ver: stable
steps:

# - name: Cache redis
# id: cache-redis
# uses: actions/cache@v3
# with:
# path: |
# ~/redis-cli
# ~/redis-server
# key: ${{ runner.os }}-${{ env.redis_ver }}-redis

# - name: Install redis
# if: steps.cache-redis.outputs.cache-hit != 'true'
# run: |
# sudo apt-get update
# wget https://github.com/redis/redis/archive/${{ env.redis_ver }}.tar.gz;
# tar -xzvf ${{ env.redis_ver }}.tar.gz;
# pushd redis-${{ env.redis_ver }} && BUILD_TLS=yes make && sudo mv src/redis-server src/redis-cli /usr/bin/ && popd;
# echo $PATH

# - name: set PATH
# run: |
# echo "$HOME" >> $GITHUB_PATH

# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with:
# toolchain: ${{ env.rust_ver }}
# override: true

# - uses: Swatinem/rust-cache@v1
- name: Cache redis
id: cache-redis
uses: actions/cache@v3
with:
path: |
~/redis-cli
~/redis-server
key: ${{ runner.os }}-${{ env.redis_ver }}-redis

- name: Install redis
if: steps.cache-redis.outputs.cache-hit != 'true'
run: |
sudo apt-get update
wget https://github.com/redis/redis/archive/${{ env.redis_ver }}.tar.gz;
tar -xzvf ${{ env.redis_ver }}.tar.gz;
pushd redis-${{ env.redis_ver }} && BUILD_TLS=yes make && sudo mv src/redis-server src/redis-cli /usr/bin/ && popd;
echo $PATH
- name: set PATH
run: |
echo "$HOME" >> $GITHUB_PATH
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.rust_ver }}
override: true

- uses: Swatinem/rust-cache@v1

- uses: actions/checkout@v3

- name: Benchmark
run: |
cargo install critcmp
cargo bench --all-features -- --save-baseline changes
git fetch
git checkout ${{ github.base_ref }}
git checkout ${{ github.base_ref }}
cargo bench --all-features -- --save-baseline base
critcmp base changes

0 comments on commit 986ee4c

Please sign in to comment.