diff --git a/.github/workflows/acceptance.yml b/.github/workflows/acceptance.yml index b363dbb..f975fe7 100644 --- a/.github/workflows/acceptance.yml +++ b/.github/workflows/acceptance.yml @@ -57,10 +57,10 @@ jobs: name: runner / acceptance-tests strategy: matrix: - ruby: [ '2.7.5', '3.1.2', '3.2.2', '3.3.0' ] + ruby: [ '2.7.5', '3.1.2', '3.2.2', '3.3.0', '3.3.1' ] steps: - - uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # pin@v1.152.0 + - uses: ruby/setup-ruby@1198b074305f9356bd56dd4b311757cc0dab2f1c # pin@v1.175.1 with: bundler-cache: true ruby-version: ${{ matrix.ruby }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0b52694..64bc0c3 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -30,17 +30,17 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 #- run: | # make bootstrap # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 32e39f2..f3668f6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,15 +15,18 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: [ '2.7.5', '3.1.2', '3.2.2', '3.3.0' ] + ruby: [ '2.7.5', '3.1.2', '3.2.2', '3.3.0', '3.3.1' ] steps: - name: checkout uses: actions/checkout@v4 - - uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # pin@v1.152.0 + - uses: ruby/setup-ruby@1198b074305f9356bd56dd4b311757cc0dab2f1c # pin@v1.175.1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true + - name: bootstrap + run: script/bootstrap + - run: bundle exec rubocop -c .rubocop.yml lib/ spec/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e30645f..cf236c2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,7 +22,7 @@ jobs: - name: checkout uses: actions/checkout@v4 - - uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # pin@v1.152.0 + - uses: ruby/setup-ruby@1198b074305f9356bd56dd4b311757cc0dab2f1c # pin@v1.175.1 with: bundler-cache: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 44e7d5c..5094a4a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,15 +15,18 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby: [ '2.7.5', '3.1.2', '3.2.2', '3.3.0' ] + ruby: [ '2.7.5', '3.1.2', '3.2.2', '3.3.0', '3.3.1' ] steps: - name: checkout uses: actions/checkout@v4 - - uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # pin@v1.152.0 + - uses: ruby/setup-ruby@1198b074305f9356bd56dd4b311757cc0dab2f1c # pin@v1.175.1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true - - run: script/test -d + - name: bootstrap + run: script/bootstrap + + - run: script/test -d -k diff --git a/.rubocop.yml b/.rubocop.yml index 79d367d..7b50acb 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,7 +5,7 @@ inherit_gem: AllCops: SuggestExtensions: false DisplayCopNames: true - TargetRubyVersion: 3.3.0 + TargetRubyVersion: 3.3.1 Exclude: - 'bin/*' - 'vendor/**/*' diff --git a/.ruby-version b/.ruby-version index 15a2799..bea438e 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.3.0 +3.3.1 diff --git a/Gemfile.lock b/Gemfile.lock index 5e70e64..2ed95ff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,10 +1,10 @@ PATH remote: . specs: - entitlements-app (0.3.3) + entitlements-app (0.3.4) concurrent-ruby (= 1.1.9) - faraday (~> 2.0) - net-ldap (~> 0.17) + faraday (> 2.0, <= 2.7.10) + net-ldap (~> 0.19) octokit (~> 4.18) optimist (= 3.0.0) @@ -39,7 +39,7 @@ GEM reline (>= 0.3.6) json (2.6.3) minitest (5.19.0) - net-ldap (0.18.0) + net-ldap (0.19.0) octokit (4.25.1) faraday (>= 1, < 3) sawyer (~> 0.9) diff --git a/entitlements-app.gemspec b/entitlements-app.gemspec index e3a1576..b486091 100644 --- a/entitlements-app.gemspec +++ b/entitlements-app.gemspec @@ -15,8 +15,8 @@ Gem::Specification.new do |s| s.executables = %w[deploy-entitlements] s.add_dependency "concurrent-ruby", "= 1.1.9" - s.add_dependency "faraday", "~> 2.0" - s.add_dependency "net-ldap", "~> 0.17" + s.add_dependency "faraday", "> 2.0", "<= 2.7.10" + s.add_dependency "net-ldap", "~> 0.19" s.add_dependency "octokit", "~> 4.18" s.add_dependency "optimist", "= 3.0.0" diff --git a/lib/entitlements.rb b/lib/entitlements.rb index 08d126c..6e89811 100644 --- a/lib/entitlements.rb +++ b/lib/entitlements.rb @@ -19,7 +19,6 @@ require "erb" require "logger" require "ostruct" -require "set" require "stringio" require "uri" require "yaml" diff --git a/lib/entitlements/backend/base_provider.rb b/lib/entitlements/backend/base_provider.rb index 3292bd0..ce8c51a 100644 --- a/lib/entitlements/backend/base_provider.rb +++ b/lib/entitlements/backend/base_provider.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "set" - module Entitlements class Backend class BaseProvider diff --git a/lib/version.rb b/lib/version.rb index 81862a2..19e1ada 100644 --- a/lib/version.rb +++ b/lib/version.rb @@ -2,6 +2,6 @@ module Entitlements module Version - VERSION = "0.3.3" + VERSION = "0.3.4" end end diff --git a/script/test b/script/test index ab02e2c..2fb9a22 100755 --- a/script/test +++ b/script/test @@ -1,15 +1,22 @@ -#!/bin/bash +#! /usr/bin/env bash # run script/test -h for help +# COLORS +OFF='\033[0m' +RED='\033[0;31m' +GREEN='\033[0;32m' +BLUE='\033[0;34m' + set -e function usage() { echo -e "\t ================== script/test usage ==================" echo -e "\t-h --help : displays help message" + echo -e "\t-k --no-linter : disables linting tests" echo -e "\t-d --disable-bootstrap : disables bootstrap" - echo -e "\n\t Suggested flags for development: script/test -d" + echo -e "\n\t Suggested flags for development: script/test -d -s" } while [ "$1" != "" ]; do @@ -35,42 +42,64 @@ while [ "$1" != "" ]; do shift done -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" - -export PATH=/usr/share/rbenv/shims:$PATH -export RBENV_VERSION="$(cat "${DIR}/.ruby-version")" - -TRASHDIR=$(mktemp -d /tmp/cibuild.XXXXXXXXXXXXXXXXXX) -cleanup() { - rm -rf "$TRASHDIR" -} -trap cleanup EXIT - -cd "$DIR" -. "${DIR}/script/lib/fold.sh" +# setup +export DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" +[ -z "$RBENV_VERSION" ] && export RBENV_VERSION=$(cat "$DIR/.ruby-version") if [[ -z $no_bootstrap ]]; then # bootstrap - begin_fold "Bootstrapping" - ./script/bootstrap - end_fold + echo -e "\nšŸ„¾ ${BLUE}Bootstrapping: $(date "+%H:%M:%S")${OFF}\n" + echo "%%%FOLD {bootstrap}%%%" + cd "$DIR" + script/bootstrap + echo "%%%END FOLD%%%" else - echo -e "\nBypass Bootstrap" + echo -e "\nā© ${BLUE}Skipping Bootstrap${OFF}" fi -bundle exec rspec spec/unit && rspec_exit=$? || rspec_exit=$? +# Run Rubocop +if [[ -z $no_linter ]]; then + echo -e "\nšŸ¤– ${BLUE}Running Rubocop: $(date "+%H:%M:%S")${OFF}\n" + bundle exec rubocop -c .rubocop.yml lib/ spec/ +else + echo -e "\nā© ${BLUE}Skipping Rubocop${OFF}" +fi + +# run tests +echo -e "\nšŸ§Ŗ ${BLUE}Running tests: $(date "+%H:%M:%S")${OFF}\n" +cd "$(dirname $0)/.." -cat "$DIR/coverage/coverage.txt" -grep -q "You're all set, friend" "$DIR/coverage/coverage.txt" && cov_exit=0 || cov_exit=1 +bundle exec bin/rspec spec/unit && rspec_exit=$? || rspec_exit=$? + +total_coverage=$(cat "$DIR/coverage/total-coverage.txt") + +if grep -q "100.0" "$DIR/coverage/total-coverage.txt"; then + cov_exit=0 + echo -e "\nāœ… Total Coverage: ${GREEN}$total_coverage${OFF}" +else + cov_exit=1 + echo -e "\nāŒ Total Coverage: ${RED}$total_coverage${OFF}" +fi echo "" echo "---------------------------------------" -echo "Summary Results" +echo "šŸ“Š Summary Results" echo "---------------------------------------" echo "" -echo "rspec: exitcode=${rspec_exit}" -echo "coverage: exitcode=${cov_exit}" + +if [[ $rspec_exit == 0 ]]; then + echo -e "āœ… ${GREEN}rspec: exitcode=${rspec_exit}${OFF}" +else + echo -e "āŒ ${RED}rspec: exitcode=${rspec_exit}${OFF}" +fi + +if [[ $cov_exit == 0 ]]; then + echo -e "āœ… \033[0;32mcoverage: exitcode=${cov_exit}\033[0m" +else + echo -e "āŒ \033[0;31mcoverage: exitcode=${cov_exit}\033[0m" +fi [ $rspec_exit -gt 0 ] && exit 1 [ $cov_exit -gt 0 ] && exit 1 + exit 0 diff --git a/spec/acceptance/tests/spec_helper.rb b/spec/acceptance/tests/spec_helper.rb index f829a23..312fec4 100644 --- a/spec/acceptance/tests/spec_helper.rb +++ b/spec/acceptance/tests/spec_helper.rb @@ -8,7 +8,6 @@ require "open3" require "rugged" require "shellwords" -require "set" require "stringio" require "tmpdir" require "uri" diff --git a/spec/unit/spec_helper.rb b/spec/unit/spec_helper.rb index 42a72c6..0f03937 100644 --- a/spec/unit/spec_helper.rb +++ b/spec/unit/spec_helper.rb @@ -21,16 +21,26 @@ require "vcr" require "webmock/rspec" +COV_DIR = File.expand_path("../../coverage", File.dirname(__FILE__)) + +SimpleCov.root File.expand_path("../../", File.dirname(__FILE__)) +SimpleCov.coverage_dir COV_DIR + SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::ERBFormatter ] -SimpleCov.start do - # don't show specs as missing coverage for themselves - add_filter "/spec/" - # don't analyze coverage for gems - add_filter "/vendor/gems/" +SimpleCov.minimum_coverage 100 + +SimpleCov.at_exit do + File.write("#{COV_DIR}/total-coverage.txt", SimpleCov.result.covered_percent) + SimpleCov.result.format! +end + +SimpleCov.start do + add_filter "spec/" + add_filter "vendor/gems/" end require_relative "../../lib/entitlements" diff --git a/vendor/cache/net-ldap-0.18.0.gem b/vendor/cache/net-ldap-0.18.0.gem deleted file mode 100644 index 6b5326f..0000000 Binary files a/vendor/cache/net-ldap-0.18.0.gem and /dev/null differ diff --git a/vendor/cache/net-ldap-0.19.0.gem b/vendor/cache/net-ldap-0.19.0.gem new file mode 100644 index 0000000..563ac71 Binary files /dev/null and b/vendor/cache/net-ldap-0.19.0.gem differ