### Go Code Formatting with gofmt and goimports Source: https://autofix.ci/setup This workflow sets up the Go environment and uses goimports to format the code and manage imports. It includes instructions for installing goimports and running the formatting command. ```yaml name: autofix.ci on: pull_request: push: branches: [ "main" ] permissions: contents: read jobs: autofix: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - uses: actions/setup-go@v6 with: go-version: '1.17' # goimports works like gofmt, but also fixes imports. # see https://pkg.go.dev/golang.org/x/tools/cmd/goimports - run: go install golang.org/x/tools/cmd/goimports@latest - run: goimports -w . # of course we can also do just this instead: # - run: gofmt -w . - uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 ``` -------------------------------- ### TypeScript/JavaScript/HTML/CSS Formatting with Prettier Source: https://autofix.ci/setup This workflow demonstrates how to format TypeScript, JavaScript, HTML, and CSS files using Prettier. It includes steps for installing Node.js, installing dependencies, and running Prettier. ```yaml name: autofix.ci on: pull_request: push: branches: [ "main" ] permissions: contents: read jobs: autofix: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - uses: actions/setup-node@v5 - run: npm ci - run: npx prettier --write . # or, if you are using yarn: # - run: yarn # - run: yarn prettier --write . - uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 ``` -------------------------------- ### Optimize PNGs with autofix.ci and pngquant Source: https://autofix.ci/setup This workflow optimizes all PNG files in a repository using pngquant. It requires installing pngquant and then running the command with globstar enabled to process all PNGs recursively. It also includes the autofix-ci action. ```yaml name: autofix.ci on: pull_request: push: branches: [ "main" ] permissions: contents: read jobs: autofix: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 # Optimize all PNGs with https://pngquant.org/ - run: sudo apt-get update && sudo apt-get install -y pngquant - name: Run pngquant run: | shopt -s globstar pngquant -f --ext .png --skip-if-larger -- **/*.png - uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 ``` -------------------------------- ### Integrate pre-commit hooks with autofix.ci Source: https://autofix.ci/setup This workflow demonstrates integrating pre-commit hooks into an autofix.ci setup. It first installs pre-commit, then runs all pre-commit hooks on the repository files, and finally includes the autofix-ci action. ```yaml name: autofix.ci on: pull_request: push: branches: [ "main" ] permissions: contents: read jobs: autofix: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - run: pip install pre-commit - run: pre-commit run --all-files - uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 ``` -------------------------------- ### Rust Code Formatting and Linting with rustfmt and clippy Source: https://autofix.ci/setup This workflow configures the Rust toolchain, including rustfmt and clippy, to automatically format the codebase and apply linter suggestions. It utilizes caching for faster builds. ```yaml name: autofix.ci on: workflow_call: pull_request: push: branches: [ "main" ] permissions: contents: read env: rust_clippy: 1.65 # MSRV jobs: autofix: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - uses: actions/cache@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ key: autofix-${{ hashFiles('**/Cargo.lock') }} - run: rustup toolchain install ${{ env.rust_clippy }} --profile minimal --component rustfmt --component clippy - run: rustup default ${{ env.rust_clippy }} - run: cargo clippy --fix --workspace - run: cargo fmt --all - uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 ``` -------------------------------- ### Python Code Formatting with Ruff and uv Source: https://autofix.ci/setup This workflow sets up Python development with uv for dependency management and configures ruff for linting and formatting. It ensures consistent Python code style. ```yaml name: autofix.ci on: workflow_call: pull_request: push: branches: [ "main" ] permissions: contents: read jobs: autofix: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 # Use uv to ensure we have the same ruff version in CI and locally. - uses: astral-sh/setup-uv@b75a909f75acd358c2196fb9a5f1299a9a8868a4 with: version: "0.4.20" # Fix lint errors - run: uv run ruff check --fix-only . # Format code - run: uv run ruff format . - uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 ``` -------------------------------- ### Configure Autofix.ci Workflow Source: https://autofix.ci/setup This is the base workflow file for autofix.ci. It defines the trigger events, necessary permissions, and the jobs to run, including the autofix.ci action itself. Ensure this file is placed at .github/workflows/autofix.yml. ```yaml name: autofix.ci # needed to securely identify the workflow on: pull_request: push: branches: [ "main" ] permissions: contents: read jobs: autofix: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 # TODO: add all code-fixing here. - uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 ``` -------------------------------- ### Define Autofix GitHub Actions Workflow Source: https://autofix.ci/index This snippet shows how to define a GitHub Actions workflow that utilizes autofix.ci. It checks out the code, formats it using `cargo fmt`, and then integrates the autofix.ci action to automatically apply fixes to pull requests. ```yaml name: autofix.ci on: [ push, pull_request ] jobs: autofix: runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - run: cargo fmt - uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.