norio-nomura / action-swiftlint Goto Github PK
View Code? Open in Web Editor NEWGitHub Action for SwiftLint
License: MIT License
GitHub Action for SwiftLint
License: MIT License
https://github.com/eonist/TestRunner/blob/master/.github/workflows/Tests.yml
But it uses some other SwiftLint file, not the one in the project, any idea how to fix this?
My workflow looks like this:
name: Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
#Something wrong with swiftlint action, figure it out later
SwiftLint: ## Adds swift-linting to GH actions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: GitHub Action for SwiftLint
uses: norio-nomura/[email protected]
with:
args: --config .swiftlint.yml
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: swift build -v
SwiftLint is still checking unchanged files in my pull-requests even though I'm using the following swiftlint.yml config
name: SwiftLint
on:
pull_request:
paths:
- '.github/workflows/swiftlint.yml'
- '.swiftlint.yml'
- '**/*.swift'
- '!Pods/**'
jobs:
SwiftLint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: GitHub Action for SwiftLint (Only files changed in the PR)
uses: norio-nomura/[email protected]
env:
DIFF_BASE: ${{ github.base_ref }}
Hi!
I'm using this action with the latest update that lints only files that have been changed in the PR.
This is great and it's a very nice addition!
However, if now a PR has changes in files within an excluded folder, for example a tests
folder, those files will also be linted, regardless of the .swiftlint.yml
configuration.
Is this the expected behaviour?
Thank you in advance,
Federico
(cc @axelguilmin)
On pull_request
event, GITHUB_SHA
environment variable does not have sha of commit.
https://help.github.com/ja/articles/events-that-trigger-workflows#pull-request-events-for-forked-repositories
Acutal Error: https://github.com/norio-nomura/action-swiftlint/runs/203274466
SeeAlso: #7
I tried to use the action on Github CI, but it won't work. Here is my workflow:
on: pull_request
name: Lint
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: norio-nomura/action-swiftlint@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
In log I see the error message: Current Action `norio-nomuraaction-swiftlint` not found!
When using the configuration option
- name: GitHub Action for SwiftLint (Only files changed in the PR)
uses: norio-nomura/[email protected]
env:
DIFF_BASE: ${{ github.base_ref }}
I tried some solutions on Stackoverflow like:
git config --global --add safe.directory '*'
or
git config --system --add safe.directory '*'
But it doesn't work...
Hey, when our .swiftlint.yml
specifies a specific swiftlint_version
to lint our project with, it causes our builds to start to fail when the Action starts using a more recent version of Swiftlint.
Happy to look into it myself, but is there a way to pin the Swiftlint version that the action (or Docker image) are using? Or was it an explicit decision to track the latest release?
Hi! I see that your tests include the strict mode, but I couldn't find a way to use that with the action itself.
Is there a way to enable it?
my .swiftlint.yml file:
disabled_rules: # rule identifiers to exclude from running
opt_in_rules: # some rules are only opt-in
- missing_docs
# Find all the available rules by running:
# swiftlint rules
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Carthage
- Pods
analyzer_rules: # Rules run by `swiftlint analyze` (experimental)
# configurable rules can be customized from this configuration file
# binary rules can set their severity level
force_cast: warning # implicitly
force_try:
severity: warning # explicitly
# rules that have both warning and error levels, can set just the warning level
# implicitly
missing_docs:
error:
- public
warning:
- internal
- private
line_length:
warning: 230
error: 500
ignores_comments: true
# they can set both implicitly with an array
type_body_length:
- 300 # warning
- 400 # error
# or they can set both explicitly
file_length:
warning: 500
error: 1200
# naming rules can set warnings/errors for min_length and max_length
# additionally they can set excluded names
type_name:
min_length: 4 # only warning
max_length: # warning and error
warning: 40
error: 50
excluded: iPhone # excluded via string
allowed_symbols: ["_"] # these are allowed in type names
identifier_name:
min_length: # only min_length
error: 4 # only error
excluded: # excluded via string array
- id
- vc
- URL
- GlobalAPIKey
- i
- db
- url
- row
- key
reporter: "xcode" # reporter type (xcode, json, csv, checkstyle, junit, html, emoji, sonarqube, markdown)
my GitHub action
name: SwiftLint
on:
pull_request:
paths:
- '.github/workflows/swiftlint.yml'
- '.swiftlint.yml'
- '**/*.swift'
jobs:
SwiftLint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: GitHub Action for SwiftLint
uses: norio-nomura/[email protected]
- name: GitHub Action for SwiftLint with --strict
uses: norio-nomura/[email protected]
with:
args:
- name: GitHub Action for SwiftLint (Only files changed in the PR)
uses: norio-nomura/[email protected]
env:
DIFF_BASE: ${{ github.base_ref }}
Title is pretty self explanatory.
We have our own macos build machine that we hooked up to be a runner (so we dont have to pay for github actions).
It would be nice to be able to run this workflow on a mac machine.
We are using config like below:
name: Swift
on:
pull_request:
types:
- opened
- edited
- reopened
- synchronize
jobs:
swiftlint:
name: Swiftlint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ssh-key: ${{ secrets.SSH_KEY }}
submodules: recursive
- name: Swiftlint
uses: norio-nomura/[email protected]
with:
# https://github.com/realm/SwiftLint
args: --strict --force-exclude
.swiftlint.yml file is excluding:
excluded:
- Pods
- SourcePackages
- fastlane/SnapshotHelper.swift //This one is new!
Locally everything works fine. Our .swiftlint.yml
file is in submodule. Checkout is fetching submodules correctly. I've verified commit and it is correct one. Right after checkout we are performing step named Swiftlint
and we are constantly getting errors on excluded file fastlane/SnapshotHelper.swift
. It seems like despite the fact that submodule fetching is successfull it is still using older (cached?) version of .swiftlint.yml
from previous submodule commit.
Currently we are running out of ideas.
With SwiftLint version 0.41.0 which has been release yesterday, SwiftLint has changed the calculation of the root path when a directory in the tree is passed as a path
argument.
Prior to this version it was possible to define a path
argument, whereas SwiftLint then took the config file and all excluded files relative to this path
argument. This seems to have changed, whereas this awesome GitHub action does not work properly anymore in the case (a) your source code is not located in the root folder of your repository, and (b) you have defined excluded files/path in a configuration file which are relative to this source code folder (e.g., to be used within an Xcode build phase). In those cases this GitHub action can not be used anymore, due to the following changes of SwiftLint:
A similar issue has already been addressed in pull request #24.
Example:
.swiftlint.yml
are located in: src/
.swiftlint.yml
contains excluded paths which are relative to this src/
folder:excluded:
- Carthage
uses: norio-nomura/[email protected]
with:
args: --path src --config .swiftlint.yml
Is there any way we can speed up this process? Why actions/checkout@v1
process is happening every time from scratch? Is there any way to fetch only changes and perform lint?
When using the configuration option
env:
- name: SwiftLint
uses: norio-nomura/[email protected]
env:
DIFF_BASE: ${{ github.base_ref }}
with:
args: --strict
in order to check only files of the current PR, my .swiftlint.yml
configuration (containing some exclusion filters) is not taken into account.
Removing the line DIFF_BASE: ${{ github.base_ref }}
re-enables my .swiftlint.yml
configuration.
is it possible to run swiftlint only on changed files?
The action seems to run SwiftLint
with no issues, but then fails with this error:
Docker run failed with exit code 2
I have a .swiftlint.yml
file that includes some disabled rules, excluded paths. Other than that nothing odd about my repo.
I can run SwiftLint successfully on my local machine (macOS).
Hello, do we able to config this with rules which are stated in .swiftlint.yml
?
If so, how do we do it?
thanks ๐
When using the DIFF_BASE to only lint files changed in a PR, file paths containing spaces will be ignored. I've tried playing around with it myself but wasn't able to get bash to escape/pass the strings to swift lint correctly.
Ideally, both of the cases below should be supported:
Sources/Supporting Files/Test.swift
Sources/My File.swift
https://blog.github.com/changelog/2018-10-16-suggested-changes/
It seems to need creating Pull Request Review with comment that contains fenced code blocks with suggestion
language identifier.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.