diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 876c3ecfa..6c49a6198 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -24,7 +24,7 @@ Works properly: - [ ] `armv7l` ### Run the following to get this pull request's changes locally for testing. -``` +```bash CREW_REPO=https://github.com//chromebrew.git CREW_BRANCH= crew update ``` diff --git a/.mdl_style.rb b/.mdl_style.rb index 51329237d..d615489aa 100644 --- a/.mdl_style.rb +++ b/.mdl_style.rb @@ -5,6 +5,8 @@ rule 'MD029', style: :ordered exclude_rule 'MD002' # We use HTML

tag as the top level header exclude_rule 'MD013' # Ignore 80 character line length limit. exclude_rule 'MD022' # Ignore headers should be surrounded by blank lines +exclude_rule 'MD026' # Ignore trailing punctuation in header +exclude_rule 'MD028' # Ignore blank line inside blockquote exclude_rule 'MD031' # Ignore code blocks should be surrounded by blank lines exclude_rule 'MD032' # Ignore lists should be surrounded by blank lines exclude_rule 'MD033' # We need HTML to center logo, which is not possible in pure Markdown diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..1027c3b52 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +--- +# To run these hooks, install pre-commit (https://pre-commit.com) and run 'pre-commit install' +# These pre-commit hooks mirror the Github CI, so running them locally will catch errors earlier. +repos: + - repo: https://github.com/rubocop/rubocop + rev: v1.64.1 + hooks: + - id: rubocop + - repo: https://github.com/syntaqx/git-hooks + rev: v0.0.18 + hooks: + - id: shellcheck + exclude: tools + - repo: https://github.com/markdownlint/markdownlint + rev: v0.13.0 + hooks: + - id: markdownlint + args: [-s.mdl_style.rb] + - repo: https://github.com/adrienverge/yamllint + rev: v1.35.1 + hooks: + - id: yamllint diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d9053347b..9aa2aa513 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -102,3 +102,11 @@ If the package is a dependency for another package, test commands of the other p ## Learn more - Visit the [wiki](https://github.com/chromebrew/chromebrew/wiki) + +## Pre-commit hooks. + +Chromebrew has pre-commit hooks to catch errors before they make it to CI. + +To install them, run `pre-commit install` in the root of the repository. + +You will first need to install the pre-commit tool, which can be done via `crew install py3_pre_commit` on ChromeOS. diff --git a/README.md b/README.md index ee93ba03f..cbd40bd72 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ crew install --keep [...] ## License -Copyright 2013-2024 Michal Siwek and [all the awesome contributors](https://github.com/chromebrew/chromebrew/graphs/contributors). +Copyright 2013-2024 Michal Siwek and [all the awesome contributors](https://github.com/chromebrew/chromebrew/graphs/contributors). This project including all of its source files is released under the terms of [GNU General Public License (version 3 or later)](http://www.gnu.org/licenses/gpl.txt). This project embeds [docopt.rb](https://github.com/docopt/docopt.rb) at lib/docopt.rb. We retain its [MIT license](lib/docopt.LICENSE). diff --git a/packages/buildessential.rb b/packages/buildessential.rb index 39121f2c6..caf92b1fc 100644 --- a/packages/buildessential.rb +++ b/packages/buildessential.rb @@ -90,9 +90,6 @@ class Buildessential < Package # depends_on 'openjdk11' # depends_on 'openjdk17' - # Linter - depends_on 'linter' - # Lisp # depends_on 'ccl' # depends_on 'clisp' diff --git a/packages/caja.rb b/packages/caja.rb index 73b712f66..9e8a734ea 100644 --- a/packages/caja.rb +++ b/packages/caja.rb @@ -56,5 +56,4 @@ class Caja < Autotools gnome configure_options '--enable-wayland' - end diff --git a/packages/gvim.rb b/packages/gvim.rb index 1e5c91350..8cf69cfab 100644 --- a/packages/gvim.rb +++ b/packages/gvim.rb @@ -24,7 +24,7 @@ class Gvim < Autotools depends_on 'glib' # R depends_on 'gpm' # R depends_on 'gtk3' # R - depends_on 'harfbuzz' # + depends_on 'harfbuzz' depends_on 'libice' # R depends_on 'libsm' # R depends_on 'libsodium' # R diff --git a/packages/linter.rb b/packages/linter.rb deleted file mode 100644 index ba84d8066..000000000 --- a/packages/linter.rb +++ /dev/null @@ -1,92 +0,0 @@ -require 'package' - -class Linter < Package - description 'Comprehensive linter and code analysis for various file types.' - homepage 'https://github.com/chromebrew/chromebrew' - version '1.4' - license 'GPL-3' - compatibility 'all' - source_url 'SKIP' - - no_compile_needed - no_upstream_update - - depends_on 'py3_codespell' - depends_on 'ruby_mdl' - depends_on 'ruby_rubocop' - depends_on 'ruby_yaml_lint' - depends_on 'shellcheck' - - def self.build - linter = <<~EOF - #!/bin/bash - export PATH=#{CREW_PREFIX}/bin:$PATH - if test "$1"; then - files="$*" - else - files="$(git ls-files -om | xargs)" - fi - for file in $files; do - ext="${file##*.}" - if ! [[ "$ext" =~ ^(md|rb|sh|yml|yaml)$ ]]; then - type="$(file -b "$file" | cut -d' ' -f1)" - case $type in - Bourne-Again) - ext="sh" - ;; - HTML) - ext="md" - ;; - Ruby) - ext="rb" - ;; - esac - fi - case $ext in - md) - mdl -c "$HOME/.mdlrc" "$file" - ;; - rb) - rubocop "$file" - ;; - sh) - shellcheck "$file" - ;; - yml|yaml) - yaml-lint "$file" - ;; - *) - echo "Unable to check syntax of $file." - ;; - esac - codespell "$file" - done - EOF - File.write('linter', linter) - mdlrc = <<~EOF - style "#{Dir.home}/.mdl_style.rb" - EOF - File.write('.mdlrc', mdlrc) - mdl_style = <<~EOF - all - # Ignore 80 character line length limit. - exclude_rule 'MD013' - # Ignore horizontal rule style. - exclude_rule 'MD035' - # Ignore emphasis used instead of a header. - exclude_rule 'MD036' - # Ignore first line in file should be a top level header. - exclude_rule 'MD041' - # Ignore code block style. - exclude_rule 'MD046' - EOF - File.write('.mdl_style.rb', mdl_style) - end - - def self.install - FileUtils.mkdir_p CREW_DEST_HOME.to_s - FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/bin" - FileUtils.install 'linter', "#{CREW_DEST_PREFIX}/bin", mode: 0o755 - FileUtils.install ['.mdlrc', '.mdl_style.rb'], CREW_DEST_HOME.to_s, mode: 0o644 - end -end diff --git a/packages/openjdk.rb b/packages/openjdk.rb index 3f00ca48a..c6b3e8827 100644 --- a/packages/openjdk.rb +++ b/packages/openjdk.rb @@ -10,7 +10,6 @@ class Openjdk < Package description 'The JDK is a development environment for building applications, applets, and components using the Java programming language.' homepage 'https://openjdk.org/' key = 1 - versions = [] @openjdk_versions = [] Dir["#{CREW_PACKAGES_PATH}/openjdk*.rb"].each do |openjdk_file| next unless openjdk_file =~ /openjdk(\d+).rb/ @@ -20,8 +19,8 @@ class Openjdk < Package @openjdk_versions.push [key, openjdk_name, openjdk_ver] key += 1 end - @openjdk_versions.each do |openjdk_ver| - versions.push openjdk_ver[2] + versions = @openjdk_versions.map do |openjdk_ver| + openjdk_ver[2] end versions.sort! version "#{versions.first}-#{versions.last}" diff --git a/packages/py3_pre_commit.rb b/packages/py3_pre_commit.rb new file mode 100644 index 000000000..072614993 --- /dev/null +++ b/packages/py3_pre_commit.rb @@ -0,0 +1,15 @@ +require 'buildsystems/pip' + +class Py3_pre_commit < Pip + description 'A framework for managing and maintaining multi-language pre-commit hooks.' + homepage 'https://pre-commit.com/' + @_ver = '3.6.2' + version "#{@_ver}-py3.12" + license 'MIT' + compatibility 'all' + source_url 'SKIP' + + depends_on 'python3' + + no_compile_needed +end diff --git a/packages/webkit2gtk_4_1.rb b/packages/webkit2gtk_4_1.rb index 616f45b77..b81d25469 100644 --- a/packages/webkit2gtk_4_1.rb +++ b/packages/webkit2gtk_4_1.rb @@ -80,9 +80,7 @@ class Webkit2gtk_4_1 < Package system "sed -i 's,/usr/bin,/usr/local/bin,g' Source/JavaScriptCore/inspector/scripts/codegen/preprocess.pl" @arch_flags = '' @gcc_ver = '' - if ARCH == 'armv7l' || ARCH == 'aarch64' - @arch_flags = '-mfloat-abi=hard -mtls-dialect=gnu -mthumb -mfpu=vfpv3-d16 -mlibarch=armv7-a+fp -march=armv7-a+fp' - end + @arch_flags = '-mfloat-abi=hard -mtls-dialect=gnu -mthumb -mfpu=vfpv3-d16 -mlibarch=armv7-a+fp -march=armv7-a+fp' if ARCH == 'armv7l' || ARCH == 'aarch64' end def self.build diff --git a/tools/packages.yaml b/tools/packages.yaml index b5cc5fe25..3ba0c7845 100644 --- a/tools/packages.yaml +++ b/tools/packages.yaml @@ -7311,6 +7311,11 @@ url: https://github.com/pypa/pip/releases activity: medium --- kind: url +name: py3_pre_commit +url: https://github.com/pre-commit/pre-commit/releases +activity: medium +--- +kind: url name: py3_pylint url: https://github.com/pylint-dev/pylint/releases activity: high