Skip to content

Commit

Permalink
Merge pull request #11 from RakuyoKit/feature/update-tool
Browse files Browse the repository at this point in the history
feat: Update tools
  • Loading branch information
rakuyoMo authored Apr 25, 2024
2 parents 9e64227 + b0be3ee commit 03b1275
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 6 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@
name: Swift Build

on:
push:
branches: [main]
paths: ["**/*.swift"]
pull_request:
branches: [main]
paths: ["**/*.swift"]
workflow_dispatch:

jobs:
Expand Down
2 changes: 2 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
pre-commit = "3.7.0"
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
default_install_hook_types: [pre-commit, pre-push]
fail_fast: true

repos:
- repo: local
hooks:
- id: lint
name: Run Lint
language: system
entry: rake swift:lint
stages: [pre-commit]
verbose: true
- id: build
name: Run Build
language: system
entry: rake swift:build
stages: [pre-push]
verbose: true
50 changes: 48 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,53 @@
FORMAT_COMMAND = 'swift package --allow-writing-to-package-directory format'
BUILD_COMMAND = 'xcodebuild -scheme RakuyoKit -destination'
namespace :env do
MISE_EXEC_PREFIX = 'mise exec --'

desc 'Init env'
task :init do
if File.exist?('.mise.toml')
install_mise
puts "mise installed: #{`mise --version`}"
sh "mise install"
end

if File.exist?('.pre-commit-config.yaml')
Rake::Task['env:githook'].invoke
end
end

desc 'Install git hook'
task :githook do
sh "#{MISE_EXEC_PREFIX} pre-commit install"
end

def install_mise
output = `which mise >/dev/null 2>&1`
if $?.success?
return
end

puts "mise not found, installing..."
sh "curl https://mise.run | sh"

case ENV['SHELL']
when /bash/
sh 'echo "eval \"\$(~/.local/bin/mise activate bash)\"" >> ~/.bashrc'
sh "source ~/.bashrc"

when /zsh/
sh 'echo "eval \"\$(~/.local/bin/mise activate zsh)\"" >> ~/.zshrc'
sh "zsh -c 'source ~/.zshrc'"

else
puts "Unknown shell env!"
exit 1
end
end
end

namespace :swift do
FORMAT_COMMAND = 'swift package --allow-writing-to-package-directory format'
BUILD_COMMAND = 'xcodebuild -scheme RakuyoKit -destination'

desc 'Run Format'
task :format do
sh FORMAT_COMMAND
Expand Down

0 comments on commit 03b1275

Please sign in to comment.