From 1a0c82201f42e3633bfb3acea3196dc359412de4 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 18 Feb 2022 13:16:53 +0100 Subject: [PATCH 1/3] CI: Also run on macos-latest Make the `test/run` script compatible to the ancient Bash version on macos. ``` test/run: line 56: conditional binary operator expected ``` Also, run `set -e` only for Bash >= 4. Otherwise the shell silently exits with a failure when a command (expectedly) fails. fix bogus test failure with Bash 3.2 on macos --- .github/workflows/ruby.yml | 4 +++- test/run | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 2307c29..e299ef1 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -16,10 +16,12 @@ on: jobs: test: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: matrix: ruby-version: ['2.6', '2.7', '3.0'] + os: [ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v2 diff --git a/test/run b/test/run index 00f2630..26e5c00 100755 --- a/test/run +++ b/test/run @@ -1,6 +1,10 @@ #! /usr/bin/env bash -set -eEuCo pipefail +set -EuCo pipefail + +if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + set -e +fi declare RED=$'\033[31m' declare GREEN=$'\033[32m' @@ -53,7 +57,7 @@ function XFAIL() { echo "$RED" "FAIL$RESET - $* (unexpected success, ${BASH_SOURCE[1]}:${BASH_LINENO[0]})" >&2 else ret=$? - if [[ -v expected && $expected -ne $ret ]]; then + if [[ -n "$expected" && $expected -ne $ret ]]; then ((++ERRORS)) echo "$RED" "FAIL$RESET - $* (expected: $expected got $ret, ${BASH_SOURCE[1]}:${BASH_LINENO[0]})" >&2 From 3995f3173c83c21598912b8062f7a63de08b5f3b Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 18 Feb 2022 14:10:09 +0100 Subject: [PATCH 2/3] Drop support for Ruby 2.5 It reached EOL with release 2.5.9, and no longer receives patches. --- .github/workflows/ruby.yml | 2 +- .rubocop.yml | 2 +- README.md | 2 +- colorls.gemspec | 2 +- lib/colorls/core.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index e299ef1..5912dbe 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: - ruby-version: ['2.6', '2.7', '3.0'] + ruby-version: ['2.6', '2.7', '3.0', '3.1'] os: [ubuntu-latest, macos-latest] steps: diff --git a/.rubocop.yml b/.rubocop.yml index ee5bc77..19b7d95 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,7 +10,7 @@ AllCops: - 'profile/*' DisplayCopNames: true NewCops: enable - TargetRubyVersion: 2.5 + TargetRubyVersion: 2.6 # Preferred codebase style --------------------------------------------- diff --git a/README.md b/README.md index e4a532e..d1c3b60 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ Man pages have been added. Checkout `man colorls`. [(Back to top)](#table-of-contents) -1. Install Ruby (preferably, version >= 2.5) +1. Install Ruby (preferably, version >= 2.6) 2. [Download](https://www.nerdfonts.com/font-downloads) and install a Nerd Font. Have a look at the [Nerd Font README](https://github.com/ryanoasis/nerd-fonts/blob/master/readme.md) for installation instructions. *Note for `iTerm2` users - Please enable the Nerd Font at iTerm2 > Preferences > Profiles > Text > Non-ASCII font > Hack Regular Nerd Font Complete.* diff --git a/colorls.gemspec b/colorls.gemspec index 102713f..61384c2 100644 --- a/colorls.gemspec +++ b/colorls.gemspec @@ -47,7 +47,7 @@ Gem::Specification.new do |spec| spec.homepage = 'https://github.com/athityakumar/colorls' spec.license = 'MIT' - spec.required_ruby_version = '>= 2.5.0' + spec.required_ruby_version = '>= 2.6.0' spec.files = IO.popen( %w[git ls-files -z], external_encoding: Encoding::ASCII_8BIT diff --git a/lib/colorls/core.rb b/lib/colorls/core.rb index aea56d6..0fecb2c 100644 --- a/lib/colorls/core.rb +++ b/lib/colorls/core.rb @@ -321,7 +321,7 @@ module ColorLS def fetch_string(content, key, color, increment) @count[increment] += 1 value = increment == :folders ? @folders[key] : @files[key] - logo = value.gsub(/\\u[\da-f]{4}/i) { |m| [m[-4..-1].to_i(16)].pack('U') } + logo = value.gsub(/\\u[\da-f]{4}/i) { |m| [m[-4..].to_i(16)].pack('U') } name = content.show name = make_link(content) if @hyperlink name += content.directory? && @indicator_style != 'none' ? '/' : ' ' From a07810cb9d195c250d1080ec2ff52702b468a5bf Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 18 Feb 2022 14:38:51 +0100 Subject: [PATCH 3/3] CI: Run shellcheck for test scripts --- .github/workflows/ruby.yml | 3 +++ test/run | 1 + 2 files changed, 4 insertions(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 5912dbe..da44c0e 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -25,6 +25,9 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Shellcheck + if: matrix.os == 'ubuntu-latest' + run: shellcheck test/run test/checks - name: Set up Ruby uses: ruby/setup-ruby@v1 with: diff --git a/test/run b/test/run index 26e5c00..08c6db9 100755 --- a/test/run +++ b/test/run @@ -103,4 +103,5 @@ function summary() { trap summary EXIT +# shellcheck source=test/checks source "$(dirname "${BASH_SOURCE[0]}")/checks"