Commit Graph

143 Commits

Author SHA1 Message Date
JP Simard 07740506b5 Automate adding a new changelog section after releasing (#5016) 2023-05-17 10:36:31 -04:00
JP Simard 15a18fd4e8 Merge make release with make publish (#5003)
To simplify the release process.
2023-05-12 09:58:06 -04:00
JP Simard 8827fca693 Automate GitHub Release Creation (#4995)
* Add `tools/generate-release-notes.sh` script
* Add `tools/create-github-release.sh` script
* Update `Releasing.md`
2023-05-11 14:01:29 -04:00
JP Simard 6cdb0aa689 Update make publish
To use the CocoaPods version from bundler and to remove the stale
workaround.
2023-05-11 11:03:28 -04:00
JP Simard a7bc9e20c7 Move built-in rules to new SwiftLintBuiltInRules module (#4950) 2023-04-27 11:16:01 -04:00
JP Simard 86d60400c1 Move core SwiftLint functionality to new SwiftLintCore module
Over the years, SwiftLintFramework had become a fairly massive monolith,
containing over 400 source files with both core infrastructure and
rules.

Architecturally, the rules should rely on the core infrastructure but
not the other way around. There are two exceptions to this:
`custom_rules` and `superfluous_disable_command` which need special
integration with the linter infrastructure.

Now the time has come to formalize this architecture and one way to do
that is to move the core SwiftLint functionality out of
SwiftLintFramework and into a new SwiftLintCore module that the rules
can depend on.

Beyond enforcing architectural patterns, this also has the advantage of
speeding up incremental compilation by skipping rebuilding the core
functionality when iterating on rules.

Because the core functionality is always useful when building rules, I'm
opting to import SwiftLintCore in SwiftLintFramework as `@_exported` so
that it's implicitly available to all files in SwiftLintFramework
without needing to import it directly.

In a follow-up I'll also split the built-in rules and the extra rules
into their own modules. More modularization is possible from there, but
not planned.

The bulk of this PR just moves files from `Source/SwiftLintFramework/*`
to `Source/SwiftLintCore/*`. There are some other changes that can't be
split up into their own PRs:

* Change jazzy to document the SwiftLintCore module instead of
  SwiftLintFramework.
* Change imports in unit tests to reflect where code was moved to.
* Update `sourcery` make rule to reflect where code was moved to.
* Create a new `coreRules` array and register those rules with the
  registry. This allows the `custom_rules` and
  `superfluous_disable_command` rule implementations to remain internal
  to the SwiftLintCore module, preventing more implementation details
  from leaking across architectural layers.
* Move `RuleRegistry.registerAllRulesOnce()` out of the type declaration
  and up one level so it can access rules defined downstream from
  SwiftLintCore.
2023-04-26 21:10:19 -04:00
JP Simard 740572f049 Move Version.swift to SwiftLintCore 2023-04-26 21:10:19 -04:00
JP Simard 165172e0fa Introduce a "rule registry" concept
This will allow for registering rules that aren't compiled as part of
SwiftLintFramework.

Specifically this will allow us to split the built-in and extra rules
into separate modules, leading to faster incremental compilation when
working on rules since the rest of the framework won't need to be
rebuilt on every compilation.
2023-04-25 12:28:50 -04:00
JP Simard 1b0f37c6f6 Pin Sourcery version to 2.0.2 (#4888)
By adding a `tools/sourcery` script that downloads and runs Sourcery via
Bazel.

Previously, unrelated changes might include modifications to the
generated comment headers because contributors' local versions of
Sourcery would be used, which we don't control.

Also move the CI job to Buildkite where the bazel server is usually
already warmed up and running.
2023-04-13 20:09:26 +00:00
Martin Redington 7dad240ea7 Add a reporters subcommand (#4836) 2023-03-31 08:09:01 +02:00
JP Simard 62b9c2de7a Don't run make clean automatically on build
Since when releasing, many steps depend on the `build`, so we don't want
to clean mid-way through releasing.

Explicitly run `make clean` at the start of `make release`.
2023-03-27 11:22:00 -04:00
JP Simard 183c0aa784 Set --platform linux/amd64 in make zip_linux_release
So it works on other architectures (e.g. Apple Silicon)
2023-02-20 17:00:48 -05:00
Keith Smiley 23e4db3e5f Add support for bzlmod (#4704) 2023-01-19 17:04:21 -05:00
Julio Carrettoni d3928cb8e8 Update docker_test to swift 5.7 (#4625) 2022-12-19 19:12:44 -03:00
JP Simard 53ee4a955d Fix make release
`make package` has a dependency on `make clean` so this was removing
the bazel release artifacts.
2022-12-09 14:42:20 -05:00
Tony Arnold ab143685a4 Use a binary target for the build tool plugin (#4603)
* Use a binary target for the build tool plugin

* Merge `push_version` and `release` make commands

Instead of running `make push_version "0.2.0: Tumble Dry"` and then
`make release`, now run `make release "0.2.0: Tumble Dry"`, which will
build the release artifacts and update/push the new version to GitHub.

This allows the artifacts to use the new version, update the artifact
bundle checksum in the package manifest, then tag the release.

The Releasing.md instructions were updated to reflect this new workflow.

* Add `SwiftLintSourcePlugin` source plugin for SwiftPM

* Add changelog entry

* Remove SwiftLintSourcePlugin for now

* Build from Source on Linux

* Use a lower-level method of checking if a file is accessible

This shouldn’t trigger sandbox violations, I hope…

* Prevent an infinite recursion of the filesystem root

* Remove unnecessary logging

* Quieten the output so that Xcode only prints violations

* Break up comment to avoid line length warning

* Fix capitalization of Glibc import

Co-authored-by: JP Simard <jp@jpsim.com>
2022-11-29 18:10:47 -05:00
JP Simard a6c4ea9614 Makefile: use bazel in more places (#4580)
Previously, it took a very long time to run `make release` since it had
to clean build everything.

With bazel, I'm more confident in incremental builds being solid, so it
now just takes a few seconds if there's anything cached, which is often
the case.
2022-11-23 21:41:28 +00:00
JP Simard b9653e3e1b Replace swift run with swift build --product (#4357) 2022-10-12 15:51:10 -04:00
JP Simard 3ac518ce69 Only build swiftlint target in Makefile (#4327)
Otherwise this tries to build the SwiftLintTestHelpers module in release
mode, which fails.

Also, to build the actual executable CLI, we can't just
`swift build --target=swiftlint` because that doesn't produce a CLI,
just the object file for the binary. So we have to `swift run`.
2022-10-07 16:50:56 +00:00
JP Simard 5ae1d98596 Create new GeneratedTests and IntegrationTests test targets (#4304)
* Move generated rule tests to a dedicated GeneratedTests target
* Move integration tests to a dedicated IntegrationTests target

This will improve bazel cacheability by having fewer tests depend on all
lint inputs, which are only needed by the integration tests.
2022-10-06 00:10:04 -04:00
JP Simard ea41b9fd09 Rename default branch from master to main (#4116) 2022-09-01 07:09:46 -04:00
JP Simard fc3b143973 Rename script directory to tools (#4141)
And move the Danger bazel config there
2022-08-29 01:16:20 -04:00
JP Simard 69f3a3b4b7 Refactor bazel release rule
Moving the signature file generation from the Makefile to the bazel rule
2022-08-22 12:26:22 -04:00
JP Simard e8f738b39c Automate producing release tarballs for Bazel (#4113) 2022-08-19 17:26:21 +00:00
Danny Mösch c1b74cd752 Rename test classes (#4083) 2022-08-11 07:33:11 +02:00
JP Simard fe652e8c8a Update Makefile to drop support for Swift 5.5 2022-07-26 09:45:16 -04:00
Juozas Valančius a28516d5e8 Create .artifactbundle during release 2022-03-31 09:52:22 -04:00
JP Simard 91b58c6cbe Strip binary when building for release
Shaves ~32% off the binary size.

Brings the universal fat binary on macOS from 86MB to 58MB.
2022-03-18 20:43:55 -04:00
JP Simard 21bb280068 Build additional Docker image with Swift 5.5 (#3904)
* Build additional Docker image with Swift 5.5
* Build `swiftlint_linux_swift_5_5.zip`
2022-03-17 17:27:05 -04:00
JP Simard ca2712aaee Make linux zip from GitHub's remote Docker image
Locally I had trouble building the image on both my previous Intel MacBook Pro
and my new M1 Max MacBook Pro.
2022-03-16 11:05:09 -04:00
JP Simard 92e199649d Fix make package command (#3890) 2022-03-10 20:00:49 -05:00
JP Simard ebaa6d2182 Add workaround for https://github.com/CocoaPods/CocoaPods/issues/11185 2022-03-08 16:33:17 -05:00
JP Simard 0f3de846d8 push to HEAD in make push_version 2022-03-08 16:18:20 -05:00
JP Simard a43e52aa91 Integrate Swift Syntax in the force_cast rule (#3867)
We've tried adding Swift Syntax support to SwiftLint in the past but had to turn it off in https://github.com/realm/SwiftLint/pull/3107 due to distribution and portability issues.

With https://github.com/keith/StaticInternalSwiftSyntaxParser it should be possible to avoid those issues by statically linking the internal Swift syntax parser so it's available no matter where users have Xcode installed on their computer.

By removing all calls to SourceKit (collecting comment commands + checking the current Swift version), there's a really significant performance improvement.

| Framework | Mean [ms] | Min [ms] | Max [ms] | Relative |
|:---|---:|---:|---:|---:|
| SourceKit | 517.8 ± 8.3 | 505.5 | 531.1 | 6.59 ± 0.43 |
| SwiftSyntax | 78.6 ± 5.0 | 72.6 | 92.1 | 1.00 |

In practice, the SourceKit overhead will continue being there for as long as any rule being run is still looking up the SwiftLint syntax map though.
2022-03-07 12:51:24 -05:00
JP Simard be1f8596e4 Require Swift 5.5 to build SwiftLint (#3869)
* Disable Swift 5.4 CI jobs
* Remove SwiftLintFramework podspec
  I couldn't find a single use in GitHub's search: https://github.com/search?q=SwiftLintFramework+filename%3APodfile+language%3ARuby+language%3ARuby&type=Code
  Just not worth maintaining anymore.
* Change package swift tools version to 5.5
* Update docker_test to use Swift 5.5 image
* Clean up old Swift versions in SwiftVersionTests
  Even though these older Swift versions should still be supported, these tests
  can't be built against those versions so they're useless.
* Run docker commands with `--platform linux/amd64`
* Remove LinuxMain
  It looks like tests are discovered dynamically on Linux as of recent
  SwiftPM versions.
2022-03-07 12:15:03 -05:00
JP Simard 6ce4766517 Fix pkg installer (#3817) 2022-01-24 18:26:52 +00:00
JP Simard 4d3217f959 Run CI with Xcode 13 & Swift 5.5 (#3711)
Currently Xcode 13 beta 5, will switch to GM when available.
2021-09-10 09:24:39 -07:00
JP Simard 888619912f Run CI with Xcode 12.5.1 & Swift 5.4 (#3710)
And require Swift 5.4 or Xcode 12.5 or later to build SwiftLint.
2021-09-10 08:32:02 -07:00
Norio Nomura a84aee23df [Makefile] Update zip_linux target to depending Dockerfile
Hiding dependencies required at build time in the Dockerfile
2020-12-05 00:25:42 +09:00
JP Simard be21dc3b4b Add scrip/get-version script
Previous way wasn't working and this way we edit one less file when
pushing new versions.
2020-11-23 11:15:52 -05:00
JP Simard f45f381320 fixup! Remove Info.plist files 2020-11-20 15:25:50 -05:00
Norio Nomura 88d77a3211 [Makefile] Build swiftlint as a universal binary on macOS
SwiftPM 5.3 uses the `XCBuild.framework` to generate universal binaries when it receives multiple `--arch` options.
In that case, `--show-bin-path` returns `.build/apple/Products/Release`.
2020-11-19 18:48:11 +09:00
Norio Nomura 97052faf18 Use -static-stdlib on building Linux binary for release artifacts
This change prevents `swiftlint` from having links to shared libraries belonging to `/usr/lib/swift`.
```
$ docker run -v$PWD:$PWD -w$PWD --rm swift sh -c 'ldd $(swift build -c release --show-bin-path)/swiftlint'
	linux-vdso.so.1 (0x00007ffee8bb8000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f75e750b000)
	libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f75e7308000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f75e7104000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f75e6d66000)
	libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f75e69a5000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f75e661c000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f75e6404000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f75e6013000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f75ea7bf000)
	libicuuc.so.60 => /usr/lib/x86_64-linux-gnu/libicuuc.so.60 (0x00007f75e5c5b000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f75e5a3e000)
	liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f75e5818000)
	libicudata.so.60 => /usr/lib/x86_64-linux-gnu/libicudata.so.60 (0x00007f75e3c6f000)
```
I confirmed that `swiftlint` produced by `make zip_linux` works with following docker images:
- swift:5.3.1-xenial
- swift:5.3.1-bionic
- swift:5.3.1-focal
- swift:5.3.1-centos8
- swift:5.3.1-amazonlinux2
- norionomura/swift:5.3.1
- norionomura/swift:5.3.0
- norionomura/swift:5.2.5
- norionomura/swift:5.1.5
- norionomura/swift:5.0.3
2020-11-18 21:39:31 +09:00
JP Simard 76708d88f7 Remove Xcode project & Drop Carthage Support
Xcode has supported Swift Package Manager projects natively since Xcode
11, which has been out for over a year, where you can use Xcode by
having it open the `Package.swift` manifest rather than a `.xcodeproj`
or `.xcworkspace`.

I've been primarily developing SwiftLint in Xcode using this approach
for over a year, and despite a few nitpicks I have, it's been a joy to
use.

So I'd like to completely remove the Xcode project along with things
that support it:

* `SwiftLint.xcworkspace`/`SwiftLint.xcodeproj`: Neither of these are
  needed if we use `xed .` or `xed Package.swift` to develop SwiftLint
  in Xcode.
* `Cartfile`/`Cartfile.private`/`Cartfile.resolved`/`.gitmodules`/`Carthage/`:
  These were used to manage dependencies as git submodules for use in
  the Xcode workspace, but that's no longer necessary if Xcode delegates
  to SwiftPM to manage dependencies for us.
* Some scripts can be simplified, cleaned up or even completely removed.

* **Reduce duplication:** Rather than update dependencies or files in
  multiples places, there will only be the package manifest and the
  Podfile
* **Reduce merge conflicts:** This hasn't been too bad, but it's
  occasionally a pain when trying to land old PRs
* **Reduce development overhead:** No need to manually make sure that
  files in the Xcode project are sorted alphabetically
* **Reduce clone time:** No need to run
  `git submodules update --init --recursive` anymore

I think this breaks Carthage users that pull in SwiftLintFramework as a
dependency in a Cartfile.

However I can't find any references to [`SwiftLintFramework` in any
`Cartfile` files on GitHub](https://github.com/search?q=swiftlintframework+filename%3ACartfile&type=Code&ref=advsearch&l=&l=)
so this doesn't appear to be worth continuing to maintain.

Resolves https://github.com/realm/SwiftLint/issues/3412
2020-11-08 13:32:07 -05:00
Dalton Claybrook d305e03905 Add inclusive_language rule (#3243)
Current events have renewed the conversation in our community about the roles of terminology with racist connotations in our software. Many companies and developers are now taking appropriate steps to remove this terminology from their codebases and products. (e.g. [GitHub](https://twitter.com/natfriedman/status/1271253144442253312)) This small rule prevents the use of declarations that contain any of the terms: whitelist, blacklist, master, and slave. It may be appropriate to add more terms to this list now or in the future.
2020-11-07 22:03:08 -05:00
JP Simard 59d6c2ef52 Test CI with official Swift 5.3 release (#3356) 2020-09-20 11:16:10 -04:00
JP Simard d0d9ad575f Add Linux binary to release artifacts
There are a lot of libraries dynamically linked, so it's unlikely to
work in most places other than the same Docker image used to build the
binary (latest official Swift Docker image).

It might still be useful if you can guarantee that you'll use this from
that image.

    ldd .build/release/swiftlint
      linux-vdso.so.1 (0x00007fff38db5000)
      libswiftCore.so => /usr/lib/swift/linux/libswiftCore.so (0x00007f11503cd000)
      libFoundation.so => /usr/lib/swift/linux/libFoundation.so (0x00007f114fba6000)
      libswiftGlibc.so => /usr/lib/swift/linux/libswiftGlibc.so (0x00007f1151264000)
      libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f114f987000)
      libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f114f784000)
      libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f114f580000)
      libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f114f1e2000)
      libswiftDispatch.so => /usr/lib/swift/linux/libswiftDispatch.so (0x00007f115122b000)
      libdispatch.so => /usr/lib/swift/linux/libdispatch.so (0x00007f114ef82000)
      libBlocksRuntime.so => /usr/lib/swift/linux/libBlocksRuntime.so (0x00007f114ed7f000)
      libFoundationXML.so => /usr/lib/swift/linux/libFoundationXML.so (0x00007f11511d2000)
      libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f114e98e000)
      libicui18nswift.so.65 => /usr/lib/swift/linux/libicui18nswift.so.65 (0x00007f114e463000)
      libicuucswift.so.65 => /usr/lib/swift/linux/libicuucswift.so.65 (0x00007f114e062000)
      libicudataswift.so.65 => /usr/lib/swift/linux/libicudataswift.so.65 (0x00007f114c3b3000)
      libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f114c02a000)
      libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f114be12000)
      /lib64/ld-linux-x86-64.so.2 (0x00007f1151053000)
      librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f114bc0a000)
      libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f114b849000)
      libicuuc.so.60 => /usr/lib/x86_64-linux-gnu/libicuuc.so.60 (0x00007f114b491000)
      libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f114b274000)
      liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f114b04e000)
      libicudata.so.60 => /usr/lib/x86_64-linux-gnu/libicudata.so.60 (0x00007f11494a5000)
2020-09-02 15:33:46 -04:00
Ilias Karim a91c987552 Update Makefile with Swift 5.2.4 image 2020-06-18 14:51:45 -05:00
JP Simard d2643db495 [Docs] Build docs using jazzy (#3016)
* Add `.jazzy.yaml` configuration file
* Update `swiftlint generate-docs` to write docs to a directory rather than a single file
* Add jazzy to the Gemfile
* Run `bundle update`
* Add CI job to run jazzy automatically and publish to GitHub Pages

![swiftlint-jazzy](https://user-images.githubusercontent.com/474794/71799038-fcf4e180-3008-11ea-81fa-3eb9cf296506.gif)
2020-01-07 20:31:29 -08:00
Marcelo Fabri b695c696f9 Update make docker_test 2019-10-08 23:55:48 -07:00