diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..62e58f8 --- /dev/null +++ b/.github/workflows/docs.yml @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..eac71b2 --- /dev/null +++ b/.github/workflows/tests.yml @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 3bbaf35..a23025d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,7 +68,7 @@ GEM unicode_utils (1.4.0) PLATFORMS - x86_64-darwin-19 + ruby DEPENDENCIES atlasq! diff --git a/Rakefile b/Rakefile index dc5fbd5..e1202c9 100644 --- a/Rakefile +++ b/Rakefile @@ -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 diff --git a/bin/generate_readme b/bin/generate_readme index 8f927bb..925679b 100755 --- a/bin/generate_readme +++ b/bin/generate_readme @@ -22,13 +22,13 @@ puts <<~README Query for country info at the command line. ```console - #{ atlasq } + #{atlasq} ``` ## Documentation ```console - #{ atlasq "--help" } + #{atlasq "--help"} ``` ## Examples @@ -36,39 +36,39 @@ puts <<~README ### 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 diff --git a/exe/atlasq b/exe/atlasq index 6d5573b..2cb11d2 100755 --- a/exe/atlasq +++ b/exe/atlasq @@ -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 + $LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "atlasq" diff --git a/test/test_helper.rb b/test/test_helper.rb index 8211a0d..a5033c6 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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__)