Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite Search #1229

Merged
merged 13 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
branches: [ master, staging ]
workflow_dispatch:

jobs:
Expand All @@ -16,7 +16,7 @@ jobs:
with:
ruby-version: 3.1
bundler-cache: true
linter:
rubocop:
needs: setup
runs-on: ubuntu-latest
steps:
Expand All @@ -25,9 +25,9 @@ jobs:
with:
ruby-version: 3.1
bundler-cache: true
- name: Run linter
- name: Run rubocop
run: bundle exec rubocop
haml-linter:
haml-lint:
needs: setup
runs-on: ubuntu-latest
steps:
Expand All @@ -36,27 +36,21 @@ jobs:
with:
ruby-version: 3.1
bundler-cache: true
- name: Run linter
- name: Run haml-lint
run: bundle exec haml-lint app/views/
unit:
needs: linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true
- name: Run unit tests
run: bundle exec rake test
system:
needs: linter
tests:
needs: [rubocop, haml-lint]
runs-on: ubuntu-latest
steps:
- uses: dentarg/postgres@v1
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true
- name: Run system tests
run: bundle exec rake test:system
- name: Run tests
run: |
bundle exec rake db:setup
bundle exec rails test -vp
env:
DATABASE_URL: "${{ env.POSTGRES_URL }}"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ public/images
public/index.html
public/package

# Logfiles and temfiles
# File storage
/storage

# Logfiles and tempfiles
/log/*.log
/tmp

Expand Down
1 change: 1 addition & 0 deletions .haml-lint.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
inherits_from: .haml-lint_todo.yml
linters:
MultilinePipe:
enabled: false
33 changes: 33 additions & 0 deletions .haml-lint_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This configuration was generated by
# `haml-lint --auto-gen-config`
# on 2023-11-08 16:31:13 +0000 using Haml-Lint version 0.40.1.
# The point is for the user to remove these configuration records
# one by one as the lints are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of Haml-Lint, may require this file to be generated again.

linters:

# Offense count: 4
InstanceVariables:
exclude:
- "app/views/layouts/_search_form.html.haml"
- "app/views/packages/_screenshot_carousel.html.haml"

# Offense count: 11
LineLength:
exclude:
- "app/views/layouts/_search_form.html.haml"
- "app/views/main/search.html.haml"
- "app/views/packages/_screenshot_carousel.html.haml"
- "app/views/packages/show.html.haml"

# Offense count: 7
RuboCop:
exclude:
- "app/views/layouts/_search_form.html.haml"

# Offense count: 1
InlineStyles:
exclude:
- "app/views/main/search.html.haml"
11 changes: 10 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

inherit_from: .rubocop_todo.yml

require: rubocop-performance
require:
- rubocop-performance
- rubocop-minitest
- rubocop-rails

AllCops:
TargetRubyVersion: 3.1
Expand All @@ -18,3 +21,9 @@ AllCops:

Style/HashSyntax:
EnforcedShorthandSyntax: either

Style/FrozenStringLiteralComment:
Enabled: false

Style/Documentation:
Enabled: false
125 changes: 72 additions & 53 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,99 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2022-03-28 14:09:17 UTC using RuboCop version 1.22.0.
# on 2023-11-08 16:47:51 UTC using RuboCop version 1.36.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
Lint/RescueException:
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/models/screenshot.rb'
- 'lib/api_connect.rb'

# Offense count: 21
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
# Offense count: 18
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 67
Max: 66

# Offense count: 3
# Offense count: 2
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 223
Max: 192

# Offense count: 16
# Configuration parameters: IgnoredMethods.
# Offense count: 10
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 25
Max: 24

# Offense count: 26
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# Offense count: 16
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/MethodLength:
Max: 46

# Offense count: 1
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 121
Max: 115

# Offense count: 11
# Configuration parameters: IgnoredMethods.
# Offense count: 7
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/PerceivedComplexity:
Max: 26
Max: 25

# Offense count: 2
Minitest/MultipleAssertions:
Max: 5

# Offense count: 1
Naming/AccessorMethodName:
Exclude:
- 'app/controllers/download_controller.rb'

# Offense count: 3
Security/Open:
# Offense count: 4
# Configuration parameters: EnforcedStyle.
# SupportedStyles: slashes, arguments
Rails/FilePath:
Exclude:
- 'app/jobs/cache_screenshot_job.rb'
- 'test/test_helper.rb'

# Offense count: 2
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasAndBelongsToMany:
Exclude:
- 'app/controllers/images_controller.rb'
- 'app/models/appdata.rb'
- 'app/models/category.rb'
- 'app/models/package.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasManyOrHasOneDependent:
Exclude:
- 'app/models/distribution.rb'
- 'app/models/repository.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Include.
# Include: **/Rakefile, **/*.rake
Rails/RakeEnvironment:
Exclude:
- 'lib/tasks/gettext.rake'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: strict, flexible
Rails/TimeZone:
Exclude:
- 'app/helpers/application_helper.rb'

# Offense count: 1
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/UniqueValidationWithoutIndex:
Exclude:
- 'app/models/package.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Expand All @@ -67,42 +105,23 @@ Style/ClassVars:
Exclude:
- 'app/helpers/application_helper.rb'

# Offense count: 8
# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'app/controllers/application_controller.rb'
- 'app/controllers/download_controller.rb'
- 'app/controllers/package_controller.rb'
- 'app/controllers/search_controller.rb'
- 'app/helpers/package_helper.rb'
- 'app/helpers/search_helper.rb'
- 'app/models/appdata.rb'
- 'lib/api_connect.rb'

# Offense count: 4
# Configuration parameters: MinBodyLength.
# Offense count: 1
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
Style/GuardClause:
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/controllers/download_controller.rb'
- 'lib/api_connect.rb'

# Offense count: 5
# Cop supports --auto-correct.
# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'app/controllers/download_controller.rb'
- 'app/controllers/search_controller.rb'
- 'app/helpers/application_helper.rb'
- 'lib/api_connect.rb'
- 'lib/obs.rb'

# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# Offense count: 13
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 135
28 changes: 3 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,8 @@
FROM registry.opensuse.org/opensuse/leap:15.4
FROM registry.opensuse.org/opensuse/infrastructure/software.opensuse.org/containers/software/base:latest
ARG CONTAINER_USERID

# Install our requirements
RUN zypper -n ar -f \
https://download.opensuse.org/repositories/devel:/languages:/ruby/15.4/devel:languages:ruby.repo; \
zypper -n --gpg-auto-import-keys refresh; \
zypper -n install --no-recommends timezone glibc-locale sudo \
vim git-core \
gcc gcc-c++ make \
MozillaFirefox \
nodejs16 ruby3.1-devel \
libxml2-devel libxslt-devel \
ImageMagick

# Setup ruby in PATH & sudo
RUN echo 'install: --no-format-executable' >> /etc/gemrc; \
echo 'software ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers; \
ln -s /usr/bin/gem.ruby3.1 /usr/local/bin/gem; \
ln -s /usr/bin/ruby.ruby3.1 /usr/local/bin/ruby; \
ln -s /usr/bin/bundle.ruby3.1 /usr/local/bin/bundle; \
ln -s /usr/bin/bundler.ruby3.1 /usr/local/bin/bundler; \
ln -s /usr/bin/irb.ruby3.1 /usr/local/bin/irb; \
ln -s /usr/bin/rake.ruby3.1 /usr/local/bin/rake

# Add our user
RUN useradd -m software -u $CONTAINER_USERID -p software
# Configure our user
RUN usermod -u $CONTAINER_USERID software

# We copy the Gemfiles into this intermediate build stage so it's checksum
# changes and all the subsequent stages (a.k.a. the bundle install call below)
Expand Down
Loading