Skip to content

Commit

Permalink
Rewrite in Rust (#2)
Browse files Browse the repository at this point in the history
* Initial setup for Rust code

* Port CICKind to Rust

* Literal port of python code for checksum

* Write tests for calculateChecksum

* Port detect

* Cleanup CICKind

* Wire up function bindings

* yeet python logic

* Add name attribute

* Start fixing CI

* ci for rust

* cargo fmt

* clippy

* changelog and readme

* some docs

* fmt

* fix ci?
  • Loading branch information
AngheloAlf authored Dec 15, 2023
1 parent 84d8640 commit 5d005ea
Show file tree
Hide file tree
Showing 24 changed files with 1,105 additions and 329 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- name: Install Dependencies
run: |
pip3 install mypy -U
pip3 install -U mypy
- name: mypy
run: mypy --show-column-numbers --hide-error-context .
42 changes: 42 additions & 0 deletions .github/workflows/publish_crate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build and upload Rust crate

# Build on every branch push, tag push, and pull request change:
on: [push, pull_request]

jobs:
build_rust:
name: Build Rust stuff and run Rust tests
runs-on: ubuntu-latest

steps:
- name: Checkout reposistory
uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true

- name: Check format
run: cargo fmt --check

- name: Setup clippy
run: rustup component add clippy

- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Build Rust package
run: cargo build --release --workspace

- name: Build Rust tests
run: cargo test --workspace

- name: Publish dry run
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
run: cargo publish --dry-run

- name: Upload crate
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Dependencies
run: |
pip3 install -U maturin
- name: Install local ipl3checksum
run: pip install .

Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/tests_other_repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ name: Test other repo
on: [push, pull_request]

jobs:
build_repo:
name: Test other repo
test_other_repo_py:
name: Test other repo (Python)
runs-on: ubuntu-latest

strategy:
Expand All @@ -15,6 +15,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Dependencies
run: |
python3 -m pip install -U maturin
- name: Install local ipl3checksum
run: python3 -m pip install .

Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rust-analyzer.cargo.features": [
"c_bindings",
"python_bindings"
]
}
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add Rust support
- New static method `CICKind.fromHashMd5`.
- Returns a CIC kind based on the passed md5 hash.

### Changed

- Library was reimplemented in Rust, allowing faster runtime calculation.
- The Python API is still the same

### Fixed

- Fix links in `CHANGELOG.md`

## [1.0.1] - 2023-09-21
Expand Down
Loading

0 comments on commit 5d005ea

Please sign in to comment.