Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: Benchmarking saving cache data to gh-page - 2 #22

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 73 additions & 1 deletion .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,84 @@ jobs:
override: true
- name: Build docs
run: cargo doc
- name: Move documentation
run: mkdir -p pages/doc && mv target/doc/* pages/doc/
- name: Get previous benchmark data
if: ${{ github.ref == 'refs/heads/master' }}
run: |
echo "Fetching gh-pages branch"
git fetch origin gh-pages
echo "Checking out gh-pages branch"
git checkout gh-pages
echo "Copying data file from gh-pages to cache"
mkdir -p pages/dev && cp -r dev/* pages/dev/ || { echo "Failed to copy dev folder" ; exit 1; }
echo "Checking out current previous branch"
git checkout -
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/master' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./target/doc
publish_dir: ./pages

bench:
needs: build
if: ${{ github.repository_owner == 'bluerobotics' }}
runs-on: raspbian-armv7-kernel-5.10.33
steps:
- uses: actions/checkout@master
- uses: dtolnay/rust-toolchain@stable
- name: Rust | Cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "rust-cache"
shared-key: "benchmark"
- name: Get previous benchmark data
run: |
echo "Fetching gh-pages branch"
git fetch origin gh-pages

echo "Checking out gh-pages branch"
git checkout gh-pages

if [ ! -d "cache" ]; then
echo "Cache folder does not exist, creating it"
mkdir cache
fi

echo "Copying data file from gh-pages to cache"
cp dev/cache/benchmark-data.json cache/benchmark-data.json || { echo "Failed to copy data file" ; exit 1; }

echo "Checking out current preivous branch"
git checkout -
- name: Cargo Bench
run: cargo bench --jobs 1 --bench bench -- --output-format bencher | tee output.txt
- name: Compare results & store cached results
uses: benchmark-action/[email protected]
with:
tool: 'cargo'
output-file-path: output.txt
summary-always: true
alert-threshold: "110%"
fail-on-alert: true
external-data-json-path: ./cache/benchmark-data.json
skip-fetch-gh-pages: "true"
- name: Update data file
if: ${{ github.ref == 'refs/heads/master' }}
run: |
git config user.name "GitHub Actions Bot"
git config user.email "[email protected]"
git fetch origin gh-pages
git checkout gh-pages
if [ ! -d "dev/cache" ]; then
echo "Cache folder does not exist, creating it"
mkdir -p dev/cache
fi
cp cache/benchmark-data.json dev/cache/benchmark-data.json
tree cache
git add dev/cache/benchmark-data.json
git commit -m "Update benchmark-data file"
git push origin gh-pages

deploy:
needs: build
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.2.0"
edition = "2021"
license = "MIT"
description = "A Rust library for interacting with the AK09915 magnetometer"
homepage = "https://docs.bluerobotics.com/AK09915-rs/ak09915_rs"
homepage = "https://docs.bluerobotics.com/AK09915-rs/doc/ak09915_rs"
documentation = "https://docs.rs/ak09915_rs"
repository = "https://github.com/bluerobotics/AK09915-rs"
readme = "README.md"
Expand Down