Skip to content
Merged
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
29 changes: 29 additions & 0 deletions .github/actions/install-sbpf/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# cspell:word sbpf
---
description: 'Install sbpf CLI'
inputs:
sbpf-cli-revision:
description: 'sbpf CLI rev (git commit hash, tag, or branch) to install'
required: true
name: 'Install sbpf CLI'
runs:
steps:
- id: 'cache-sbpf'
name: 'Cache sbpf CLI'
uses: 'actions/cache@v5'
with:
key: 'sbpf-cli-${{ inputs.sbpf-cli-revision }}-${{ runner.os }}-${{
runner.arch }}'
path: '~/.cargo/bin/sbpf'
- if: 'steps.cache-sbpf.outputs.cache-hit != ''true'''
name: 'Install sbpf CLI'
run: >-
cargo install
--git https://github.com/blueshift-gg/sbpf.git
--rev ${{ inputs.sbpf-cli-revision }}
shell: 'sh'
- name: 'Verify sbpf CLI'
run: 'sbpf --version'
shell: 'sh'
using: 'composite'
...
7 changes: 7 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ env:
NODE_VERSION: '25'
PRE_COMMIT_VERSION: '4.5.1'
PYTHON_VERSION: '3.14.3'
RUST_VERSION: 'stable'
jobs:
lint:
env:
Expand All @@ -28,6 +29,12 @@ jobs:
steps.apt-cache.outputs.cache-hit == 'true'
run: 'echo "$HOME/.local/bin" >> "$GITHUB_PATH"'
- uses: 'actions/checkout@v6'
- uses: 'dtolnay/rust-toolchain@stable'
with:
components: 'clippy, rustfmt'
- uses: 'Swatinem/rust-cache@v2'
with:
shared-key: 'rust-${{ runner.os }}'
- uses: 'actions/setup-node@v6'
with:
node-version: '${{ env.NODE_VERSION }}'
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# cspell:word sbpf
---
env:
# https://github.com/blueshift-gg/sbpf/pull/109
SBPF_CLI_REV: '5583e2b167e540b0143311aceb62afd98bfaa67b'
jobs:
test:
name: 'Test'
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@v6'
- uses: 'dtolnay/rust-toolchain@stable'
- uses: 'Swatinem/rust-cache@v2'
with:
shared-key: 'rust-${{ runner.os }}'
- uses: './.github/actions/install-sbpf'
with:
sbpf-cli-revision: '${{ env.SBPF_CLI_REV }}'
- name: 'Build assembly'
run: 'make asm'
- name: 'Run tests'
run: 'make test'
name: 'Test'
'on':
pull_request: null
...
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
.PHONY: all
.PHONY: asm
.PHONY: clean
.PHONY: lint
.PHONY: test

SBPF_ARCH ?= v0
DEPLOY_DIR ?= target/asm

all: docs-prettier pre-commit-lint
all: lint test
clean:
cargo clean
rm -rf docs/node_modules docs/.vitepress/cache docs/.vitepress/dist
rm -rf $(DEPLOY_DIR)

# Run test cases.
test: asm
Expand Down Expand Up @@ -37,6 +40,9 @@ docs-prod:
&& npx vitepress build \
&& (sleep 1 && open http://localhost:4173 &) && npx vitepress preview

# Run all lint checks.
lint: pre-commit-lint docs-prettier

# Run pre-commit lint checks on all files.
pre-commit-lint:
pre-commit run --config cfg/pre-commit/lint.yml --all-files
3 changes: 3 additions & 0 deletions cfg/dictionary.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
clippy
clrs
codegen
dasmac
dropset
dtolnay
globl
idents
insn
Expand All @@ -16,5 +18,6 @@ repr
sbpf
shiki
solana
swatinem
vite
vitepress
15 changes: 15 additions & 0 deletions cfg/pre-commit/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ repos:
id: 'pretty-format-json'
repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: 'v6.0.0'
- hooks:
- entry: 'cargo fmt --'
id: 'rustfmt'
language: 'system'
name: 'rustfmt'
types:
- 'rust'
- entry: 'cargo clippy --all-targets -- -D warnings'
id: 'clippy'
language: 'system'
name: 'clippy'
pass_filenames: false
types:
- 'rust'
repo: 'local'
- hooks:
- id: 'checkmake'
repo: 'https://github.com/checkmake/checkmake.git'
Expand Down
8 changes: 7 additions & 1 deletion macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ pub fn constant_group(input: TokenStream) -> TokenStream {
pub fn discriminant_enum(attr: TokenStream, item: TokenStream) -> TokenStream {
let target = parse_macro_input!(attr as LitStr);
let input = parse_macro_input!(item as syn::ItemEnum);
TokenStream::from(enum_to_asm::expand(&target.value(), "DISC", 0, "u8", &input))
TokenStream::from(enum_to_asm::expand(
&target.value(),
"DISC",
0,
"u8",
&input,
))
}

/// Attribute macro for error code enums.
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading