From 1bf5ffa400fa6ed32dfbb8b843b4fbaa23606634 Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Sat, 23 Dec 2023 22:32:11 -0500 Subject: [PATCH] feat: Add github actions for both templates (#27) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: Correct link to actions in README 🐛 * feat: Add actions ✨ * fix: Remove unnecessary clone 🐛 * feat: Remove build.yml ✨ --- .github/workflows/build.yml | 32 ------------------- .github/workflows/ci.yml | 54 +++++++++++++++++++++++++++++++++ .github/workflows/template.toml | 7 +++++ async/template/README.md | 2 +- async/template/src/utils.rs | 2 +- 5 files changed, 63 insertions(+), 34 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/template.toml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 568e6db..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Test the builds for the template - -name: "Build Template" -on: - workflow_dispatch: - schedule: - # Run once a week at 6pm on Saturday (UTC) - - cron: "0 18 * * 6" - push: - paths-ignore: - - "**.md" - -jobs: - build: - runs-on: ubuntu-latest - env: - PROJECT_NAME: my-project - steps: - - uses: actions/checkout@v3 - - uses: cargo-generate/cargo-generate-action@v0.17.5 - with: - name: ${{ env.PROJECT_NAME }} - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - # We need to move the generated project to a temp folder, away from the template project - # otherwise `cargo` runs would fail . - # see https://github.com/rust-lang/cargo/issues/9922 - - run: | - mv $PROJECT_NAME ${{ runner.temp }}/ - cd ${{ runner.temp }}/$PROJECT_NAME - cargo check diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..50f09f7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +name: Build Template +on: + push: + branches: + - main + pull_request: + +jobs: + build-simple: + runs-on: ubuntu-latest + env: + PROJECT_NAME: ratatui-github-example + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Run cargo generate + uses: cargo-generate/cargo-generate-action@v0.18.3 + with: + name: ${{ env.PROJECT_NAME }} + template: simple + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + - name: Cargo check + # we need to move the generated project to a temp folder, away from the template project + # otherwise `cargo` runs would fail + # see https://github.com/rust-lang/cargo/issues/9922 + run: | + mv $PROJECT_NAME ${{ runner.temp }}/ + cd ${{ runner.temp }}/$PROJECT_NAME + cargo check --tests + + build-async: + runs-on: ubuntu-latest + env: + PROJECT_NAME: ratatui-github-example + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Run cargo generate + uses: cargo-generate/cargo-generate-action@v0.18.3 + with: + name: ${{ env.PROJECT_NAME }} + template: async + template_values_file: .github/workflows/template.toml + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + - name: Cargo check + # we need to move the generated project to a temp folder, away from the template project + # otherwise `cargo` runs would fail + # see https://github.com/rust-lang/cargo/issues/9922 + run: | + mv $PROJECT_NAME ${{ runner.temp }}/ + cd ${{ runner.temp }}/$PROJECT_NAME + cargo check --tests diff --git a/.github/workflows/template.toml b/.github/workflows/template.toml new file mode 100644 index 0000000..e1a4efe --- /dev/null +++ b/.github/workflows/template.toml @@ -0,0 +1,7 @@ +[values] +gh-username = "ratatui" +project-description = "Example of ratatui template" +msrv = "nightly" +use_gitserver = false +crossterm_io = "stderr" +use_rustfmt = false diff --git a/async/template/README.md b/async/template/README.md index 63d9eea..fc34e29 100644 --- a/async/template/README.md +++ b/async/template/README.md @@ -1,5 +1,5 @@ # {{project-name}} -[![CI](https://github.com/{{gh-username}}/{{project-name}}/workflows/CI/badge.svg)](https://github.com/{{gh-username}}/{{project-name}}/actions) +[![CI](https://github.com/{{gs-username}}/{{project-name}}/workflows/CI/badge.svg)](https://github.com/{{gs-username}}/{{project-name}}/actions) {{project-description}} diff --git a/async/template/src/utils.rs b/async/template/src/utils.rs index b1171e5..da22959 100644 --- a/async/template/src/utils.rs +++ b/async/template/src/utils.rs @@ -144,7 +144,7 @@ macro_rules! trace_dbg { pub fn version() -> String { let author = clap::crate_authors!(); - let commit_hash = GIT_COMMIT_HASH.clone(); + let commit_hash = GIT_COMMIT_HASH; // let current_exe_path = PathBuf::from(clap::crate_name!()).display().to_string(); let config_dir_path = get_config_dir().display().to_string();