Skip to content

Commit

Permalink
Modernize gem.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 13, 2024
1 parent c4e536c commit 33103f2
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 42 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/documentation-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Documentation Coverage

on: [push, pull_request]

permissions:
contents: read

env:
CONSOLE_OUTPUT: XTerm
COVERAGE: PartialSummary

jobs:
validate:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.3"
bundler-cache: true

- name: Validate coverage
timeout-minutes: 5
run: bundle exec bake decode:index:coverage lib
4 changes: 2 additions & 2 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
run: bundle exec bake utopia:project:static --force no

- name: Upload documentation artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3
with:
path: docs

Expand All @@ -55,4 +55,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3
uses: actions/deploy-pages@v4
24 changes: 24 additions & 0 deletions .github/workflows/rubocop.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: RuboCop

on: [push, pull_request]

permissions:
contents: read

env:
CONSOLE_OUTPUT: XTerm

jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
bundler-cache: true

- name: Run RuboCop
timeout-minutes: 10
run: bundle exec rubocop
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Coverage
name: Test Coverage

on: [push, pull_request]

Expand Down Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Run tests
timeout-minutes: 5
run: bundle exec bake test

- uses: actions/upload-artifact@v3
with:
name: coverage-${{matrix.os}}-${{matrix.ruby}}
Expand Down
46 changes: 46 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
AllCops:
DisabledByDefault: true

Layout/IndentationStyle:
Enabled: true
EnforcedStyle: tabs

Layout/InitialIndentation:
Enabled: true

Layout/IndentationWidth:
Enabled: true
Width: 1

Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: normal

Layout/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: start_of_line

Layout/BeginEndAlignment:
Enabled: true
EnforcedStyleAlignWith: start_of_line

Layout/ElseAlignment:
Enabled: true

Layout/DefEndAlignment:
Enabled: true

Layout/CaseIndentation:
Enabled: true

Layout/CommentIndentation:
Enabled: true

Layout/EmptyLinesAroundClassBody:
Enabled: true

Layout/EmptyLinesAroundModuleBody:
Enabled: true

Style/FrozenStringLiteralComment:
Enabled: true
10 changes: 5 additions & 5 deletions examples/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
Console.logger.debug "Spawning 2 containers..."

2.times do
container.spawn do |task|
Console.logger.debug task, "Sleeping..."
sleep(2)
Console.logger.debug task, "Waking up!"
end
container.spawn do |task|
Console.logger.debug task, "Sleeping..."
sleep(2)
Console.logger.debug task, "Waking up!"
end
end

Console.logger.debug "Waiting for container..."
Expand Down
46 changes: 23 additions & 23 deletions examples/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@
require '../lib/async/container/controller'

class Controller < Async::Container::Controller
def setup(container)
container.run(count: 1, restart: true) do |instance|
if container.statistics.failed?
Console.logger.debug(self, "Child process restarted #{container.statistics.restarts} times.")
else
Console.logger.debug(self, "Child process started.")
end

instance.ready!

while true
sleep 1

Console.logger.debug(self, "Work")

if rand < 0.5
Console.logger.debug(self, "Should exit...")
sleep 0.5
exit(1)
end
end
end
end
def setup(container)
container.run(count: 1, restart: true) do |instance|
if container.statistics.failed?
Console.logger.debug(self, "Child process restarted #{container.statistics.restarts} times.")
else
Console.logger.debug(self, "Child process started.")
end

instance.ready!

while true
sleep 1

Console.logger.debug(self, "Work")

if rand < 0.5
Console.logger.debug(self, "Should exit...")
sleep 0.5
exit(1)
end
end
end
end
end

Console.logger.debug!
Expand Down
2 changes: 2 additions & 0 deletions gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
group :test do
gem "sus"
gem "covered"
gem "decode"
gem "rubocop"

gem "bake-test"
gem "bake-test-external"
Expand Down
2 changes: 0 additions & 2 deletions lib/async/container/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ def spawn(name: nil, restart: false, key: nil, &block)
break
end
end
# ensure
# Console.logger.error(self) {$!} if $!
end.resume

return true
Expand Down
3 changes: 1 addition & 2 deletions lib/async/container/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def exec(*arguments, ready: true, **options)
self.before_spawn(arguments, options)
end

# TODO prefer **options... but it doesn't support redirections on < 2.7
::Process.exec(*arguments, options)
::Process.exec(*arguments, **options)
end
end

Expand Down
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ We welcome contributions to this project.

### Developer Certificate of Origin

This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.

### Contributor Covenant
### Community Guidelines

This project is governed by the [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
6 changes: 3 additions & 3 deletions test/async/container/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def before
super
end

def after
def after(error = nil)
Process.kill(:TERM, @pid)
Process.wait(@pid)

Expand Down Expand Up @@ -143,7 +143,7 @@ def before
super
end

def after
def after(error = nil)
Process.kill(:TERM, @pid)
Process.wait(@pid)

Expand Down Expand Up @@ -175,7 +175,7 @@ def before
super
end

def after
def after(error = nil)
Process.kill(:TERM, @pid)
Process.wait(@pid)

Expand Down

0 comments on commit 33103f2

Please sign in to comment.