2022-02-28 03:58:39 -08:00
|
|
|
name: Lint and Test
|
|
|
|
on:
|
|
|
|
push:
|
2022-05-09 12:30:49 -07:00
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
- dev
|
2022-02-28 03:58:39 -08:00
|
|
|
pull_request:
|
2022-05-09 12:37:58 -07:00
|
|
|
workflow_dispatch:
|
2022-02-28 03:58:39 -08:00
|
|
|
|
|
|
|
env:
|
|
|
|
CARGO_TERM_COLOR: always
|
2022-05-27 22:05:34 -07:00
|
|
|
SOLANA_VERSION: '1.9.14'
|
2022-05-23 12:46:18 -07:00
|
|
|
RUST_TOOLCHAIN: 1.60.0
|
2022-05-27 22:05:34 -07:00
|
|
|
LOG_PROGRAM: 'm43thNJ58XCjL798ZSq6JGAG1BnWskhdq5or6kcnfsD'
|
2022-02-28 03:58:39 -08:00
|
|
|
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: ./
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
lint:
|
|
|
|
name: Lint
|
2022-05-09 12:23:26 -07:00
|
|
|
if: github.actor != 'github-actions[bot]'
|
2022-05-23 12:46:18 -07:00
|
|
|
runs-on: ubuntu-latest
|
2022-02-28 03:58:39 -08:00
|
|
|
steps:
|
2022-05-09 12:23:26 -07:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
2022-05-18 08:16:14 -07:00
|
|
|
- name: Install Linux dependencies
|
|
|
|
run: sudo apt-get update && sudo apt-get install -y pkg-config build-essential libudev-dev
|
2022-05-23 12:46:18 -07:00
|
|
|
- name: Install Rust
|
2022-02-28 03:58:39 -08:00
|
|
|
uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
override: true
|
|
|
|
profile: minimal
|
|
|
|
toolchain: ${{ env.RUST_TOOLCHAIN }}
|
|
|
|
components: rustfmt, clippy
|
|
|
|
- name: Cache dependencies
|
|
|
|
uses: Swatinem/rust-cache@v1
|
|
|
|
- name: Run fmt
|
|
|
|
run: cargo fmt -- --check
|
|
|
|
- name: Run clippy
|
|
|
|
run: cargo clippy -- --deny=warnings --allow=clippy::style --allow=clippy::complexity
|
|
|
|
|
|
|
|
tests:
|
|
|
|
name: Test
|
2022-05-09 12:23:26 -07:00
|
|
|
if: github.actor != 'github-actions[bot]'
|
2022-02-28 03:58:39 -08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-05-09 12:23:26 -07:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
2022-02-28 03:58:39 -08:00
|
|
|
- name: Install Linux dependencies
|
|
|
|
run: sudo apt-get update && sudo apt-get install -y pkg-config build-essential libudev-dev
|
2022-05-23 12:46:18 -07:00
|
|
|
- name: Install Rust
|
2022-02-28 03:58:39 -08:00
|
|
|
uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
override: true
|
|
|
|
profile: minimal
|
|
|
|
toolchain: ${{ env.RUST_TOOLCHAIN }}
|
|
|
|
- name: Install Solana
|
|
|
|
run: |
|
|
|
|
sh -c "$(curl -sSfL https://release.solana.com/v${{ env.SOLANA_VERSION }}/install)"
|
|
|
|
echo "$HOME/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
|
|
|
|
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
|
|
|
|
solana --version
|
|
|
|
echo "Generating keypair..."
|
|
|
|
solana-keygen new -o "$HOME/.config/solana/id.json" --no-passphrase --silent
|
2022-03-13 07:18:50 -07:00
|
|
|
- name: Build all deps
|
|
|
|
run: cargo build-bpf
|
2022-05-09 12:23:26 -07:00
|
|
|
# Run bpf tests and output to runner and log
|
|
|
|
- name: Run tests
|
|
|
|
run: cargo test-bpf 2> >(tee raw-test-bpf.log >&2)
|
|
|
|
- name: Save raw log
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: raw-test-bpf
|
|
|
|
path: raw-test-bpf.log
|
2022-05-13 08:51:41 -07:00
|
|
|
|
2022-05-23 12:46:18 -07:00
|
|
|
# Download logs and process them
|
2022-05-09 12:23:26 -07:00
|
|
|
process-logs:
|
|
|
|
name: Process logs
|
2022-05-13 08:51:41 -07:00
|
|
|
if: github.actor != 'github-actions[bot]'
|
2022-05-09 12:23:26 -07:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: [lint, tests]
|
|
|
|
steps:
|
|
|
|
- name: Download raw log
|
|
|
|
uses: actions/download-artifact@v3
|
|
|
|
with:
|
|
|
|
name: raw-test-bpf
|
|
|
|
- name: Install deps
|
|
|
|
run: |
|
|
|
|
sudo apt-get install ripgrep
|
|
|
|
curl -Lo xsv.tar.gz "https://github.com/BurntSushi/xsv/releases/latest/download/xsv-0.13.0-x86_64-unknown-linux-musl.tar.gz"
|
|
|
|
sudo tar xf xsv.tar.gz -C /usr/local/bin
|
|
|
|
- name: Setup date input
|
|
|
|
id: date
|
|
|
|
run: echo "::set-output name=today::$(date +'%Y-%m-%d')"
|
|
|
|
- name: Process raw log
|
|
|
|
run: |
|
2022-05-13 08:14:30 -07:00
|
|
|
rg -oNI "(Instruction: |Program ${{ env.LOG_PROGRAM }} consumed).*$" raw-test-bpf.log \
|
|
|
|
| rg -U 'Instruction:.*\nProgram ${{ env.LOG_PROGRAM }}.*' \
|
2022-05-09 12:23:26 -07:00
|
|
|
| awk 'NR % 2 == 1 { o=$0 ; next } { print o " " $0 }' \
|
|
|
|
| sort | uniq -u | sort > cu-per-ix.log
|
|
|
|
- name: Clean up log
|
|
|
|
run: |
|
2022-05-13 08:14:30 -07:00
|
|
|
rg -N 'Instruction: (\w+) .* consumed (\d+) .*' cu-per-ix.log -r '${{ steps.date.outputs.today }},$1,$2' \
|
|
|
|
| uniq | xsv sort -s 2 -N -R \
|
|
|
|
| sort -t ',' -k 2,3 -u \
|
2022-05-09 12:23:26 -07:00
|
|
|
| sort > cu-per-ix-clean.log
|
|
|
|
- name: Save clean log
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: cu-per-ix-clean
|
|
|
|
path: cu-per-ix-clean.log
|