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 github actions #6

Merged
merged 4 commits into from
Nov 18, 2023
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
20 changes: 20 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Docs
on:
push:
branches: master
pull_request:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@main

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true

- name: Outdated readme check
run: bundle exec rake readme:outdated
27 changes: 27 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI
on:
push:
branches: master
pull_request:
jobs:
tests:
strategy:
matrix:
platform: ["ubuntu-latest", "macos-latest"]
ruby: [2.7, 3.0, 3.1, 3.2]
runs-on: ${{ matrix.platform }}
steps:
- name: Set up Git repository
uses: actions/checkout@main

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Run linter
run: bundle exec rake lint

- name: Run tests
run: bundle exec rake test
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ GEM
unicode_utils (1.4.0)

PLATFORMS
x86_64-darwin-19
ruby

DEPENDENCIES
atlasq!
Expand Down
8 changes: 5 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ desc "Shortcut for `rake rubocop:autocorrect`"
task fix: :"rubocop:autocorrect"

namespace "readme" do
desc "Check if the readme needs to be regenerated"
task :outdated do
Tempfile.open("readme") do |file|
sh "bin/generate_readme > #{ file.path }"
sh "diff -q README.md #{ file.path }"
sh "bin/generate_readme > #{file.path}"
sh "diff -q README.md #{file.path}"
end
end

desc "Regenerate the readme"
task :generate do
Tempfile.open("readme") do |file|
sh "bin/generate_readme > #{ file.path }"
sh "bin/generate_readme > #{file.path}"
mv file.path, "README.md"
end
end
Expand Down
20 changes: 10 additions & 10 deletions bin/generate_readme
Original file line number Diff line number Diff line change
Expand Up @@ -22,53 +22,53 @@ puts <<~README
Query for country info at the command line.
```console
#{ atlasq }
#{atlasq}
```
## Documentation
```console
#{ atlasq "--help" }
#{atlasq "--help"}
```
## Examples
### Countries
```console
#{ atlasq "--country", "418" }
#{atlasq "--country", "418"}
```
```console
#{ atlasq "--country", "AM" }
#{atlasq "--country", "AM"}
```
```console
#{ atlasq "--country", "honduras" }
#{atlasq "--country", "honduras"}
```
### Regions
```console
#{ atlasq "--region", "melanesia" }
#{atlasq "--region", "melanesia"}
```
```console
#{ atlasq "--region", "antarctica" }
#{atlasq "--region", "antarctica"}
```
### Currencies
```console
#{ atlasq "--money", "ANG" }
#{atlasq "--money", "ANG"}
```
```console
#{ atlasq "--money", "฿" }
#{atlasq "--money", "฿"}
```
```console
#{ atlasq "--money", "Surinamese Dollar" }
#{atlasq "--money", "Surinamese Dollar"}
```
## Development
Expand Down
3 changes: 3 additions & 0 deletions exe/atlasq
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ debug = true if ARGV.delete("-d")
debug = true if ARGV.delete("--debug")
ENV["ATLASQ_DEBUG"] = "1" if debug

# Avoid warnings on Ruby 2.7 related to pattern matching.
Warning[:experimental] = false
Comment on lines +8 to +9
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a real pain tracking this down. This only showed up in integration tests but then it took me a bit to realize that other methods of silencing this didn't work.


$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "atlasq"

Expand Down
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

# Avoid accidental debug output causing test failures.
ENV.delete("ATLASQ_DEBUG")

$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
Expand Down