Skip to content

[CI] Improve linters and git hooks #884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cron-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ jobs:
- uses: actions/checkout@v4.1.1
- uses: ./.github/actions/bootstrap
- run: bundle exec fastlane rubocop
- run: bundle exec fastlane run_swift_format lint:true
- run: bundle exec fastlane run_swift_format strict:true
- run: bundle exec fastlane pod_lint

slack:
Expand Down
17 changes: 5 additions & 12 deletions .github/workflows/smoke-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,13 @@ jobs:
if: ${{ github.event.inputs.record_snapshots_swiftui != 'true' && github.event.inputs.record_snapshots_uikit != 'true' }}
steps:
- uses: actions/checkout@v4.1.1
with:
fetch-depth: 0
- uses: ./.github/actions/bootstrap
- name: Public Interface Validation
run: bundle exec fastlane validate_public_interface
- name: Run Danger
run: bundle exec fastlane lint_pr
- name: Run Fastlane Linting
run: bundle exec fastlane rubocop
- name: Run SwiftFormat Linting
run: bundle exec fastlane run_swift_format lint:true
- name: Run Podspec Linting
- run: bundle exec fastlane validate_public_interface
- run: bundle exec fastlane lint_pr
- run: bundle exec fastlane rubocop
- run: bundle exec fastlane run_swift_format strict:true
- run: bundle exec fastlane pod_lint
if: startsWith(github.event.pull_request.head.ref, 'release/')
run: bundle exec fastlane pod_lint

build-xcode15:
name: Build SDKs (Xcode 15)
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
gem 'danger', group: :danger_dependencies
gem 'fastlane', group: :fastlane_dependencies
gem 'json'
gem 'lefthook'
gem 'rubocop', '1.38', group: :rubocop_dependencies
gem 'sinatra', group: :sinatra_dependencies
gem 'slather'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ GEM
rexml (>= 3.3.9)
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
lefthook (1.11.16)
logger (1.7.0)
method_source (1.1.0)
mini_magick (4.13.2)
Expand Down Expand Up @@ -427,6 +428,7 @@ DEPENDENCIES
fastlane-plugin-stream_actions (= 0.3.84)
fastlane-plugin-versioning
json
lefthook
plist
puma
rackup
Expand Down
14 changes: 5 additions & 9 deletions Scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@ trap "echo ; echo ❌ The Bootstrap script failed to finish without error. See t

source ./Githubfile

puts "Create git/hooks folder if needed"
mkdir -p .git/hooks

# Symlink hooks folder to .git/hooks folder
puts "Create symlink for pre-commit hooks"
# Symlink needs to be ../../hooks and not ./hooks because git evaluates them in .git/hooks
ln -sf ../../hooks/pre-commit.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
chmod +x ./hooks/git-format-staged
if [ "${GITHUB_ACTIONS:-}" != "true" ]; then
puts "Set up git hooks"
bundle install
bundle exec lefthook install
fi

if [ "${SKIP_MINT_BOOTSTRAP:-}" != true ]; then
puts "Bootstrap Mint dependencies"
Expand Down
17 changes: 10 additions & 7 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ reversed_gci = gci.split('.').reverse.join('.')
is_localhost = !is_ci
@force_check = false
swift_environment_path = File.absolute_path('../Sources/StreamVideo/Generated/SystemEnvironment+Version.swift')
swiftformat_excluded_paths = ["**/Generated", "**/generated", "**/protobuf", "**/OpenApi"]
swiftformat_source_paths = ["Sources", "DemoApp", "DemoAppUIKit", "StreamVideoTests", "StreamVideoSwiftUITests", "StreamVideoUIKitTests"]

before_all do |lane|
if is_ci
Expand Down Expand Up @@ -673,10 +671,13 @@ end
desc 'Run source code formatting/linting'
lane :run_swift_format do |options|
Dir.chdir('..') do
action = options[:lint] ? "--lint" : ""
swiftformat_source_paths.each do |path|
sh("mint run swiftformat #{action} --config .swiftformat --exclude #{swiftformat_excluded_paths.join(',')} #{path}")
sh("mint run swiftlint lint --config .swiftlint.yml --progress --quiet --reporter json #{path}")
strict = options[:strict] ? '--lint' : nil
sources_matrix[:swiftformat_include].each do |path|
sh("mint run swiftformat #{strict} --config .swiftformat --exclude #{sources_matrix[:swiftformat_exclude].join(',')} #{path}")
next if path.include?('Tests')

sh("mint run swiftlint lint --config .swiftlint.yml --fix --progress --quiet --reporter json #{path}") unless strict
sh("mint run swiftlint lint --config .swiftlint.yml --strict --progress --quiet --reporter json #{path}")
end
end
end
Expand Down Expand Up @@ -708,7 +709,9 @@ lane :sources_matrix do
documentation_tests: ['Sources', 'DocumentationTests', xcode_project],
size: ['Sources', xcode_project],
public_interface: ['Sources'],
ruby: ['fastlane']
ruby: ['fastlane'],
swiftformat_include: ["Sources", "DemoApp", "DemoAppUIKit", "StreamVideoTests", "StreamVideoSwiftUITests", "StreamVideoUIKitTests"],
swiftformat_exclude: ["**/Generated", "**/generated", "**/protobuf", "**/OpenApi"]
}
end

Expand Down
249 changes: 0 additions & 249 deletions hooks/git-format-staged

This file was deleted.

16 changes: 0 additions & 16 deletions hooks/pre-commit.sh

This file was deleted.

6 changes: 0 additions & 6 deletions hooks/regenerage-spm-package-if-needed.sh

This file was deleted.

Loading
Loading