From 5044d9e3bccb975b2bfa9c54c3a53bc46af67eb5 Mon Sep 17 00:00:00 2001 From: Louis Hildebrand Date: Sat, 16 Dec 2023 22:55:05 -0500 Subject: [PATCH 1/7] Add more details to Cargo.toml --- Cargo.lock | 34 +++++++++++++++++----------------- Cargo.toml | 10 +++++++++- src/main.rs | 2 +- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d74b621..a364ab4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -269,6 +269,23 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "fungus-cli" +version = "1.0.0" +dependencies = [ + "anyhow", + "clap 4.1.13", + "criterion", + "itertools", + "logos", + "pretty_assertions", + "relative-path", + "rustc-hash", + "serde", + "serde_json", + "walkdir", +] + [[package]] name = "half" version = "1.8.2" @@ -418,23 +435,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "manual-analyzer" -version = "1.0.0" -dependencies = [ - "anyhow", - "clap 4.1.13", - "criterion", - "itertools", - "logos", - "pretty_assertions", - "relative-path", - "rustc-hash", - "serde", - "serde_json", - "walkdir", -] - [[package]] name = "memoffset" version = "0.8.0" diff --git a/Cargo.toml b/Cargo.toml index acfb83d..076df3e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,15 @@ [package] -name = "manual-analyzer" +name = "fungus-cli" version = "1.0.0" +authors = ["Gabriel Lacroix", "Kirollos Roufail", "Louis Hildebrand"] edition = "2021" +description = "FUNGUS is a tool for detecting similarities between ARMv7 assembly projects, for example, for introductory software assignments." +readme = "README.md" +homepage = "https://github.com/Project-Fungus" +repository = "https://github.com/Project-Fungus/fungus-cli" +license = "MIT" +keywords = ["plagiarism", "copy_detection", "assignments"] +categories = ["command-line-utilities"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/main.rs b/src/main.rs index 90af7e6..c5491ca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,7 @@ use std::{ }; use walkdir::WalkDir; -use manual_analyzer::{ +use fungus_cli::{ detect_plagiarism, lexing::TokenizingStrategy, output::{Output, Warning, WarningType}, From da089cfaf93dd9d3377574b5ba90139e90c5ef2a Mon Sep 17 00:00:00 2001 From: Louis Hildebrand Date: Sun, 17 Dec 2023 19:31:36 -0500 Subject: [PATCH 2/7] Add installation instructions to README.md --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 1dc2089..b058805 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,22 @@ FUNGUS is a tool for detecting similarities between ARMv7 assembly projects, for FUNGUS is inspired by Stanford's [Measure of Software Similarity](https://theory.stanford.edu/~aiken/moss/) (Moss). At its core, it uses the same algorithm, winnowing, described in [this paper](https://theory.stanford.edu/~aiken/publications/papers/sigmod03.pdf). +## Installation + +### Binary + +1. Go to the [Releases page](https://github.com/Project-Fungus/fungus-cli/releases). +2. Download the artifact for your platform. +3. Add the command to your `PATH`. + +Run `fungus --version` to check that the installation was successful. + +### Building From Source + +1. Clone this repository or download the code. +2. Ensure you have [installed Cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html). +3. Run `cargo build --release`. The binary will be placed in the `target/release/` directory. + ## Key Inputs ### Root From 0b71506f434ecfc2cd70b32111a87f523779bf20 Mon Sep 17 00:00:00 2001 From: Louis Hildebrand Date: Sun, 17 Dec 2023 19:32:39 -0500 Subject: [PATCH 3/7] Add release option to the CI/CD workflow --- .github/workflows/rust.yml | 99 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cb11da3..3724f63 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -5,15 +5,20 @@ on: branches: [ "main" ] pull_request: branches: [ "main" ] + workflow_dispatch: + inputs: + release: + description: 'Build for release?' + required: true + default: false + type: boolean env: CARGO_TERM_COLOR: always jobs: - build: - + test: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v3 - name: Build @@ -24,3 +29,91 @@ jobs: run: cargo clippy -- -Dclippy::complexity -Dclippy::perf -Dclippy::suspicious -Dclippy::style - name: Format run: cargo fmt --check + # Based on the release workflow for hyperfine: + # https://github.com/sharkdp/hyperfine/blob/24a0d5da1bff11567bbf307315d11cb0e10733ec/.github/workflows/CICD.yml + build_release: + if: ${{ inputs.release }} + needs: test + runs-on: ${{ matrix.job.os }} + strategy: + fail-fast: false + matrix: + job: + - { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + - { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true } + - { target: arm-unknown-linux-musleabihf, os: ubuntu-20.04, use-cross: true } + - { target: i686-pc-windows-msvc , os: windows-2019 } + - { target: i686-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + - { target: i686-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + - { target: x86_64-apple-darwin , os: macos-12 } + - { target: x86_64-pc-windows-msvc , os: windows-2019 } + - { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } + - { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } + env: + BUILD_CMD: cargo + steps: + - name: Checkout source code + uses: actions/checkout@v4 + + - name: Install prerequisites + shell: bash + run: | + case ${{ matrix.job.target }} in + arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;; + aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;; + esac + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.job.target }} + + - name: Install cross + if: matrix.job.use-cross + uses: taiki-e/install-action@v2 + with: + tool: cross + + - name: Overwrite build command env variable + if: matrix.job.use-cross + shell: bash + run: echo "BUILD_CMD=cross" >> $GITHUB_ENV + + - name: Show version information (Rust, cargo, GCC) + shell: bash + run: | + gcc --version || true + rustup -V + rustup toolchain list + rustup default + cargo -V + rustc -V + + - name: Build + shell: bash + run: $BUILD_CMD build --locked --release --target=${{ matrix.job.target }} + + - name: Set binary name & path + id: bin + shell: bash + run: | + # Figure out suffix of binary + EXE_suffix="" + case ${{ matrix.job.target }} in + *-pc-windows-*) EXE_suffix=".exe" ;; + esac; + + # Setup paths + BIN_NAME="${{ needs.crate_metadata.outputs.name }}${EXE_suffix}" + BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}" + + # Let subsequent steps know where to find the binary + echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT + echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_OUTPUT + + - name: Upload binary + uses: actions/upload-artifact@v4 + with: + name: fungus-${{ matrix.job.target }} + path: ${{ env.BIN_PATH }} + if-no-files-found: error From 0f38d48ca35f7f837a23d25c5f9835229be6a5e4 Mon Sep 17 00:00:00 2001 From: Louis Hildebrand Date: Sun, 17 Dec 2023 19:35:35 -0500 Subject: [PATCH 4/7] Fix failing doctest --- src/identity_hash.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/identity_hash.rs b/src/identity_hash.rs index 39a6b3b..256a662 100644 --- a/src/identity_hash.rs +++ b/src/identity_hash.rs @@ -5,7 +5,7 @@ //! //! ```rust //! # fn main() { -//! use manual_analyzer::identity_hash::{IdentityHashMap, IdentityHashSet}; +//! use fungus_cli::identity_hash::{IdentityHashMap, IdentityHashSet}; //! let mut map: IdentityHashMap = IdentityHashMap::default(); //! map.insert(22, 44); //! let mut set: IdentityHashSet = IdentityHashSet::default(); From 1d219e35c0244dd88eea06e2112b0a5632812a8e Mon Sep 17 00:00:00 2001 From: Louis Hildebrand Date: Sun, 17 Dec 2023 19:40:03 -0500 Subject: [PATCH 5/7] Make release pipeline always run to test it --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3724f63..e1aa4c8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -32,7 +32,7 @@ jobs: # Based on the release workflow for hyperfine: # https://github.com/sharkdp/hyperfine/blob/24a0d5da1bff11567bbf307315d11cb0e10733ec/.github/workflows/CICD.yml build_release: - if: ${{ inputs.release }} + # if: ${{ inputs.release }} needs: test runs-on: ${{ matrix.job.os }} strategy: From afcd63728318c33fcb85bca907f45a2bf62b2851 Mon Sep 17 00:00:00 2001 From: Louis Hildebrand Date: Sun, 17 Dec 2023 19:52:59 -0500 Subject: [PATCH 6/7] Fix release pipeline --- .github/workflows/rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e1aa4c8..531aea6 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -104,7 +104,7 @@ jobs: esac; # Setup paths - BIN_NAME="${{ needs.crate_metadata.outputs.name }}${EXE_suffix}" + BIN_NAME="fungus${EXE_suffix}" BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}" # Let subsequent steps know where to find the binary @@ -115,5 +115,5 @@ jobs: uses: actions/upload-artifact@v4 with: name: fungus-${{ matrix.job.target }} - path: ${{ env.BIN_PATH }} + path: ${{ steps.bin.outputs.BIN_PATH }} if-no-files-found: error From 44ea8a469365da8b767fb21c575d408df7263dcb Mon Sep 17 00:00:00 2001 From: Louis Hildebrand Date: Sun, 17 Dec 2023 21:56:19 -0500 Subject: [PATCH 7/7] Only build for release on workflow dispatch --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 531aea6..c25a28b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -32,7 +32,7 @@ jobs: # Based on the release workflow for hyperfine: # https://github.com/sharkdp/hyperfine/blob/24a0d5da1bff11567bbf307315d11cb0e10733ec/.github/workflows/CICD.yml build_release: - # if: ${{ inputs.release }} + if: ${{ inputs.release }} needs: test runs-on: ${{ matrix.job.os }} strategy: