From 9fc6569d7326d1fdf9897bc19cea3af203979a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danny=20M=C3=B6sch?= Date: Mon, 20 Jan 2025 20:07:50 +0100 Subject: [PATCH 1/2] Move more build steps into Makefile --- .azure/templates/run-make.yml | 16 ++++++++++++++++ .buildkite/pipeline.yml | 14 ++++++-------- .gitignore | 3 +-- Makefile | 23 ++++++++++++++++++----- azure-pipelines.yml | 20 ++++++++------------ 5 files changed, 49 insertions(+), 27 deletions(-) create mode 100644 .azure/templates/run-make.yml diff --git a/.azure/templates/run-make.yml b/.azure/templates/run-make.yml new file mode 100644 index 0000000000..8861ec66d8 --- /dev/null +++ b/.azure/templates/run-make.yml @@ -0,0 +1,16 @@ +# Run the commands in the Makefile for the specified rule. + +parameters: + - name: rule + type: string + +steps: + - script: >- + awk ' + $0 ~ "${{ parameters.rule }}:" { in_rule = 1; next } + in_rule && /^\t/ { print $0 } + in_rule && !/^\t/ { in_rule = 0 } + ' Makefile | while IFS= read -r command; do + eval "$command" + done + displayName: Run `${{ parameters.rule }}` rule diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index e3c492c64d..4b14922990 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -4,23 +4,21 @@ steps: - echo "+++ Build" - bazel build :swiftlint - echo "+++ Test" - - bazel test --test_output=errors //Tests/... + - make bazel_test - label: "SwiftPM" commands: - echo "+++ Test" - - swift test --parallel -Xswiftc -DDISABLE_FOCUSED_EXAMPLES + - make spm_test - label: "Danger" commands: - - echo "--- Install Bundler" + - echo "+++ Install Bundler" - gem install bundler -v 2.4.22 - - echo "--- Bundle Install" - - bundle install - - echo "+++ Run Danger" - - bundle exec danger --verbose + - echo "+++ Run OSS Scan" + - make oss_scan - label: "TSan Tests" commands: - echo "+++ Test" - - bazel test --test_output=errors --build_tests_only --features=tsan --test_timeout=1000 //Tests/... + - make bazel_test_tsan - label: "Sourcery" commands: - echo "+++ Run Sourcery" diff --git a/.gitignore b/.gitignore index 8e3b6a8960..05b0f8961a 100644 --- a/.gitignore +++ b/.gitignore @@ -60,8 +60,7 @@ Packages/ .DS_Store # Bundler -.bundle/ -bundle/ +.bundler/ # Bazel bazel-* diff --git a/Makefile b/Makefile index f0b09ff520..2296621325 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,13 @@ test_tsan: swift build --build-tests $(TSAN_SWIFT_BUILD_FLAGS) DYLD_INSERT_LIBRARIES=$(TSAN_LIB) $(TSAN_XCTEST) $(TSAN_TEST_BUNDLE) +spm_build_plugins: + swift build -c release --product SwiftLintCommandPlugin + swift build -c release --product SwiftLintBuildToolPlugin + +spm_test: + swift test --parallel -Xswiftc -DDISABLE_FOCUSED_EXAMPLES + write_xcodebuild_log: xcodebuild -scheme swiftlint clean build-for-testing -destination "platform=macOS" > xcodebuild.log @@ -147,6 +154,9 @@ package: $(SWIFTLINT_EXECUTABLE) bazel_test: bazel test --test_output=errors //Tests/... +bazel_test_tsan: + bazel test --test_output=errors --build_tests_only --features=tsan --test_timeout=1000 //Tests/... + bazel_release: $(SWIFTLINT_EXECUTABLE) bazel build :release mv -f bazel-bin/bazel.tar.gz bazel-bin/bazel.tar.gz.sha256 $(SWIFTLINT_EXECUTABLE) . @@ -167,17 +177,20 @@ display_compilation_time: formula_bump: brew update && brew bump-formula-pr --tag=$(shell git describe --tags) --revision=$(shell git rev-parse HEAD) swiftlint -pod_publish: +bundle_install: bundle install + +oss_scan: bundle_install + bundle exec danger --verbose + +pod_publish: bundle_install bundle exec pod trunk push SwiftLint.podspec -pod_lint: - bundle install +pod_lint: bundle_install bundle exec pod lib lint --verbose SwiftLint.podspec -docs: +docs: bundle_install swift run swiftlint generate-docs - bundle install bundle exec jazzy get_version: diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f9bfe1dc97..81af9d715e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,8 +11,9 @@ jobs: vmImage: 'ubuntu-24.04' # "Noble Numbat" container: swift:6.0-noble steps: - - script: swift test --parallel -Xswiftc -DDISABLE_FOCUSED_EXAMPLES - displayName: Run tests + - template: .azure/templates/run-make.yml + parameters: + rule: spm_test - job: bazel_linux displayName: 'Bazel, Linux : Swift 6' @@ -47,7 +48,7 @@ jobs: variables: DEVELOPER_DIR: /Applications/Xcode_$(xcode).app steps: - - script: swift test --parallel -Xswiftc -DDISABLE_FOCUSED_EXAMPLES + - script: make spm_test displayName: Run tests - job: plugins_linux # Plugins shall be able to run on older Swift versions. @@ -65,10 +66,9 @@ jobs: image: swift:6.0-noble container: $[ variables['image'] ] steps: - - script: swift build -c release --product SwiftLintCommandPlugin - displayName: Build command plugin - - script: swift build -c release --product SwiftLintBuildToolPlugin - displayName: Build build tool plugin + - template: .azure/templates/run-make.yml + parameters: + rule: spm_build_plugins - job: Jazzy pool: @@ -76,11 +76,7 @@ jobs: variables: DEVELOPER_DIR: /Applications/Xcode_15.4.app steps: - - script: swift run swiftlint generate-docs - displayName: Generate documentation - - script: bundle install --path vendor/bundle - displayName: Install dependencies - - script: bundle exec jazzy + - script: make docs displayName: Run Jazzy - script: > if ruby -rjson -e "j = JSON.parse(File.read('docs/undocumented.json')); exit j['warnings'].length != 0"; then From 3a15c7bb06a5e53d2e6ef2bf2b8c18724a9c210f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danny=20M=C3=B6sch?= Date: Thu, 23 Jan 2025 18:52:22 +0100 Subject: [PATCH 2/2] Reset .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 05b0f8961a..8e3b6a8960 100644 --- a/.gitignore +++ b/.gitignore @@ -60,7 +60,8 @@ Packages/ .DS_Store # Bundler -.bundler/ +.bundle/ +bundle/ # Bazel bazel-*