Skip to content

Commit 15f7956

Browse files
Add types (#1)
* scaffold * setup coverage and publish * cleanup tests * spike on initial items * cleanup artifact format * remove unnecessary imports * add notes * remove extra file * add crate comment * add description * call components * remove unused dep * add README comment
1 parent 89c4395 commit 15f7956

File tree

16 files changed

+2389
-0
lines changed

16 files changed

+2389
-0
lines changed

.github/actions/setup/action.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: 'Setup'
2+
inputs:
3+
rust-version:
4+
description: 'The version of Rust to use in cache keys'
5+
required: true
6+
protoc-version:
7+
description: 'The version of protoc to use in cache keys'
8+
default: '28.2'
9+
required: false
10+
runs:
11+
using: 'composite'
12+
steps:
13+
- name: Cache cargo registry
14+
uses: actions/cache@v4
15+
with:
16+
path: ~/.cargo/registry
17+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}-${{ inputs.rust-version }}
18+
- name: Cache cargo index
19+
uses: actions/cache@v4
20+
with:
21+
path: ~/.cargo/git
22+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}-${{ inputs.rust-version }}
23+
- name: Cache cargo target
24+
uses: actions/cache@v4
25+
with:
26+
path: target
27+
key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}-${{ inputs.rust-version }}
28+
- name: Create protoc directory
29+
run: mkdir -p ~/protoc
30+
shell: bash
31+
- name: Cache protoc
32+
id: cache-protoc
33+
uses: actions/cache@v4
34+
with:
35+
path: ~/protoc
36+
key: ${{ runner.os }}-protoc-${{ inputs.protoc-version }}
37+
- name: Install protoc
38+
if: steps.cache-protoc.outputs.cache-hit != 'true'
39+
run: |
40+
curl -L -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v${{ inputs.protoc-version }}/protoc-${{ inputs.protoc-version }}-linux-x86_64.zip
41+
unzip protoc.zip -d ~/protoc
42+
rm protoc.zip
43+
shell: bash
44+
- name: Add protoc to PATH
45+
run: echo "$HOME/protoc/bin" >> $GITHUB_PATH
46+
shell: bash

.github/workflows/coverage.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Coverage
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
All:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
- name: Get Rust version
18+
id: rust-version
19+
run: echo "rust_version=$(rustc --version)" >> "$GITHUB_OUTPUT"
20+
- name: Run setup
21+
uses: ./.github/actions/setup
22+
with:
23+
rust-version: ${{ steps.rust-version.outputs.rust_version}}
24+
- name: Install cargo-llvm-cov
25+
uses: taiki-e/install-action@cargo-llvm-cov
26+
- name: Generate coverage report
27+
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
28+
- name: Upload coverage to Codecov
29+
uses: codecov/codecov-action@v4
30+
with:
31+
files: lcov.info
32+
fail_ci_if_error: true
33+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/publish.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
All:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
- name: Get Rust version
14+
id: rust-version
15+
run: echo "rust_version=$(rustc --version)" >> "$GITHUB_OUTPUT"
16+
- name: Run setup
17+
uses: ./.github/actions/setup
18+
with:
19+
rust-version: ${{ steps.rust-version.outputs.rust_version}}
20+
- name: Publish types
21+
run: cargo publish --manifest-path types/Cargo.toml
22+
continue-on-error: true
23+
env:
24+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/tests.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
UDEPS_VERSION: 0.1.50
11+
12+
jobs:
13+
All:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
- name: Get Rust version
19+
id: rust-version
20+
run: echo "rust_version=$(rustc --version)" >> "$GITHUB_OUTPUT"
21+
- name: Run setup
22+
uses: ./.github/actions/setup
23+
with:
24+
rust-version: ${{ steps.rust-version.outputs.rust_version}}
25+
- name: Lint
26+
run: cargo clippy --all-targets --all-features -- -D warnings
27+
- name: Fmt
28+
run: cargo fmt --all -- --check
29+
- name: Check docs
30+
run: cargo doc --no-deps --document-private-items
31+
env:
32+
RUSTDOCFLAGS: "-D warnings"
33+
- name: Run tests
34+
run: cargo test --verbose
35+
36+
Dependencies:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
- name: Install nightly Rust toolchain
42+
run: rustup toolchain install nightly
43+
- name: Get Rust version
44+
id: rust-version
45+
run: echo "rust_version=$(rustc +nightly --version)" >> "$GITHUB_OUTPUT"
46+
- name: Run setup
47+
uses: ./.github/actions/setup
48+
with:
49+
rust-version: ${{ steps.rust-version.outputs.rust_version}}
50+
- name: Cache cargo-udeps
51+
id: cargo-udeps-cache
52+
uses: actions/cache@v4
53+
with:
54+
path: ~/.cargo/bin/cargo-udeps
55+
key: ${{ runner.os }}-${{ env.UDEPS_VERSION }}-cargo-udeps-${{ steps.rust-version.outputs.rust_version }}
56+
- name: Install cargo-udeps
57+
if: steps.cargo-udeps-cache.outputs.cache-hit != 'true'
58+
run: cargo +nightly install cargo-udeps --version ${{ env.UDEPS_VERSION }}
59+
- name: Check for unused dependencies
60+
run: cargo +nightly udeps --all-targets
61+
62+
WASM:
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Checkout repository
66+
uses: actions/checkout@v4
67+
- name: Get Rust version
68+
id: rust-version
69+
run: echo "rust_version=$(rustc --version)" >> "$GITHUB_OUTPUT"
70+
- name: Run setup
71+
uses: ./.github/actions/setup
72+
with:
73+
rust-version: ${{ steps.rust-version.outputs.rust_version}}
74+
- name: Add WASM target
75+
run: rustup target add wasm32-unknown-unknown
76+
- name: Build types
77+
run: cargo build --target wasm32-unknown-unknown --release --manifest-path types/Cargo.toml && du -h target/wasm32-unknown-unknown/release/alto_types.wasm

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.swp
2+
*.DS_Store
3+
/target
4+
*.vscode

0 commit comments

Comments
 (0)