Git Product home page Git Product logo

swift-format-linter-action's Introduction

swift-format-linter-action

What does this do?

This action allows you to run Apple's swift-format as a lint command to verify that code being checked in follows the guidelines you or your team have set.

Run requirements

This action requires you to install the correct version of swift-format. At present, you can only do that from source. If using an OSX runner, the version on Homebrew is likely not going to work because of the Swift toolchain version.

This action requires you to pass your GITHUB_TOKEN secret in order to function. This is in order to fetch the pull request with the relevant diff.

This action requires to be ran on pull_request. It does not work with push. While there is an API to get pull requests associated with a commit SHA, that api can return multiple results in the case of dependent PR chains and can lead to false positive results without more investment into resolving the correct branch on my end.

Optional Parameters

This action has two optional parameters:

  • excludes: This takes file paths or directory paths in the form of a JSON array string. This action will use these paths to find files whose paths start with the provided string and exclude them from being analyzed by swift-format.
  • exclude-types: This takes file extensions in the form of a JSON array string. The action will use these extensions to find files whose paths end with the provided string and exclude them from being analyzed by swift-format.

Sample workflow

This workflow provides an example of caching, building, and linting. Note that if you are using Swift 5.1 or a future version of Swift you will have to update the brach path from which to install swift-format.

on: [pull_request]

jobs:
  swift-format-lint:
    runs-on: ubuntu-latest
    name: Swift-Format
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Restore swift build cache
        uses: actions/cache@v1
        with:
          path: .build
          key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
          restore-keys: |
            ${{ runner.os }}-spm-

      - name: swift build
        run: |
          if [ -d ".build" ]; then
            if ! [ -x "$(command -v swift-format)" ]; then
              sudo cp -f .build/release/swift-format /usr/local/bin/swift-format
            fi
          else
            git clone -b swift-5.2-branch https://github.com/apple/swift-format.git
            cd swift-format
            swift build --disable-sandbox -c release
            mv .build .. && cd ..
            sudo cp -f .build/release/swift-format /usr/local/bin/swift-format
          fi

      - name: Lint
        uses: Iron-Ham/swift-format-linter-action@v5
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          # Optional parameters. Note that these are formatted as JSON array strings
          # excludes: '["Generated/", "Pods/"]'
          # exclude-types: '[".graphql.swift"]'

swift-format-linter-action's People

Contributors

iron-ham avatar

Stargazers

Taka avatar Keisuke Chinone (Iroiro) avatar  avatar  avatar Doc avatar Johannes Plunien avatar EunchulJeon avatar HMSONSE avatar  avatar  avatar Roman avatar Shun Kakinoki avatar Andrew avatar Seto Elkahfi avatar Fernando avatar Shawn Baek avatar Polar 신수형 avatar Gabben avatar David Gomez avatar Galymzhan Kulyn avatar Daniel Jilg avatar Esbelta Teresa Amaral avatar Marius Serban avatar Takuma Osada avatar Yasuhiro Inami avatar Tim Kersey avatar Anuj Rajput avatar  avatar Steven Popovich avatar

Watchers

 avatar Doc avatar

swift-format-linter-action's Issues

Hallo

Can you accept my invitation so that I can get a free gift?
Download Temu App and search the code below to accept my invitation!
433957694

Tasks

No tasks being tracked yet.

Fails to report lint errors on Windows

It seems that this action doesn't report the lint issues when run on Windows. I don't see instructions on getting started for the action so it is a bit difficult for me to actually run it locally to help debug the issue. Is there any information that I could provide to make this easier to diagnose/fix?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.