diff --git a/.github/actions/setup-rust/action.yaml b/.github/actions/setup-rust/action.yaml new file mode 100644 index 000000000..c3edf3298 --- /dev/null +++ b/.github/actions/setup-rust/action.yaml @@ -0,0 +1,27 @@ +name: 'Setup Rust Environment' +description: 'Sets up Rust and caches dependencies' +inputs: + components: + description: "Rust components to install (e.g., rustfmt, clippy)" + required: false + default: "" +runs: + using: "composite" + steps: + - name: Extract Rust version from rust-toolchain.toml + id: rustver + shell: bash + run: | + rust_version=$(grep -E '^[[:space:]]*channel[[:space:]]*=' rust-toolchain.toml \ + | sed -E 's/.*"([^"]+)".*/\1/') + echo "rust_version=${rust_version}" >>"$GITHUB_OUTPUT" + echo "Rust version: ${rust_version}" + + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ steps.rustver.outputs.rust_version }} + components: ${{ inputs.components }} + + - name: Add Rust Cache + uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/pr_main.yaml b/.github/workflows/pr_main.yaml new file mode 100644 index 000000000..46aa1d907 --- /dev/null +++ b/.github/workflows/pr_main.yaml @@ -0,0 +1,55 @@ +name: Integration Tests +on: + push: + branches: ["main"] + merge_group: + pull_request: + branches: ["**"] + +permissions: + contents: read + actions: write + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + lint: + # "Lint" is a required check, don't change the name + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Setup Rust Environment + uses: ./.github/actions/setup-rust + with: + components: rustfmt, clippy + + - name: Run cargo check + run: cargo check + + - name: Run cargo clippy + run: | + cargo clippy -- -D warnings + + - name: Run cargo fmt + run: | + cargo fmt --all -- --check + + test: + # "Test" is a required check, don't change the name + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Setup Rust Environment + uses: ./.github/actions/setup-rust + + - name: Run tests + run: | + make test-no-compile diff --git a/.gitignore b/.gitignore index 361f8f81a..ea8c4bf7f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ /target -/program_artifacts diff --git a/Makefile b/Makefile index 2aa0d1343..0c18abfc5 100644 --- a/Makefile +++ b/Makefile @@ -42,11 +42,13 @@ clean: -rm -rf $(RUST_ARTIFACTS_DIR) mkdir -p $(RUST_ARTIFACTS_DIR) -test: compile-programs - cargo test +test: compile-programs test-no-compile test-asm: compile-programs-asm cargo test --test asm test-rust: compile-programs-rust cargo test --test rust + +test-no-compile: + cargo test diff --git a/program_artifacts/asm/basic_program.elf b/program_artifacts/asm/basic_program.elf new file mode 100755 index 000000000..55712514d Binary files /dev/null and b/program_artifacts/asm/basic_program.elf differ diff --git a/program_artifacts/rust/basic_rust.elf b/program_artifacts/rust/basic_rust.elf new file mode 100755 index 000000000..0427f1f37 Binary files /dev/null and b/program_artifacts/rust/basic_rust.elf differ diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 000000000..2ce412d5a --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.90.0" +profile = "default" diff --git a/src/vm/instructions.rs b/src/vm/instructions.rs index 36e2c0fa7..e6822e5d6 100644 --- a/src/vm/instructions.rs +++ b/src/vm/instructions.rs @@ -40,7 +40,7 @@ enum InstructionFormat { I, S, B, - U, + _U, J, } @@ -54,7 +54,6 @@ impl Opcode { &Opcode::Store => InstructionFormat::S, &Opcode::Branch => InstructionFormat::B, &Opcode::JumpAndLink => InstructionFormat::J, - _ => unimplemented!(), } } }