38 Commits

Author SHA1 Message Date
Danny Mösch 0c7eb017e2 Use default bundled Bundler (#6397) 2025-12-26 20:55:22 +00:00
JP Simard 775174b03a [CI] Use Bazel for "Register" job (#6110)
Which should be much faster than the previous SwiftPM build in the
common case of not having to rebuild SwiftSyntax.
2025-06-19 21:42:00 -04:00
Danny Mösch d2e4fc31a7 Add legit example implementation to rule template 2025-03-27 21:29:44 +01:00
Danny Mösch 9710148f76 Replace Sourcery with internal implementation (#6034)
Tasks we perform with Sourcery are rather simple and can be replaced
with a basic collection of files and the generation of lists in the
new `swiftlint-dev` command. This spares contributors from installing
either Sourcery or Bazel.
2025-03-26 20:38:53 +00:00
Danny Mösch 043f9cac5b Introduce internal CLI to simplify development tasks (#6032)
Start with a command that generates a template for a new SwiftSyntax
rule. This tool could remain separate or be merged into the official
binary under a `dev` sub-command at a later point in time.
2025-03-23 01:21:41 +01:00
Danny Mösch 92d48b864a Generate summary in OSS check (#6023)
The file listing more fine-grained differences between new and fixed
violations can be downloaded from the job on Buildkite.
2025-03-16 14:32:43 +01:00
Danny Mösch a4db2f65c0 Skip integration tests in CI intentionally (#6017) 2025-03-09 20:26:39 +01:00
Danny Mösch 375be43147 Make Danger run first 2025-02-16 14:14:01 +01:00
Danny Mösch 6cf862c655 Move more build steps into Makefile (#5975) 2025-01-23 18:05:21 +00:00
Danny Mösch 532bc5a770 Remove option for strict concurrency checking (#5910) 2024-12-23 15:40:21 +00:00
Danny Mösch cffb331009 Fix spurious Bazel build errors (#5756) 2024-08-18 20:53:57 +00:00
Danny Mösch 3d29c67424 Use explicit version for Bundler (#5395) 2023-12-15 17:34:34 +00:00
JP Simard 3eb3772022 Compile with -strict-concurrency=complete (#5320)
* Compile with `-strict-concurrency=complete`

Only in Bazel for now, because this is considered an unsafe flag in
SwiftPM which would lead to warnings for downstream consumers of
SwiftLint using SwiftPM.

Some imports of SwiftSyntax need the `@preconcurrency` annotation until
https://github.com/apple/swift-syntax/pull/2322 is available in a
release.

The following SwiftLint libraries have `-strict-concurrency=complete`
applied:

* SwiftLintCoreMacros
* SwiftLintBuiltInRules
* SwiftLintExtraRules

The following SwiftLint libraries don't have the flag applied and need
to be migrated:

* SwiftLintCore
* swiftlint (CLI target)

So really the rules and macros are now being compiled with
`-strict-concurrency=complete`, but the core infrastructure of SwiftLint
is not.

Still, given that Swift 6 will eventually make these warnings errors by
default, it's good to prevent issues from creeping in earlier rather
than later.

* Add CI job to build with strict concurrency
2023-11-01 15:20:40 +00:00
JP Simard bc642d42d0 Clean up CI changes for Xcode 15 transition (#5237)
These shouldn't be needed anymore now that CI has Xcode 15 selected
2023-09-26 01:51:53 +00:00
JP Simard 406d4d270b Require Swift 5.9 (#5235)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2023-09-25 18:54:02 -04:00
JP Simard 5802fd99b1 Parallelize TSan tests on CI (#5002) 2023-05-12 09:54:27 -04:00
JP Simard 74b82daba0 [CI] Use rbenv to manage Ruby (#4893)
And pin the Ruby version to 2.7.5. rbenv was installed on all CI
machines using Homebrew, with Ruby 2.7.5 installed and set as the
global version. The `pre-command` script was also updated on all agents
to add rbenv binaries to the path and run `rbenv init`.

Remove rules_ruby integration and just use rbenv and ruby directly.
2023-04-14 16:23:05 +00: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
JP Simard 81f1dbfd1b [CI] Stop running "Analyze" job (#4728)
it's extremely time-consuming, taking 25 minutes lately, and we'll
hopefully have a better solution soon with the upcoming improvements
to dead code detection, taking less than 1 second to run.

```
(1/4) Collecting units and records (0.25s)
(2/4) Collecting protocol conformances (0.26s)
(3/4) Collecting declarations and references (0.04s)
(4/4) Calculating unused declarations (0.05s)
Source/SwiftLintFramework/Extensions/Configuration+IndentationStyle.swift:16:18: error: Unused declaration named 'init(_:)'
Source/SwiftLintFramework/Models/LinterCache.swift:53:13: error: Unused declaration named 'init(cache:location:fileManager:swiftVersion:)'
Source/SwiftLintFramework/Models/SwiftVersion.swift:25:16: error: Unused declaration named 'fiveDotTwo'
Source/SwiftLintFramework/Models/SwiftVersion.swift:27:16: error: Unused declaration named 'fiveDotThree'
Source/SwiftLintFramework/Models/SwiftVersion.swift:31:16: error: Unused declaration named 'fiveDotFive'
Source/SwiftLintFramework/Rules/Lint/CompilerProtocolInitRule.swift:85:5: error: Unused declaration named 'init(protocolName:types:arguments:)'
Found 6 unused declarations (0.61s)
```
2023-01-27 19:51:13 -05:00
JP Simard d120f41181 [CI] Remove 'TSan Runs' job (#4701)
This frequently crashes and I don't think it's due to a real TSan race.

E.g. https://buildkite.com/swiftlint/swiftlint/builds/4912#0185c098-a803-4525-8df1-827d1c97ed01

```
swiftlint(373,0x1ecdd3a80) malloc: nano zone abandoned due to inability to preallocate reserved vm space.
Linting Swift files in current working directory
1 of 538 [                              ] ETA: 0s (13129 files/s)
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
ThreadSanitizer:DEADLYSIGNAL
==373==ERROR: ThreadSanitizer: SEGV on unknown address 0x000000000008 (pc 0x000102cbe380 bp 0x00016f50ee00 sp 0x00016f50edc0 T30753687)
==373==The signal is caused by a UNKNOWN memory access.
==373==Hint: address points to the zero page.
    #0 __tsan::ThreadClock::release(__tsan::DenseSlabAllocCache*, __tsan::SyncClock*) <null>:46801128 (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x2a380)
    #1 __tsan::Release(__tsan::ThreadState*, unsigned long, unsigned long) <null>:46801128 (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x7456c)
    #2 swift::runJobInEstablishedExecutorContext(swift::Job*) <null>:46801128 (libswift_Concurrency.dylib:arm64e+0x40588)
    #3 swift_job_runImpl(swift::Job*, swift::ExecutorRef) <null>:46801128 (libswift_Concurrency.dylib:arm64e+0x41404)
    #4 _dispatch_root_queue_drain <null>:46801128 (libdispatch.dylib:arm64e+0x15f90)
    #5 _dispatch_worker_thread2 <null>:46801128 (libdispatch.dylib:arm64e+0x167bc)
    #6 _pthread_wqthread <null>:46801128 (libsystem_pthread.dylib:arm64e+0x30c0)
    #7 start_wqthread <null>:46801128 (libsystem_pthread.dylib:arm64e+0x1e1c)

==373==Register values:
 x[0] = 0x0000000102a53458   x[1] = 0x0000000000000538   x[2] = 0x0000000000000000   x[3] = 0x0000000000000000
 x[4] = 0x0000000000000001   x[5] = 0x0000000000000000   x[6] = 0x0095000004220122   x[7] = 0x0000000000000001
 x[8] = 0x0000000000000008   x[9] = 0x0000000000000000  x[10] = 0x0000000000000000  x[11] = 0x0000000000000000
x[12] = 0x0000000000000020  x[13] = 0x0000000110904040  x[14] = 0x0000000000000000  x[15] = 0x0000000106251910
x[16] = 0x0000000104190960  x[17] = 0x0000000000200018  x[18] = 0x0000000000000000  x[19] = 0x000000010f5d3488
x[20] = 0x0000000109ca03f0  x[21] = 0x0000000102a53458  x[22] = 0x0000000109ca03f0  x[23] = 0x0000000109cc0078
x[24] = 0x00040c0000fd77c4  x[25] = 0x0000010000000000  x[26] = 0x00000002287898f8  x[27] = 0x0000000000000000
x[28] = 0x000000016f50f0e0     fp = 0x000000016f50ee00     lr = 0x0000000102cbe360     sp = 0x000000016f50edc0
ThreadSanitizer can not provide additional info.
SUMMARY: ThreadSanitizer: SEGV (libclang_rt.tsan_osx_dynamic.dylib:arm64e+0x2a380) in __tsan::ThreadClock::release(__tsan::DenseSlabAllocCache*, __tsan::SyncClock*)+0x174
==373==ABORTING
```
2023-01-17 11:42:46 -05:00
JP Simard db6aea5d07 Disable remote cache for the "TSan Runs" CI job (#4700)
I suspect it might be the reason why it occasionally crashes.
2023-01-17 11:24:48 -05:00
JP Simard 0e53e19cb1 [CI] Increase timeout for analyze CI job to 60 minutes (#4654)
I recently moved CI machines over to use Xcode 14.2 and it's possible
that running SwiftLint analyzer rules now take longer.
2022-12-21 17:37:44 -05:00
JP Simard e9c1128b86 Move SwiftPM CI job to Buildkite (#4589)
We have 6 CI machines now and these should run faster on bare metal
machines with lots of stuff already cached, like starting with an
existing git repo.
2022-11-24 17:58:09 +00:00
JP Simard b4f45aa55e Move TSan Runs CI job to Buildkite (#4457)
Now that we have more Buildkite machines, these should be faster than
running on Azure Pipelines.

Also remove the `//bazel:xcode_config` configurations since they should
no longer be in use.
2022-10-23 13:05:28 -04:00
JP Simard 7af26f0f77 [CI] Increase TSan test timeout to 1,000 seconds (~16 minutes) (#4298)
We're starting to hit this timeout.
2022-10-05 20:45:07 -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 0fd9a112b4 [CI] Run Danger with Bazel (#4138)
It'd be nice to avoid needing to maintain rbenv on CI
2022-08-28 22:58:39 -04:00
JP Simard eb14f5283c Speed up Analyze CI job (#4136)
By merging `write_swiftpm_yaml` into analyze test
2022-08-28 22:35:42 -04:00
JP Simard 7259c02ee5 Teach --compile-commands to parse SwiftPM yaml files (#4119)
And move analyze CI job to Bazel

Which will benefit from caching previous results,
so if we make a PR that doesn't impact the analysis
results (i.e. changelog or docs) we might be able to
skip running this at all.
2022-08-23 11:01:13 -04:00
JP Simard 2960ae6a7a Test with thread sanitizer in Buildkite using Bazel (#4115)
This will allow for the test to be skipped if it's already cached,
speeding up CI runs.
2022-08-22 19:21:54 -04:00
JP Simard 5e1eaea148 Improve Buildkite grouping (#4086)
Reference: https://buildkite.com/docs/pipelines/managing-log-output
2022-08-12 00:02:13 -04:00
JP Simard 21ba7c8280 Update SourceKitten to 0.33.0 (#4085)
https://github.com/jpsim/SourceKitten/releases/tag/0.33.0
2022-08-11 21:04:32 +00:00
JP Simard adec1c76ee Show Bazel test errors on CI 2022-08-10 15:03:44 -04:00
JP Simard cc7c400e81 Run bazel tests in sandbox on CI
By setting `IN_PROCESS_SOURCEKIT=1` as `--test_env`
2022-08-07 22:00:10 -04:00
JP Simard 8b90623b38 [Bazel] Set up tests (#4055)
Run with `bazel test --spawn_strategy=standalone //Tests/...`

Consumers who define rules via `swiftlint_extra_rules` can run tests for
their custom rules too:

```
./bazelw test \
  --spawn_strategy=standalone \
  @SwiftLint//Tests:ExtraRulesTests
```
2022-07-28 19:14:03 +00:00
JP Simard cb5fa0425d Move Analyze CI job to Buildkite (#3919)
We now have two Buildkite agents thanks to a newly added M1 Mac mini
from MacStadium. Running the analyze job should be considerably faster
than the VMs that run on Azure Pipelines, although still slower than
if we were to run them with Xcode 13.2.1 because of the performance
regressions described in https://github.com/realm/SwiftLint/issues/3920.
2022-04-05 12:05:38 -04:00
JP Simard 9ace4bbb73 Don't pass --path to bundle install (#3918)
> [DEPRECATED] The `--path` flag is deprecated because it relies on
> being remembered across bundler invocations, which bundler will no
> longer do in future versions. Instead please use
> `bundle config set path 'vendor/bundle'`, and stop using this flag
2022-03-24 10:12:32 -04:00
JP Simard c664c4f9e6 Move Buildkite pipeline config to repo (#3893)
These were previously defined in Buildkite itself.
2022-03-11 16:27:17 -05:00