diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 4861c696c0..785d2b1ed6 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -1,6 +1,9 @@ name: Test all targets -on: [push, pull_request] +on: + push: + pull_request: + workflow_dispatch: permissions: contents: write @@ -39,13 +42,10 @@ jobs: 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 @@ -55,18 +55,40 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./pages - bench: - needs: build + cross-compile-bench: + needs: build + if: ${{ github.repository_owner == 'bluerobotics' }} + runs-on: ubuntu-latest + strategy: + matrix: + TARGET: [armv7-unknown-linux-gnueabihf] + steps: + - uses: actions/checkout@master + - name: Cross-compile benchmark + uses: houseabsolute/actions-rust-cross@v0.0.14 + with: + target: ${{ matrix.TARGET }} + args: "bench --no-run --bench bench" + - name: Upload benchmark binary + uses: actions/upload-artifact@v3 + with: + name: benchmark-binary + path: target/${{ matrix.TARGET }}/release/deps/bench-* + retention-days: 1 + + run-bench: + needs: cross-compile-bench 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 + - name: Download benchmark binary + uses: actions/download-artifact@v3 with: - prefix-key: "rust-cache" - shared-key: "benchmark" + name: benchmark-binary + path: ./bench-binary + - name: Make benchmark executable + run: chmod +x ./bench-binary/* - name: Get previous benchmark data run: | echo "Fetching gh-pages branch" @@ -83,10 +105,12 @@ jobs: 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" + echo "Checking out current previous branch" git checkout - - - name: Cargo Bench - run: cargo bench --jobs 1 --bench bench -- --output-format bencher | tee output.txt || { echo "Benchmark failed"; exit 1; } + - name: Run benchmark + run: | + BENCH_BINARY=$(find ./bench-binary -type f -executable) + $BENCH_BINARY --jobs 1 --bench bench -- --output-format bencher | tee output.txt || { echo "Benchmark failed"; exit 1; } - name: Compare results & store cached results uses: benchmark-action/github-action-benchmark@v1.18.0 with: @@ -102,20 +126,14 @@ jobs: run: | git config user.name "GitHub Actions Bot" git config user.email "actions@github.com" - 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 @@ -144,4 +162,4 @@ jobs: - name: Publish to crates.io uses: katyo/publish-crates@v1 with: - registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} + registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} \ No newline at end of file