Skip to content

Commit

Permalink
Migrate to GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
palkan committed Jun 11, 2020
1 parent 1487506 commit 762c048
Show file tree
Hide file tree
Showing 20 changed files with 265 additions and 63 deletions.
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
First of all, thanks for your report/suggestion/whatever!
This template is for bug reports. If you are reporting a bug, please continue on. If you are here for another reason,
feel free to skip the rest of this template.
-->

### Tell us about your environment

**Ruby version:**

**`litecable` gem version:**

**`anycable` gem version:**

**`grpc` gem version:**

### What did you do?

### What did you expect to happen?

### What actually happened?

<!--
Please, provide reproduction script (using this template (https://github.com/anycable/anycable/blob/master/etc/bug_report_template.rb)
when submitting bugs if possible.
-->
31 changes: 31 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
First of all, thanks for contributing!
If it's a typo fix or minor documentation update feel free to skip the rest of this template!
-->

## Summary

<!--
If it's a bug fix, then link it to the issue, for example:
Fixes #xxx
-->

## Changes

- [ ] Change A

### Checklist

- [ ] I've added tests for this change
- [ ] I've added a Changelog entry
- [ ] I've updated Readme

<!--
---
Add any additional information in the end of the description after a horizontal line
-->
72 changes: 72 additions & 0 deletions .github/workflows/docs-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Lint Docs

on:
push:
branches:
- master
paths:
- "README.md"
- "CHANGELOG.md"
pull_request:
paths:
- "README.md"
- "CHANGELOG.md"

jobs:
markdownlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: Run Markdown linter
run: |
gem install mdl
mdl CHANGELOG.md README.md
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: Lint Markdown files with RuboCop
run: |
gem install bundler
bundle install --gemfile gemfiles/rubocop.gemfile --jobs 4 --retry 3
bundle exec --gemfile gemfiles/rubocop.gemfile rubocop -c .rubocop-md.yml
forspell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Hunspell
run: |
sudo apt-get install hunspell
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: Cache installed gems
uses: actions/cache@v1
with:
path: /home/runner/.rubies/ruby-2.7.0/lib/ruby/gems/2.7.0
key: gems-cache-${{ runner.os }}
- name: Install Forspell
run: gem install forspell
- name: Run Forspell
run: forspell CHANGELOG.md README.md
liche:
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.13.x
- name: Run liche
run: |
export PATH=$PATH:$(go env GOPATH)/bin
go get -u github.com/raviqqe/liche
liche README.md CHANGELOG.md
21 changes: 21 additions & 0 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint Ruby

on:
push:
branches:
- master
pull_request:

jobs:
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: Lint Ruby code with RuboCop
run: |
gem install bundler
bundle install --gemfile gemfiles/rubocop.gemfile --jobs 4 --retry 3
bundle exec --gemfile gemfiles/rubocop.gemfile rubocop
40 changes: 40 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build

on:
push:
branches:
- master
pull_request:

jobs:
test:
runs-on: ubuntu-latest
env:
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
BUNDLE_FORCE_RUBY_PLATFORM: 1
CI: true
strategy:
fail-fast: false
matrix:
ruby: ["2.5", "2.6", "2.7", "truffleruby"]
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v1
with:
path: /home/runner/bundle
key: bundle-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}-${{ hashFiles('**/Gemfile') }}
restore-keys: |
bundle-${{ matrix.ruby }}-
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Bundle install
run: |
bundle config path /home/runner/bundle
bundle config --global gemfile ${{ matrix.gemfile }}
bundle install
bundle update
- name: Run RSpec
run: |
bundle exec rspec
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ Gemfile.local
*.gem
tmp/
coverage/
gemfiles/*.lock
1 change: 1 addition & 0 deletions .mdlrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rules "~MD013", "~MD033", "~MD041"
31 changes: 31 additions & 0 deletions .rubocop-md.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
inherit_from: ".rubocop.yml"

require:
- rubocop-md


AllCops:
Include:
- '**/*.md'

Lint/Void:
Exclude:
- '**/*.md'

Lint/DuplicateMethods:
Exclude:
- '**/*.md'

# See https://github.com/rubocop-hq/rubocop/issues/4222
Lint/AmbiguousBlockAssociation:
Exclude:
- '**/*.md'


Naming/FileName:
Exclude:
- '**/*.md'

Layout/InitialIndentation:
Exclude:
- 'CHANGELOG.md'
25 changes: 0 additions & 25 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,3 @@ Style/TrailingCommaInArrayLiteral:

Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: no_comma

Layout/AlignParameters:
EnforcedStyle: with_first_parameter

Lint/Void:
Exclude:
- '**/*.md'

# See https://github.com/rubocop-hq/rubocop/issues/4222
Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/**/*'
- '**/*.md'

Lint/DuplicateMethods:
Exclude:
- '**/*.md'

Naming/FileName:
Exclude:
- '**/*.md'

Layout/InitialIndentation:
Exclude:
- 'CHANGELOG.md'
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ LITECABLE_BROADCAST_ADAPTER=any_cable ruby my_app.rb

## 0.4.1 (2017-02-04)

- Use `websocket-ruby` with subprotocols support ([@palkan][])
- Use `websocket-ruby` with sub-protocols support ([@palkan][])

## 0.4.0 (2017-01-29)

Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
source 'https://rubygems.org'

eval_gemfile "gemfiles/rubocop.gemfile"

# Specify your gem's dependencies in litecable.gemspec
gemspec
20 changes: 7 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Gem Version](https://badge.fury.io/rb/litecable.svg)](https://rubygems.org/gems/litecable)
[![Build Status](https://travis-ci.org/palkan/litecable.svg?branch=master)](https://travis-ci.org/palkan/litecable)
[![Build](https://github.com/palkan/litecable/workflows/Build/badge.svg)](https://github.com/palkan/litecable/actions)

# Lite Cable

Expand All @@ -26,17 +26,11 @@ Add this line to your application's Gemfile:
gem "litecable"
```

And then execute:

$ bundle

Or install it yourself as:

$ gem install litecable
And run `bundle install`.

## Usage

Please, checkout [Action Cable guides](http://guides.rubyonrails.org/action_cable_overview.html) for general information. Lite Cable aims to be compatible with Action Cable as much as possible without the loss of simplicity and _ligthness_.
Please, checkout [Action Cable guides](http://guides.rubyonrails.org/action_cable_overview.html) for general information. Lite Cable aims to be compatible with Action Cable as much as possible without the loss of simplicity and _lightness_.

You can use Action Cable javascript client without any change (precompiled version can be found [here](https://github.com/palkan/litecable/tree/master/examples/sinatra/assets/cable.js)).

Expand Down Expand Up @@ -86,21 +80,21 @@ end

Lite Cable is AnyCable-compatible out-of-the-box:

1. Set broadcast adapter to AnyCable:
- Set broadcast adapter to AnyCable:

```ruby
LiteCable.broadcast_adapter = :any_cable
```

You can also do this via configuration, e.g., env var (`LITECABLE_BROADCAST_ADAPTER=any_cable`) or `broadcast_adapter: any_cable` in a YAML config.

2. Configure connection factory:
- Configure connection factory:

```ruby
AnyCable.connection_factory = MyApp::Connection
```

Then run AnyCable alongs with the app:
Then run AnyCable along with the app:

```sh
bundle exec anycable
Expand Down Expand Up @@ -133,4 +127,4 @@ Bug reports and pull requests are welcome on GitHub at [https://github.com/palka

## License

The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
The gem is available as open source under the terms of the [MIT License](./LICENSE.txt).
6 changes: 6 additions & 0 deletions forspell.dict
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: one word per line. Empty lines and #-comments are supported too.
# If you want to add word with its forms, you can write 'word: example' (without quotes) on the line,
# where 'example' is existing word with the same possible forms (endings) as your word.
# Example: deduplicate: duplicate
Adapterize
Hanami
4 changes: 4 additions & 0 deletions gemfiles/rubocop.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "https://rubygems.org" do
gem "rubocop-md", "~> 0.3"
gem "standard", "~> 0.2.0"
end
4 changes: 2 additions & 2 deletions lib/lite_cable/broadcast_adapters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ def lookup_adapter(args)
# We couldn't require the adapter itself.
if e.path == path_to_adapter
raise e.class, "Couldn't load the '#{adapter}' broadcast adapter for LiteCable",
e.backtrace
e.backtrace
# Bubbled up from the adapter require.
else
raise e.class, "Error loading the '#{adapter}' broadcast adapter for LiteCable",
e.backtrace
e.backtrace
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/lite_cable/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ class Config < Anyway::Config
config_name :litecable

attr_config :logger,
coder: Coders::JSON,
broadcast_adapter: :memory,
identifier_coder: Coders::Raw,
log_level: Logger::INFO
coder: Coders::JSON,
broadcast_adapter: :memory,
identifier_coder: Coders::Raw,
log_level: Logger::INFO
end
end
4 changes: 2 additions & 2 deletions lib/lite_cable/connection/subscriptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def perform_action(identifier, data)
def execute_command(data)
command = data.delete("command")
case command
when "subscribe" then add(data["identifier"])
when "subscribe" then add(data["identifier"])
when "unsubscribe" then remove(data["identifier"])
when "message" then perform_action(data["identifier"], data["data"])
when "message" then perform_action(data["identifier"], data["data"])
else
raise UnknownCommandError, "Command not found #{command}"
end
Expand Down
Loading

0 comments on commit 762c048

Please sign in to comment.