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

Add danger #158

Merged
merged 7 commits into from
Jul 26, 2022
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
25 changes: 25 additions & 0 deletions .github/workflows/danger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Danger

on:
push:
branches: stable
pull_request:

jobs:
check:
name: Danger Check
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
-
name: Run Danger
run: bundle exec danger --verbose --dangerfile=rakelib/Dangerfile
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.danger_github_api_token }}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch:

jobs:
build:
cocoapods:
name: Push To CocoaPods
runs-on: ubuntu-latest
steps:
Expand All @@ -21,6 +21,22 @@ jobs:
bundler-cache: true
-
name: Push to CocoaPods
run: bundle exec pod trunk push StencilSwiftKit.podspec
run: bundle exec rake release:cocoapods
env:
COCOAPODS_TRUNK_TOKEN: "${{secrets.COCOAPODS_TRUNK_TOKEN}}"

github:
name: GitHub Release
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
-
name: Create release on GitHub
run: bundle exec rake release:github
2 changes: 1 addition & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ opt_in_rules:
- closure_end_indentation
- closure_spacing
- collection_alignment
- comment_spacing
- conditional_returns_on_newline
- contains_over_filter_count
- contains_over_filter_is_empty
Expand Down Expand Up @@ -61,7 +62,6 @@ opt_in_rules:
- optional_enum_case_matching
- overridden_super_call
- override_in_extension
- pattern_matching_keywords
- prefer_self_in_static_references
- prefer_self_type_over_type_of_self
- prefer_zero_over_explicit_init
Expand Down
13 changes: 5 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ _None_

### Internal Changes

_None_
* Add `Danger` to check pull requests.
[David Jennes](https://github.com/djbe)
[#158](https://github.com/SwiftGen/StencilSwiftKit/pull/158)

## 2.9.0

Expand All @@ -28,9 +30,7 @@ _None_
[David Jennes](https://github.com/djbe)
[#154](https://github.com/SwiftGen/StencilSwiftKit/pull/154)
[#156](https://github.com/SwiftGen/StencilSwiftKit/pull/156)
* The string filter `replace` can now accept an optional parameter `regex` to enable regular expressions, see the
[documentation](Documentation/filters-strings.md)
for more information.
* The string filter `replace` can now accept an optional parameter `regex` to enable regular expressions, see the [documentation](Documentation/filters-strings.md) for more information.
[David Jennes](https://github.com/djbe)
[JanGorman](https://github.com/JanGorman)
[#123](https://github.com/SwiftGen/StencilSwiftKit/pull/123)
Expand Down Expand Up @@ -129,10 +129,7 @@ _None_

### New Features

* The `set` tag can now directly accept an expression as value, see the
[documentation](Documentation/tag-set.md)
for an explanation on how this differs with the normal `set`/`endset`
pair.
* The `set` tag can now directly accept an expression as value, see the [documentation](Documentation/tag-set.md) for an explanation on how this differs with the normal `set`/`endset` pair.
[David Jennes](https://github.com/djbe)
[#87](https://github.com/SwiftGen/StencilSwiftKit/pull/87)
* Updated Stencil to the latest version (0.12.1).
Expand Down
11 changes: 6 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ source 'https://rubygems.org'

# The bare minimum for building, e.g. in Homebrew
group :build do
gem 'rake', '~> 13.0'
gem 'xcpretty', '~> 0.3'
gem 'rake', '~> 13.0'
gem 'xcpretty', '~> 0.3'
end

# In addition to :build, for contributing
group :development do
gem 'cocoapods', '~> 1.11'
gem 'rubocop', '~> 1.22'
gem 'cocoapods', '~> 1.11'
gem 'danger', '~> 8.4'
gem 'rubocop', '~> 1.22'
end

# For releasing to GitHub
group :release do
gem 'octokit', '~> 4.21'
gem 'octokit', '~> 4.7'
end
61 changes: 57 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ GEM
ast (2.4.2)
atomos (0.1.3)
claide (1.1.0)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
cocoapods (1.11.3)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
Expand Down Expand Up @@ -56,35 +60,81 @@ GEM
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.1.10)
cork (0.3.0)
colored2 (~> 3.1)
danger (8.6.1)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
cork (~> 0.1)
faraday (>= 0.9.0, < 2.0)
faraday-http-cache (~> 2.0)
git (~> 1.7)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.0)
no_proxy_fix
octokit (~> 4.7)
terminal-table (>= 1, < 4)
escape (0.0.4)
ethon (0.15.0)
ffi (>= 1.15.0)
faraday (2.3.0)
faraday-net_http (~> 2.0)
faraday (1.10.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-net_http (2.0.3)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-http-cache (2.4.0)
faraday (>= 0.8)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
ffi (1.15.5)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
git (1.11.0)
rchardet (~> 1.8)
httpclient (2.8.3)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json (2.6.2)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
minitest (5.16.2)
molinillo (0.8.0)
multipart-post (2.2.3)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
no_proxy_fix (0.1.2)
octokit (4.25.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
open4 (1.3.4)
parallel (1.22.1)
parser (3.1.2.0)
ast (~> 2.4.1)
public_suffix (4.0.7)
rainbow (3.1.1)
rake (13.0.6)
rchardet (1.8.0)
regexp_parser (2.5.0)
rexml (3.2.5)
rouge (2.0.7)
Expand All @@ -106,6 +156,8 @@ GEM
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (2.0.5)
Expand All @@ -127,7 +179,8 @@ PLATFORMS

DEPENDENCIES
cocoapods (~> 1.11)
octokit (~> 4.21)
danger (~> 8.4)
octokit (~> 4.7)
rake (~> 13.0)
rubocop (~> 1.22)
xcpretty (~> 0.3)
Expand Down
66 changes: 1 addition & 65 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/rake

require 'English'

unless defined?(Bundler)
Expand All @@ -12,69 +13,4 @@ POD_NAME = 'StencilSwiftKit'.freeze
MIN_XCODE_VERSION = 13.0
BUILD_DIR = File.absolute_path('./.build')

## [ Release a new version ] ##################################################

namespace :release do
desc 'Create a new release on CocoaPods'
task :new => [:check_versions, :check_tag_and_ask_to_release, 'spm:test', :cocoapods]

desc 'Check if all versions from the podspecs and CHANGELOG match'
task :check_versions do
results = []

# Check if bundler is installed first, as we'll need it for the cocoapods task (and we prefer to fail early)
`which bundler`
results << Utils.table_result(
$CHILD_STATUS.success?,
'Bundler installed',
'Please install bundler using `gem install bundler` and run `bundle install` first.'
)

# Extract version from podspec
podspec_version = Utils.podspec_version(POD_NAME)
Utils.table_info("#{POD_NAME}.podspec", podspec_version)

# Check if entry present in CHANGELOG
changelog_entry = system(%(grep -q '^## #{Regexp.quote(podspec_version)}$' CHANGELOG.md))
results << Utils.table_result(
changelog_entry,
'CHANGELOG, Entry added',
"Please add an entry for #{podspec_version} in CHANGELOG.md"
)

changelog_has_stable = system("grep -qi '^## Stable Branch' CHANGELOG.md")
results << Utils.table_result(
!changelog_has_stable,
'CHANGELOG, No stable',
'Please remove section for stable branch in CHANGELOG'
)

exit 1 unless results.all?
end

desc "Check tag and ask to release"
task :check_tag_and_ask_to_release do
results = []
podspec_version = Utils.podspec_version(POD_NAME)

tag_set = !`git ls-remote --tags . refs/tags/#{podspec_version}`.empty?
results << Utils.table_result(
tag_set,
'Tag pushed',
'Please create a tag and push it'
)

exit 1 unless results.all?

print "Release version #{podspec_version} [Y/n]? "
exit 2 unless STDIN.gets.chomp == 'Y'
end

desc "pod trunk push #{POD_NAME} to CocoaPods"
task :cocoapods do
Utils.print_header 'Pushing pod to CocoaPods Trunk'
sh "bundle exec pod trunk push #{POD_NAME}.podspec"
end
end

task :default => 'spm:test'
Loading