diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..1db48bb --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,60 @@ +# MIT License +# +# Copyright (c) 2024 Zerocracy +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +--- +AllCops: + Exclude: + - 'vendor/**/*' + DisplayCopNames: true + TargetRubyVersion: 3.2 + SuggestExtensions: false + NewCops: enable + +Naming/FileName: + Regex: !ruby/regexp '/^[a-z-._]*$/' +Style/GlobalVars: + Enabled: false +Metrics/MethodLength: + Enabled: false +Lint/NestedMethodDefinition: + Enabled: false +Gemspec/RequiredRubyVersion: + Enabled: false +Style/ClassAndModuleChildren: + Enabled: false +Layout/MultilineMethodCallIndentation: + Enabled: false +Metrics/AbcSize: + Enabled: false +Metrics/BlockLength: + Enabled: false +Metrics/CyclomaticComplexity: + Enabled: false +Metrics/ClassLength: + Enabled: false +Metrics/PerceivedComplexity: + Enabled: false +Layout/EmptyLineAfterGuardClause: + Enabled: false +Layout/CaseIndentation: + Enabled: false +Naming/MethodParameterName: + MinNameLength: 2 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..90cca91 --- /dev/null +++ b/Gemfile @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +# MIT License +# +# Copyright (c) 2024 Zerocracy +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +source 'https://rubygems.org' + +gem 'fbe', '~>0.0' +gem 'judges', '~>0.8' +gem 'rake', '13.2.1' +gem 'rubocop', '1.64.1' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..cc1599d --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,157 @@ +GEM + remote: https://rubygems.org/ + specs: + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + ast (2.4.2) + backtrace (0.4.0) + concurrent-ruby (1.3.3) + decoor (0.0.1) + ethon (0.16.0) + ffi (>= 1.15.0) + factbase (0.0.56) + backtrace (~> 0.3) + decoor (~> 0.0) + json (~> 2.7) + loog (~> 0.2) + nokogiri (~> 1.10) + others (~> 0.0) + tago (~> 0.0) + yaml (~> 0.3) + faraday (2.9.2) + faraday-net_http (>= 2.0, < 3.2) + faraday-http-cache (2.5.1) + faraday (>= 0.8) + faraday-multipart (1.0.4) + multipart-post (~> 2) + faraday-net_http (3.1.0) + net-http + faraday-retry (2.2.1) + faraday (~> 2.0) + fbe (0.0.3) + backtrace (~> 0.3) + decoor (~> 0.0) + factbase (~> 0.0) + faraday (~> 2.9) + faraday-http-cache (~> 2.5) + faraday-multipart (~> 1.0) + faraday-retry (~> 2.2) + judges (~> 0.0) + loog (~> 0.2) + obk (~> 0.0) + octokit (~> 9.1.0) + others (~> 0.0) + verbose (~> 0.0) + ffi (1.17.0-aarch64-linux-gnu) + ffi (1.17.0-aarch64-linux-musl) + ffi (1.17.0-arm-linux-gnu) + ffi (1.17.0-arm-linux-musl) + ffi (1.17.0-arm64-darwin) + ffi (1.17.0-x86-linux-gnu) + ffi (1.17.0-x86-linux-musl) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) + ffi (1.17.0-x86_64-linux-musl) + gli (2.21.1) + iri (0.8.0) + json (2.7.2) + judges (0.13.3) + backtrace (~> 0.3) + concurrent-ruby (~> 1.2) + factbase (~> 0.0) + gli (~> 2.21) + iri (~> 0.8) + loog (~> 0.2) + moments (~> 0.3) + nokogiri (~> 1.10) + others (~> 0.0) + retries (~> 0.0) + tago (~> 0.0) + typhoeus (~> 1.3) + language_server-protocol (3.17.0.3) + loog (0.5.2) + moments (0.3.0) + multipart-post (2.4.1) + net-http (0.4.1) + uri + nokogiri (1.16.6-aarch64-linux) + racc (~> 1.4) + nokogiri (1.16.6-arm-linux) + racc (~> 1.4) + nokogiri (1.16.6-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.6-x86-linux) + racc (~> 1.4) + nokogiri (1.16.6-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.16.6-x86_64-linux) + racc (~> 1.4) + obk (0.3.1) + octokit (9.1.0) + faraday (>= 1, < 3) + sawyer (~> 0.9) + others (0.0.3) + parallel (1.25.1) + parser (3.3.3.0) + ast (~> 2.4.1) + racc + public_suffix (6.0.0) + racc (1.8.0) + rainbow (3.1.1) + rake (13.2.1) + regexp_parser (2.9.2) + retries (0.0.5) + rexml (3.3.1) + strscan + rubocop (1.64.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.31.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.3) + parser (>= 3.3.1.0) + ruby-progressbar (1.13.0) + sawyer (0.9.2) + addressable (>= 2.3.5) + faraday (>= 0.17.3, < 3) + strscan (3.1.0) + tago (0.0.2) + typhoeus (1.4.1) + ethon (>= 0.9.0) + unicode-display_width (2.5.0) + uri (0.13.0) + verbose (0.0.2) + loog (~> 0.2) + tago (~> 0.0) + yaml (0.3.0) + +PLATFORMS + aarch64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm-linux + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86-linux + x86-linux-gnu + x86-linux-musl + x86_64-darwin + x86_64-linux + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + fbe (~> 0.0) + judges (~> 0.8) + rake (= 13.2.1) + rubocop (= 1.64.1) + +BUNDLED WITH + 2.5.6 diff --git a/Makefile b/Makefile index 46eaaa5..756f5be 100644 --- a/Makefile +++ b/Makefile @@ -26,9 +26,6 @@ .SHELLFLAGS := -e -o pipefail -c SHELL := bash -JUDGES_VERSION=0.13.1 -FACTBASE_VERSION=0.0.55 - YAMLS = $(wildcard tests/*.yml) FBS = $(subst tests/,target/fb/,${YAMLS:.yml=.fb}) HTMLS = $(subst fb/,html/,${FBS:.fb=.html}) @@ -68,8 +65,7 @@ $(SAXON): | target wget --no-verbose -O $(SAXON) https://repo.maven.apache.org/maven2/net/sf/saxon/Saxon-HE/9.8.0-5/Saxon-HE-9.8.0-5.jar install: $(SAXON) | target - gem install factbase:$(FACTBASE_VERSION) - gem install judges:$(JUDGES_VERSION) + bundle update npm --no-color install -g sass@1.77.2 $(DIRS): diff --git a/Rakefile.rb b/Rakefile.rb new file mode 100644 index 0000000..741acc8 --- /dev/null +++ b/Rakefile.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +# MIT License +# +# Copyright (c) 2024 Zerocracy +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +require 'rubygems' +require 'rake' +require 'rake/clean' + +task default: %i[clean test judges rubocop] + +require 'rake/testtask' +desc 'Run all unit tests' +Rake::TestTask.new(:test) do |test| + test.libs << 'lib' << 'test' + test.pattern = 'test/**/test_*.rb' + test.warning = true + test.verbose = false +end + +desc 'Test all judges' +task :judges do + live = ARGV.include?('--live') ? '' : '--disable live' + sh "judges --verbose test #{live} --no-log judges" +end + +require 'rubocop/rake_task' +desc 'Run RuboCop on all directories' +RuboCop::RakeTask.new(:rubocop) do |task| + task.fail_on_error = true +end diff --git a/action.yml b/action.yml index ab5ec92..a22adfa 100644 --- a/action.yml +++ b/action.yml @@ -29,6 +29,7 @@ inputs: verbose: description: 'Log as much debug information as possible' required: false + default: false output: description: 'Directory path with YAML, XML, JSON and other files generated' required: false @@ -36,4 +37,4 @@ inputs: factbase: description: 'Path of the factbase file' required: true - default: 'recent.fb' + default: 'default.fb' diff --git a/entry.sh b/entry.sh index 4a0c950..f46d507 100755 --- a/entry.sh +++ b/entry.sh @@ -66,6 +66,8 @@ for f in yaml xml json; do "${JUDGES}" "${gopts[@]}" print --format "${f}" "${INPUT_FACTBASE}" "${INPUT_OUTPUT}/${name}.${f}" done +"${JUDGES}" "${gopts[@]}" update "${INPUT_FACTBASE}" "${SELF}/judges/" + # Build a summary HTML. css=$(cat "${SELF}/target/css/main.css") java -jar "${SELF}/target/saxon.jar" \ diff --git a/judges/add-user-names/add-user-name.rb b/judges/add-user-names/add-user-name.rb new file mode 100644 index 0000000..438af0d --- /dev/null +++ b/judges/add-user-names/add-user-name.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +# MIT License +# +# Copyright (c) 2024 Zerocracy +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +require 'fbe/octo' +require 'fbe/conclude' + +Fbe.conclude do + on '(and (exists who) (not (exists who_name)))' + consider do |f| + f.who_name = Fbe.octo.user_name_by_id(f.who) + end +end diff --git a/judges/add-user-names/fake-names.yml b/judges/add-user-names/fake-names.yml new file mode 100644 index 0000000..0111bf8 --- /dev/null +++ b/judges/add-user-names/fake-names.yml @@ -0,0 +1,36 @@ +# MIT License +# +# Copyright (c) 2024 Zerocracy +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +--- +options: + testing: true +input: + - + _id: 11 + what: bug-was-resolved + who: 4444 + issue: 42 + repository: 100 + when: 2024-01-01T03:15:45Z +expected: + - /fb[count(f)=1] + - /fb/f[who='4444'] + - /fb/f[who_name='yegor256'] diff --git a/tests/simple.yml b/tests/simple.yml index 573a5af..c6b0111 100644 --- a/tests/simple.yml +++ b/tests/simple.yml @@ -23,18 +23,18 @@ - time: 2024-05-18T22:22:22.8492Z award: 15 - payee: yegor256 + who: 526301 reason: for being a good boy href: https://github.com/yegor256/judges/issues/111 - time: 2024-05-15T22:22:22.8492Z award: -24 - payee: yegor256 + who: 6305016 reason: for being a bad boy href: https://github.com/yegor256/judges/issues/111 - time: 2024-05-15T22:22:22.8492Z award: 55 - payee: torvalds + who: 6305016 reason: for new release href: https://github.com/yegor256/judges/issues/111 diff --git a/xsl/awards.xsl b/xsl/awards.xsl index 75718c0..84bc360 100644 --- a/xsl/awards.xsl +++ b/xsl/awards.xsl @@ -68,10 +68,10 @@ SOFTWARE.
-