diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67de6d1..f4b7148 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,6 +68,6 @@ jobs: if: steps.binaries.outcome != 'success' run: cargo install cargo-generate - name: Generate - run: cargo generate --path /home/runner/work/esp-template/esp-template/github-esp-template --allow-commands --name test --vcs none --silent -d mcu=${{ matrix.board }} -d advanced=true -d devcontainer=false -d wokwi=false -d alloc=${{ matrix.alloc }} + run: cargo generate --path /home/runner/work/esp-template/esp-template/github-esp-template --allow-commands --name test --vcs none --silent -d mcu=${{ matrix.board }} -d advanced=true -d devcontainer=false -d wokwi=false -d alloc=${{ matrix.alloc }} -d ci=false - name: cargo ${{ matrix.action.command }} run: cd test; cargo ${{ matrix.action.command }} ${{ matrix.action.args }} diff --git a/.github/workflows/ci_docker.yml b/.github/workflows/ci_docker.yml index be4b1d2..b36015e 100644 --- a/.github/workflows/ci_docker.yml +++ b/.github/workflows/ci_docker.yml @@ -46,7 +46,7 @@ jobs: if: steps.binaries.outcome != 'success' run: cargo install cargo-generate - name: Generate - run: cargo generate --path /home/runner/work/esp-template/esp-template/github-esp-template --allow-commands --name test-${{ matrix.board }} --vcs none --silent -d mcu=${{ matrix.board }} -d advanced=true -d devcontainer=true -d wokwi=false -d alloc=false + run: cargo generate --path /home/runner/work/esp-template/esp-template/github-esp-template --allow-commands --name test-${{ matrix.board }} --vcs none --silent -d mcu=${{ matrix.board }} -d advanced=true -d devcontainer=true -d wokwi=false -d alloc=false -d ci=false - name: Update ownership run: | sudo chown 1000:1000 -R test-${{ matrix.board }} diff --git a/.github/workflows/rust_ci.yml b/.github/workflows/rust_ci.yml new file mode 100644 index 0000000..39d2ef9 --- /dev/null +++ b/.github/workflows/rust_ci.yml @@ -0,0 +1,52 @@ +name: Continuous Integration + +on: + push: + paths-ignore: + - "**/README.md" + pull_request: + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + {% raw -%} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + {%- endraw %} + +jobs: + rust-checks: + name: Rust Checks + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + action: + - command: build + args: --release + - command: fmt + args: --all -- --check --color always + - command: clippy + args: --all-targets --all-features --workspace -- -D warnings + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Enable caching + uses: Swatinem/rust-cache@v2 + - name: Setup Rust + {%- if arch == "riscv" %} + uses: dtolnay/rust-toolchain@v1 + with: + target: {{ rust_target }} + toolchain: nightly + components: rust-src + {%- else %} + uses: esp-rs/xtensa-toolchain@v1.5 + with: + default: true + buildtargets: {{ mcu }} + ldproxy: false + {% endif -%} + - name: Run command + {%- raw %} + run: cargo ${{ matrix.action.command }} ${{ matrix.action.args }} + {%- endraw %} diff --git a/cargo-generate.toml b/cargo-generate.toml index a00f869..4eb6ec4 100644 --- a/cargo-generate.toml +++ b/cargo-generate.toml @@ -1,6 +1,6 @@ [template] cargo_generate_version = ">=0.17.4" -ignore = [".git", ".github", "README.md"] +ignore = [".git", ".github/dependabot.yml", ".github/workflows/ci_docker.yml", ".github/workflows/ci.yml", ".github/workflows/issue_handler.yml", "README.md"] [hooks] pre = ["pre-script.rhai"] @@ -31,7 +31,12 @@ type = "bool" prompt = "Configure project to support Wokwi simulation with Wokwi VS Code extension?" default = false -[conditional.'devcontainer == false'] +[conditional.'advanced'.placeholders.ci] +type = "bool" +prompt = "Add CI files for GitHub Action?" +default = false + +[conditional.'!devcontainer'] ignore = [ ".devcontainer/", ".vscode/tasks.json", @@ -40,7 +45,10 @@ ignore = [ ".dockerignore", ] -[conditional.'wokwi == false'] +[conditional.'!ci'] +ignore = [".github"] + +[conditional.'!wokwi'] ignore = [".vscode/launch.json", "diagram.json", "wokwi.toml"] [conditional.'!advanced'] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 6139fb1..f68b612 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -3,4 +3,4 @@ channel = "{{ toolchain }}" {%- if arch == "riscv" %} components = ["rust-src"] targets = ["{{ rust_target }}"] -{% endif %} \ No newline at end of file +{% endif %}