Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Add CI prompt (#97)
Browse files Browse the repository at this point in the history
* feat: Initial CI support

* ci: Fix generated CI file

* ci: Add CI prompt
  • Loading branch information
SergioGasquez authored Jul 10, 2023
1 parent 7789c4f commit 2165a0b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
2 changes: 1 addition & 1 deletion .github/workflows/ci_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/rust_ci.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
with:
default: true
buildtargets: {{ mcu }}
ldproxy: false
{% endif -%}
- name: Run command
{%- raw %}
run: cargo ${{ matrix.action.command }} ${{ matrix.action.args }}
{%- endraw %}
14 changes: 11 additions & 3 deletions cargo-generate.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down Expand Up @@ -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",
Expand All @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ channel = "{{ toolchain }}"
{%- if arch == "riscv" %}
components = ["rust-src"]
targets = ["{{ rust_target }}"]
{% endif %}
{% endif %}

0 comments on commit 2165a0b

Please sign in to comment.