Skip to content
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

Switch to Xcode12 and MacOS 10.15 for CI #67

Merged
merged 1 commit into from
Oct 13, 2020
Merged
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 .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: swift
os: osx
osx_image: xcode11.5
osx_image: xcode12
script:
- ./Scripts/brew.sh && make lint
- make clean build
Expand Down
34 changes: 34 additions & 0 deletions Scripts/Formulas/swiftformat.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Swiftformat < Formula
desc "Formatting tool for reformatting Swift code"
homepage "https://github.com/nicklockwood/SwiftFormat"
url "https://github.com/nicklockwood/SwiftFormat/archive/0.40.13.tar.gz"
sha256 "a61441673b0ef3c4c088b873fed377866a230c2ff3ba0d5e91f2a105664be05d"
head "https://github.com/nicklockwood/SwiftFormat.git", :shallow => false

bottle do
cellar :any_skip_relocation
sha256 "216b41d26aefdd32f278d56b91a6394cb32d06295c3338ebd982ddcbc74b6d3c" => :catalina
sha256 "5db9699c3a6be7d2fa9713e229719fdf0fbb64254f8491860eb67bc71d8c3b01" => :mojave
sha256 "7011a5ed4606fe67d98e855a0515eccdaf9f1b30e582f5adbfbde1cdaac48f4e" => :high_sierra
end

depends_on :xcode => ["10.1", :build]

def install
xcodebuild "-project",
"SwiftFormat.xcodeproj",
"-scheme", "SwiftFormat (Command Line Tool)",
"CODE_SIGN_IDENTITY=",
"SYMROOT=build", "OBJROOT=build"
bin.install "build/Release/swiftformat"
end

test do
(testpath/"potato.swift").write <<~EOS
struct Potato {
let baked: Bool
}
EOS
system "#{bin}/swiftformat", "#{testpath}/potato.swift"
end
end
30 changes: 30 additions & 0 deletions Scripts/Formulas/swiftlint.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Swiftlint < Formula
desc "Tool to enforce Swift style and conventions"
homepage "https://github.com/realm/SwiftLint"
url "https://github.com/realm/SwiftLint.git",
:tag => "0.35.0",
:revision => "8dc8421a49f2b74f79da3ef514a26249027309b9"
head "https://github.com/realm/SwiftLint.git"

bottle do
cellar :any_skip_relocation
sha256 "fd44022dfec1c42bd2041aebbff5dd5e6b23d9cd3b129e03c9c39cbef3280790" => :catalina
sha256 "1cc25d57420ea3a42f6156b733e926e91494a3b0b01caba8e7be15a0fbf107b9" => :mojave
sha256 "3985b4244c0fc5035fbfcddb1234b299b4390821a5f463d2d809f548067cb7bf" => :high_sierra
end

depends_on :xcode => ["10.0", :build]
depends_on :xcode => "8.0"

def install
system "make", "prefix_install", "PREFIX=#{prefix}", "TEMPORARY_FOLDER=#{buildpath}/SwiftLint.dst"
end

test do
(testpath/"Test.swift").write "import Foundation"
assert_match "Test.swift:1:1: warning: Trailing Newline Violation: Files should have a single trailing newline. (trailing_newline)",
shell_output("SWIFTLINT_SWIFT_VERSION=3 SWIFTLINT_DISABLE_SOURCEKIT=1 #{bin}/swiftlint lint --no-cache").chomp
assert_match version.to_s,
shell_output("#{bin}/swiftlint version").chomp
end
end
19 changes: 9 additions & 10 deletions Scripts/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@
function install_formula {
brew list $1 2> /dev/null
if [[ $? == 0 ]] ; then
brew outdated "$2" || brew reinstall "$2"
else
brew install "$2"
brew list "$1" && brew uninstall "$1"
fi
brew install "$1.rb"
}

function main {
# 0.35.0
SWIFTLINT_FORMULA="https://raw.githubusercontent.com/Homebrew/homebrew-core/a150ab2162228b957db1871947315f2278b21252/Formula/swiftlint.rb"

# 0.40.13
SWIFTFORMAT_FORMULA="https://raw.githubusercontent.com/Homebrew/homebrew-core/cd3ba980c503d06fdc8daf796e2ddb795685b555/Formula/swiftformat.rb"
# go to formulas
pushd "Scripts/Formulas"

# disable homebrew auto update
export HOMEBREW_NO_AUTO_UPDATE=1

# install (or reinstall) swiftlint
install_formula swiftlint $SWIFTLINT_FORMULA
install_formula swiftlint

# install (or reinstall) swiftformat
install_formula swiftformat $SWIFTFORMAT_FORMULA
install_formula swiftformat

# go back
popd
}

main