From 3304c8f08bf58c8279a7afb4f2556be7d8216409 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Thu, 21 Nov 2024 19:13:16 -0500 Subject: [PATCH] remove autofix.r8 --- .github/workflows/autofix.yml | 68 ---------------------------- .github/workflows/ci.yml | 5 +++ tests/autofix.rs | 83 ----------------------------------- tests/ci.rs | 14 +++++- 4 files changed, 18 insertions(+), 152 deletions(-) delete mode 100644 .github/workflows/autofix.yml delete mode 100644 tests/autofix.rs diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml deleted file mode 100644 index 6402374..0000000 --- a/.github/workflows/autofix.yml +++ /dev/null @@ -1,68 +0,0 @@ -# ------------------------------------------------------------------- -# ------------------------------- WARNING --------------------------- -# ------------------------------------------------------------------- -# -# This file was automatically generated by gh-workflows using the -# gh-workflow-gen bin. You should add and commit this file to your -# git repository. **DO NOT EDIT THIS FILE BY HAND!** Any manual changes -# will be lost if the file is regenerated. -# -# To make modifications, update your `build.rs` configuration to adjust -# the workflow description as needed, then regenerate this file to apply -# those changes. -# -# ------------------------------------------------------------------- -# ----------------------------- END WARNING ------------------------- -# ------------------------------------------------------------------- - -name: autofix.ci -on: - pull_request: - types: - - opened - - reopened - - synchronize - - labeled - branches: - - main - push: - branches: - - main -permissions: - contents: read - pull-requests: read - packages: read -jobs: - lint: - name: Run Formatter and Lint Check - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - packages: write - env: - LINT_MODE: '${{contains(github.event.pull_request.labels.*.name, ''ci: lintfix'') && ''fix'' || ''check''}}' - steps: - - name: Checkout Code - uses: actions/checkout@v4 - - name: Print $LINT_MODE - run: echo $LINT_MODE - env: - LINT_MODE: ${{ env.LINT_MODE }} - - name: Setup Rust Toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: stable, nightly - components: clippy, rustfmt - - name: Cargo Clippy Fix - if: env.LINT_MODE == 'fix' - run: cargo +nightly clippy --all --all-targets --all-features --fix --allow-staged --allow-dirty - - name: Cargo Fmt fix - if: env.LINT_MODE == 'fix' - run: cargo +nightly fmt --all - - name: Commit and push if changed - if: env.LINT_MODE == 'fix' - uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c45755..e5bc8b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,8 @@ jobs: build: name: Build and Test runs-on: ubuntu-latest + env: + LINT_MODE: '${{contains(github.event.pull_request.labels.*.name, ''ci: lintfix'') && ''fix'' || ''check''}}' steps: - name: Checkout Code uses: actions/checkout@v4 @@ -47,6 +49,9 @@ jobs: run: cargo +nightly fmt --check - name: Cargo Clippy run: cargo +nightly clippy --all-features --workspace -- -D warnings + - name: Commit and push if changed + if: env.LINT_MODE == 'fix' + uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c release: needs: build name: Release diff --git a/tests/autofix.rs b/tests/autofix.rs deleted file mode 100644 index 3eda291..0000000 --- a/tests/autofix.rs +++ /dev/null @@ -1,83 +0,0 @@ -use gh_workflow::generate::Generate; -use gh_workflow::toolchain::Toolchain; -use gh_workflow::*; - -#[test] -fn autofix() { - let lint_mode_condition = - "contains(github.event.pull_request.labels.*.name, 'ci: lintfix') && 'fix' || 'check'"; - let permissions = Permissions::default() - .pull_requests(Level::Write) - .packages(Level::Write) - .contents(Level::Write); - - let lint_job = Job::new("Run Formatter and Lint Check") - .runs_on("ubuntu-latest") - .permissions(permissions) - .add_env(("LINT_MODE", format!("${{{{{}}}}}", lint_mode_condition))) - .add_step(Step::checkout()) - .add_step( - Step::run("echo $LINT_MODE") - .add_env(("LINT_MODE", "${{ env.LINT_MODE }}")) - .name("Print $LINT_MODE"), - ) - .add_step( - Toolchain::default() - .add_stable() - .add_nightly() - .add_clippy() - .add_fmt(), - ) - .add_step( - Cargo::new("clippy") - .nightly() - .args("--all --all-targets --all-features --fix --allow-staged --allow-dirty") - .if_condition("env.LINT_MODE == 'fix'") - .name("Cargo Clippy Fix"), - ) - .add_step( - Cargo::new("fmt") - .nightly() - .args("--all") - .if_condition("env.LINT_MODE == 'fix'") - .name("Cargo Fmt fix"), - ) - .add_step( - Step::uses( - "autofix-ci", - "action", - "ff86a557419858bb967097bfc916833f5647fa8c", - ) - .if_condition(Expression::new("env.LINT_MODE == 'fix'")) - .name("Commit and push if changed"), - ); - - let concurrency = Concurrency::default() - .group("${{ github.workflow }}-${{ github.ref }}") - .cancel_in_progress(true); - - let permissions = Permissions::default() - .pull_requests(Level::Read) - .packages(Level::Read) - .contents(Level::Read); - - let workflow = Workflow::new("autofix.ci") - .on(Event::default() - .push(Push::default().add_branch("main")) - .pull_request( - PullRequest::default() - .add_branch("main") - .add_type(PullRequestType::Opened) - .add_type(PullRequestType::Reopened) - .add_type(PullRequestType::Synchronize) - .add_type(PullRequestType::Labeled), - )) - .permissions(permissions) - .concurrency(concurrency) - .add_job("lint", lint_job); - - Generate::new(workflow) - .name("autofix.yml") - .generate() - .unwrap() -} diff --git a/tests/ci.rs b/tests/ci.rs index 2a2a0b0..1f558da 100644 --- a/tests/ci.rs +++ b/tests/ci.rs @@ -4,9 +4,13 @@ use toolchain::Toolchain; #[test] fn generate() { + let lint_mode_condition = + "contains(github.event.pull_request.labels.*.name, 'ci: lintfix') && 'fix' || 'check'"; + let flags = RustFlags::deny("warnings"); let build = Job::new("Build and Test") + .add_env(("LINT_MODE", format!("${{{{{}}}}}", lint_mode_condition))) .add_step(Step::checkout()) .add_step( Toolchain::default() @@ -31,7 +35,15 @@ fn generate() { .nightly() .args("--all-features --workspace -- -D warnings") .name("Cargo Clippy"), - ); + ).add_step( + Step::uses( + "autofix-ci", + "action", + "ff86a557419858bb967097bfc916833f5647fa8c", + ) + .if_condition(Expression::new("env.LINT_MODE == 'fix'")) + .name("Commit and push if changed"), + ); let event = Event::default() .push(Push::default().add_branch("main"))