From 07be4efdb57fd3bd1b2f3ae2a352971609608feb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 31 Mar 2026 13:10:14 +0000 Subject: [PATCH 1/2] fix: improve template usability and reproducibility - Fix rust-analyzer "can't find crate for test" by adding check.allTargets: false - Add rust-toolchain.toml to pin toolchain version, target, and components - Add cargo-binutils and llvm-tools to Dockerfile for binary inspection/disassembly - Add defmt-test for on-target embedded testing with example test Agent-Logs-Url: https://github.com/Baker-link-Lab/bakerlink_tutorial_template/sessions/f183cbad-512b-43ab-a93c-048310787e22 Co-authored-by: Baker-Tanaka <42606588+Baker-Tanaka@users.noreply.github.com> --- .docker/Dockerfile | 2 ++ .vscode/settings.json | 1 + Cargo.toml | 7 +++++++ rust-toolchain.toml | 4 ++++ tests/example_test.rs | 20 ++++++++++++++++++++ 5 files changed, 34 insertions(+) create mode 100644 rust-toolchain.toml create mode 100644 tests/example_test.rs diff --git a/.docker/Dockerfile b/.docker/Dockerfile index af73443..bef5828 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -3,3 +3,5 @@ FROM rust:1.86.0-bullseye RUN rustup target install thumbv6m-none-eabi RUN cargo install flip-link --version 0.1.10 RUN rustup component add rustfmt +RUN rustup component add llvm-tools +RUN cargo install cargo-binutils diff --git a/.vscode/settings.json b/.vscode/settings.json index 93a45b7..82c1108 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { "rust-analyzer.cargo.target": "thumbv6m-none-eabi", + "rust-analyzer.check.allTargets": false, "editor.formatOnSave": true } \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index a9c4c72..329868d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,13 @@ rp2040-hal = { version = "0.10", features = ["rt", "critical-section-impl"] } rp2040-boot2 = "0.3" critical-section = "1.0.0" +[dev-dependencies] +defmt-test = "0.3" + +[[test]] +name = "example_test" +harness = false + # cargo build/run [profile.dev] codegen-units = 1 diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..e5da890 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "1.86.0" +targets = ["thumbv6m-none-eabi"] +components = ["rustfmt", "llvm-tools"] diff --git a/tests/example_test.rs b/tests/example_test.rs new file mode 100644 index 0000000..aa2928d --- /dev/null +++ b/tests/example_test.rs @@ -0,0 +1,20 @@ +#![no_std] +#![no_main] + +use defmt_rtt as _; +use panic_probe as _; +use rp2040_hal as _; + +#[link_section = ".boot2"] +#[used] +pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GENERIC_03H; + +#[defmt_test::tests] +mod tests { + use defmt::assert; + + #[test] + fn it_works() { + assert!(true); + } +} From 6cf2323c0b0c7d54fa70bd22aee34fb29a5e64a7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 31 Mar 2026 13:21:16 +0000 Subject: [PATCH 2/2] feat: pre-build Docker image and push to Docker Hub for faster setup - Add GitHub Actions workflow to build/push image on Dockerfile changes - Update compose.yaml to pull pre-built bakerlinklab/bakerlink-env:latest - Add .github/ to cargo-generate ignore list to protect ${{ }} syntax Agent-Logs-Url: https://github.com/Baker-link-Lab/bakerlink_tutorial_template/sessions/a073b2f3-6935-476b-be2a-58f9cef53054 Co-authored-by: Baker-Tanaka <42606588+Baker-Tanaka@users.noreply.github.com> --- .docker/compose.yaml | 5 +--- .github/workflows/docker-publish.yml | 41 ++++++++++++++++++++++++++++ cargo-generate.toml | 2 +- 3 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.docker/compose.yaml b/.docker/compose.yaml index 4c4042e..9646abf 100644 --- a/.docker/compose.yaml +++ b/.docker/compose.yaml @@ -1,9 +1,6 @@ services: {{project-name}}: - build: - context: . - dockerfile: Dockerfile - image: "baker-link-env" + image: "bakerlinklab/bakerlink-env:latest" container_name: "{{project-name}}-container" volumes: - "../:/{{project-name}}" diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..67b7948 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,41 @@ +name: Build and Push Docker Image + +on: + push: + branches: [main] + paths: + - '.docker/Dockerfile' + workflow_dispatch: + +env: + DOCKER_IMAGE: bakerlinklab/bakerlink-env + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + # Requires repository secrets: DOCKERHUB_USERNAME and DOCKERHUB_TOKEN + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: .docker + file: .docker/Dockerfile + push: true + tags: | + ${{ env.DOCKER_IMAGE }}:latest + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/cargo-generate.toml b/cargo-generate.toml index bb488e6..32f5ec8 100644 --- a/cargo-generate.toml +++ b/cargo-generate.toml @@ -1,2 +1,2 @@ [template] -ignore = ["README.md", "LICENSE"] +ignore = ["README.md", "LICENSE", ".github/"]