From: Tom Hughes Date: Thu, 17 Dec 2020 12:30:05 +0000 (+0000) Subject: Merge remote-tracking branch 'upstream/pull/3010' X-Git-Tag: live~2371 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/3f6f62b39827e7956c696300dc6fba7137fb9409?hp=1b4a06adef58262a3e9eba47049a6ca212d88be4 Merge remote-tracking branch 'upstream/pull/3010' --- diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index 91600595a..000000000 --- a/.coveralls.yml +++ /dev/null @@ -1 +0,0 @@ -service_name: travis-ci diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 539fa4a1d..7b28ebfcd 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,3 +5,7 @@ updates: directory: "/" schedule: interval: "daily" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..e9b7cfd4a --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,115 @@ +name: Lint +on: + - push + - pull_request +env: + os: ubuntu-20.04 + ruby: 2.7 +jobs: + rubocop: + name: RuboCop + runs-on: ubuntu-20.04 + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Setup ruby + uses: actions/setup-ruby@v1.1.2 + with: + ruby-version: ${{ env.ruby }} + - name: Cache gems + uses: actions/cache@v2 + with: + path: vendor/bundle + key: bundle-${{ env.os }}-${{ env.ruby }}-${{ hashFiles('Gemfile.lock') }} + restore-keys: | + bundle-${{ env.os }}-${{ env.ruby }}- + - name: Install gems + run: | + gem install bundler + bundle config set deployment true + bundle install --jobs 4 --retry 3 + - name: Run rubocop + run: bundle exec rubocop --format fuubar + erblint: + name: ERB Lint + runs-on: ubuntu-20.04 + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Setup ruby + uses: actions/setup-ruby@v1.1.2 + with: + ruby-version: ${{ env.ruby }} + - name: Cache gems + uses: actions/cache@v2 + with: + path: vendor/bundle + key: bundle-${{ env.os }}-${{ env.ruby }}-${{ hashFiles('Gemfile.lock') }} + restore-keys: | + bundle-${{ env.os }}-${{ env.ruby }}- + - name: Install gems + run: | + gem install bundler + bundle config set deployment true + bundle install --jobs 4 --retry 3 + - name: Run erblint + run: bundle exec erblint . + eslint: + name: ESLint + runs-on: ubuntu-20.04 + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Setup ruby + uses: actions/setup-ruby@v1.1.2 + with: + ruby-version: ${{ env.ruby }} + - name: Cache gems + uses: actions/cache@v2 + with: + path: vendor/bundle + key: bundle-${{ env.os }}-${{ env.ruby }}-${{ hashFiles('Gemfile.lock') }} + restore-keys: | + bundle-${{ env.os }}-${{ env.ruby }}- + - name: Cache node modules + uses: actions/cache@v1 + with: + path: node_modules + key: yarn-${{ env.os }}-${{ hashFiles('yarn.lock') }} + restore-keys: | + yarn-${{ env.os }}- + - name: Install gems + run: | + gem install bundler + bundle config set deployment true + bundle install --jobs 4 --retry 3 + - name: Install node modules + run: bundle exec rake yarn:install + - name: Create dummy database configuration + run: cp config/example.database.yml config/database.yml + - name: Run eslint + run: bundle exec rake eslint + brakeman: + name: Brakeman + runs-on: ubuntu-20.04 + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Setup ruby + uses: actions/setup-ruby@v1.1.2 + with: + ruby-version: ${{ env.ruby }} + - name: Cache gems + uses: actions/cache@v2 + with: + path: vendor/bundle + key: bundle-${{ env.os }}-${{ env.ruby }}-${{ hashFiles('Gemfile.lock') }} + restore-keys: | + bundle-${{ env.os }}-${{ env.ruby }}- + - name: Install gems + run: | + gem install bundler + bundle config set deployment true + bundle install --jobs 4 --retry 3 + - name: Run brakeman + run: bundle exec brakeman -q diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..b111da933 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,85 @@ +name: Tests +on: + - push + - pull_request +jobs: + test: + name: Ubuntu ${{ matrix.ubuntu }}, Ruby ${{ matrix.ruby }} + strategy: + matrix: + ubuntu: [18.04, 20.04] + ruby: [2.5, 2.7] + runs-on: ubuntu-${{ matrix.ubuntu }} + env: + RAILS_ENV: test + OPENSTREETMAP_MEMCACHE_SERVERS: 127.0.0.1 + steps: + - name: Checkout source + uses: actions/checkout@v1 + - name: Setup ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - name: Cache gems + uses: actions/cache@v1 + with: + path: vendor/bundle + key: bundle-ubuntu-${{ matrix.ubuntu }}-ruby-${{ matrix.ruby }}-${{ hashFiles('Gemfile.lock') }} + restore-keys: | + bundle-ubuntu-${{ matrix.ubuntu }}-ruby-${{ matrix.ruby }}- + - name: Cache node modules + uses: actions/cache@v1 + with: + path: node_modules + key: yarn-ubuntu-${{ matrix.ubuntu }}-${{ hashFiles('yarn.lock') }} + restore-keys: | + yarn-ubuntu-${{ matrix.ubuntu }}- + - name: Install packages + run: | + sudo apt-get -yqq update + sudo apt-get -yqq install memcached + - name: Install gems + run: | + gem install bundler + bundle config set deployment true + bundle install --jobs 4 --retry 3 + - name: Create database + run: | + sudo systemctl start postgresql + sudo -u postgres createuser -s $(id -un) + createdb openstreetmap + psql -c "CREATE EXTENSION btree_gist" openstreetmap + psql -f db/functions/functions.sql openstreetmap + - name: Configure rails + run: | + cp config/github.database.yml config/database.yml + cp config/example.storage.yml config/storage.yml + touch config/settings.local.yml + - name: Populate database + run: | + sed -f script/normalise-structure db/structure.sql > db/structure.expected + bundle exec rake db:migrate + sed -f script/normalise-structure db/structure.sql > db/structure.actual + diff -uw db/structure.expected db/structure.actual + - name: Export javascript strings + run: bundle exec rake i18n:js:export + - name: Install node modules + run: bundle exec rake yarn:install + - name: Run tests + run: bundle exec rake test:db + - name: Report completion to Coveralls + uses: coverallsapp/github-action@v1.1.2 + with: + github-token: ${{ secrets.github_token }} + flag-name: ubuntu-${{ matrix.ubuntu }}-ruby-${{ matrix.ruby }} + parallel: true + finish: + name: Finalise + needs: test + runs-on: ubuntu-latest + steps: + - name: Report completion to Coveralls + uses: coverallsapp/github-action@v1.1.2 + with: + github-token: ${{ secrets.github_token }} + parallel-finished: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 77b17cf9d..000000000 --- a/.travis.yml +++ /dev/null @@ -1,38 +0,0 @@ -dist: bionic -language: ruby -rvm: - - 2.7.0 -cache: - - bundler -addons: - postgresql: 9.5 - apt: - packages: - - firefox-geckodriver - - libarchive-dev - - libgd-dev - - libffi-dev - - libbz2-dev -services: - - memcached -before_script: - - sed -e 's/ IMMUTABLE / /' -e "/^--/d" db/structure.sql > db/structure.expected - - psql -U postgres -c "CREATE DATABASE openstreetmap" - - psql -U postgres -c "CREATE EXTENSION btree_gist" openstreetmap - - psql -U postgres -f db/functions/functions.sql openstreetmap - - cp config/travis.database.yml config/database.yml - - cp config/example.storage.yml config/storage.yml - - touch config/settings.local.yml - - echo -e "---\nmemcache_servers:\n - 127.0.0.1" > config/settings/test.local.yml - - bundle exec rake db:migrate - - bundle exec rake i18n:js:export - - bundle exec rake yarn:install -script: - - bundle exec rubocop -f fuubar - - bundle exec rake eslint - - bundle exec erblint . - - bundle exec brakeman -q - - bundle exec rake db:structure:dump - - sed -e "/idle_in_transaction_session_timeout/d" -e 's/ IMMUTABLE / /' -e "/^--/d" db/structure.sql > db/structure.actual - - diff -uw db/structure.expected db/structure.actual - - bundle exec rake test:db diff --git a/Gemfile b/Gemfile index 10cfb970e..8869fb37c 100644 --- a/Gemfile +++ b/Gemfile @@ -141,7 +141,6 @@ end group :test do gem "brakeman" gem "capybara", ">= 2.15" - gem "coveralls", :require => false gem "erb_lint", :require => false gem "factory_bot_rails" gem "minitest", "~> 5.1" @@ -152,5 +151,7 @@ group :test do gem "rubocop-performance" gem "rubocop-rails" gem "selenium-webdriver" + gem "simplecov", :require => false + gem "simplecov-lcov", :require => false gem "webmock" end diff --git a/Gemfile.lock b/Gemfile.lock index ee1b533ab..d5924e95b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -137,12 +137,6 @@ GEM config (2.2.3) deep_merge (~> 1.2, >= 1.2.1) dry-validation (~> 1.0, >= 1.0.0) - coveralls (0.8.23) - json (>= 1.8, < 3) - simplecov (~> 0.16.1) - term-ansicolor (~> 1.3) - thor (>= 0.19.4, < 2.0) - tins (~> 1.6) crack (0.4.4) crass (1.0.6) dalli (2.7.11) @@ -435,6 +429,7 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) + simplecov-lcov (0.8.0) smart_properties (1.15.0) sprockets (4.0.2) concurrent-ruby (~> 1.0) @@ -445,14 +440,9 @@ GEM sprockets (>= 3.0.0) strong_migrations (0.7.3) activerecord (>= 5) - sync (0.5.0) - term-ansicolor (1.7.1) - tins (~> 1.0) thor (1.0.1) thread_safe (0.3.6) tilt (2.0.10) - tins (1.26.0) - sync tzinfo (1.2.8) thread_safe (~> 0.1) uglifier (4.2.0) @@ -498,7 +488,6 @@ DEPENDENCIES capybara (>= 2.15) composite_primary_keys (~> 12.0.0) config - coveralls dalli delayed_job_active_record dynamic_form @@ -552,6 +541,8 @@ DEPENDENCIES sassc-rails secure_headers selenium-webdriver + simplecov + simplecov-lcov strong_migrations uglifier (>= 1.3.0) validates_email_format_of (>= 1.5.1) diff --git a/README.md b/README.md index 81b8ce7bf..9d5ac53eb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # "The Rails Port" -[![Build Status](https://travis-ci.org/openstreetmap/openstreetmap-website.svg?branch=master)](https://travis-ci.org/openstreetmap/openstreetmap-website) +[![Lint](https://github.com/openstreetmap/openstreetmap-website/workflows/Lint/badge.svg?branch=master&event=push)](https://github.com/openstreetmap/openstreetmap-website/actions?query=workflow%3ALint%20branch%3Amaster%20event%3Apush) +[![Tests](https://github.com/openstreetmap/openstreetmap-website/workflows/Tests/badge.svg?branch=master&event=push)](https://github.com/openstreetmap/openstreetmap-website/actions?query=workflow%3ATests%20branch%3Amaster%20event%3Apush) [![Coverage Status](https://coveralls.io/repos/openstreetmap/openstreetmap-website/badge.svg?branch=master)](https://coveralls.io/r/openstreetmap/openstreetmap-website?branch=master) This is The Rails Port, the [Ruby on Rails](http://rubyonrails.org/) diff --git a/app/assets/images/aol.png b/app/assets/images/aol.png deleted file mode 100644 index cf773f907..000000000 Binary files a/app/assets/images/aol.png and /dev/null differ diff --git a/app/assets/images/aol.svg b/app/assets/images/aol.svg new file mode 100644 index 000000000..53c4dadb7 --- /dev/null +++ b/app/assets/images/aol.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/facebook.png b/app/assets/images/facebook.png deleted file mode 100644 index 8a9efc970..000000000 Binary files a/app/assets/images/facebook.png and /dev/null differ diff --git a/app/assets/images/facebook.svg b/app/assets/images/facebook.svg new file mode 100644 index 000000000..1968745b2 --- /dev/null +++ b/app/assets/images/facebook.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/github.png b/app/assets/images/github.png deleted file mode 100644 index b797e243a..000000000 Binary files a/app/assets/images/github.png and /dev/null differ diff --git a/app/assets/images/github.svg b/app/assets/images/github.svg new file mode 100644 index 000000000..79fa0cb13 --- /dev/null +++ b/app/assets/images/github.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/google.png b/app/assets/images/google.png deleted file mode 100644 index b273b6b6e..000000000 Binary files a/app/assets/images/google.png and /dev/null differ diff --git a/app/assets/images/google.svg b/app/assets/images/google.svg new file mode 100644 index 000000000..fecdd4d00 --- /dev/null +++ b/app/assets/images/google.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/wikipedia.png b/app/assets/images/wikipedia.png deleted file mode 100644 index 784c18477..000000000 Binary files a/app/assets/images/wikipedia.png and /dev/null differ diff --git a/app/assets/images/wikipedia.svg b/app/assets/images/wikipedia.svg new file mode 100644 index 000000000..7330ec7e3 --- /dev/null +++ b/app/assets/images/wikipedia.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/windowslive.png b/app/assets/images/windowslive.png deleted file mode 100644 index 8df253c2b..000000000 Binary files a/app/assets/images/windowslive.png and /dev/null differ diff --git a/app/assets/images/windowslive.svg b/app/assets/images/windowslive.svg new file mode 100644 index 000000000..fdc0cbd76 --- /dev/null +++ b/app/assets/images/windowslive.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/wordpress.png b/app/assets/images/wordpress.png deleted file mode 100644 index dd7147c74..000000000 Binary files a/app/assets/images/wordpress.png and /dev/null differ diff --git a/app/assets/images/wordpress.svg b/app/assets/images/wordpress.svg new file mode 100644 index 000000000..d4ff7f03d --- /dev/null +++ b/app/assets/images/wordpress.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/images/yahoo.png b/app/assets/images/yahoo.png deleted file mode 100644 index 2a9c4a4f3..000000000 Binary files a/app/assets/images/yahoo.png and /dev/null differ diff --git a/app/assets/images/yahoo.svg b/app/assets/images/yahoo.svg new file mode 100644 index 000000000..b0bbdef73 --- /dev/null +++ b/app/assets/images/yahoo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 8aee535af..46ef1c349 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -1324,7 +1324,7 @@ tr.turn:hover { .diary-subscribe-buttons { - position:relative; + position: relative; top: -30px; left: 130px; } @@ -1333,11 +1333,11 @@ tr.turn:hover { #login_auth_buttons { margin-bottom: 0; -} -#login_auth_buttons li { - float: left; - padding: $lineheight/4 $lineheight/2; + li { + float: left; + padding: $lineheight/4 $lineheight/2; + } } /* Rules for the account confirmation page */ diff --git a/app/helpers/user_helper.rb b/app/helpers/user_helper.rb index 74f16380c..5b33b57b3 100644 --- a/app/helpers/user_helper.rb +++ b/app/helpers/user_helper.rb @@ -58,7 +58,7 @@ module UserHelper def auth_button(name, provider, options = {}) link_to( - image_tag("#{name}.png", :alt => t("users.login.auth_providers.#{name}.alt")), + image_tag("#{name}.svg", :alt => t("users.login.auth_providers.#{name}.alt"), :class => "rounded-lg"), auth_path(options.merge(:provider => provider)), :class => "auth_button", :title => t("users.login.auth_providers.#{name}.title") diff --git a/config/github.database.yml b/config/github.database.yml new file mode 100644 index 000000000..9f9c4b1de --- /dev/null +++ b/config/github.database.yml @@ -0,0 +1,4 @@ +test: + adapter: postgresql + database: openstreetmap + encoding: utf8 diff --git a/lib/gpx.rb b/lib/gpx.rb index d0607233a..86cf2f49d 100644 --- a/lib/gpx.rb +++ b/lib/gpx.rb @@ -44,8 +44,8 @@ module GPX @tracksegs = 0 begin - Archive::Reader.open_filename(@file).each_entry_with_data do |_entry, data| - parse_file(XML::Reader.string(data), &block) + Archive::Reader.open_filename(@file).each_entry_with_data do |entry, data| + parse_file(XML::Reader.string(data), &block) if entry.regular? end rescue Archive::Error io = ::File.open(@file) diff --git a/script/normalise-structure b/script/normalise-structure new file mode 100644 index 000000000..9cf0b6cae --- /dev/null +++ b/script/normalise-structure @@ -0,0 +1,10 @@ +/^$/d +/^--/d +/^CREATE EXTENSION IF NOT EXISTS plpgsql /d +/^COMMENT ON EXTENSION plpgsql /d +/^SET default_with_oids /d +/^SET default_table_access_method /d +/^SET idle_in_transaction_session_timeout /d +/^ AS integer$/d + +s/ IMMUTABLE / / diff --git a/test/helpers/user_helper_test.rb b/test/helpers/user_helper_test.rb index c2b54c056..340d2494d 100644 --- a/test/helpers/user_helper_test.rb +++ b/test/helpers/user_helper_test.rb @@ -73,10 +73,10 @@ class UserHelperTest < ActionView::TestCase def test_auth_button button = auth_button("google", "google") - assert_equal("\"Login", button) + assert_equal("\"Login", button) button = auth_button("yahoo", "openid", :openid_url => "yahoo.com") - assert_equal("\"Login", button) + assert_equal("\"Login", button) end private diff --git a/test/test_helper.rb b/test/test_helper.rb index 720618ba0..41dac890a 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,21 +1,30 @@ -require "coveralls" -Coveralls.wear!("rails") - -# Override the simplecov output message, since it is mostly unwanted noise -module SimpleCov - module Formatter - class HTMLFormatter - def output_message(_result); end +require "simplecov" +require "simplecov-lcov" + +# Fix incompatibility of simplecov-lcov with older versions of simplecov that are not expresses in its gemspec. +# https://github.com/fortissimo1997/simplecov-lcov/pull/25 +unless SimpleCov.respond_to?(:branch_coverage) + module SimpleCov + def self.branch_coverage? + false end end end -# Output both the local simplecov html and the coveralls report -SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new( - [SimpleCov::Formatter::HTMLFormatter, - Coveralls::SimpleCov::Formatter] +SimpleCov::Formatter::LcovFormatter.config do |config| + config.report_with_single_file = true + config.single_report_path = "coverage/lcov.info" +end + +SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new( + [ + SimpleCov::Formatter::HTMLFormatter, + SimpleCov::Formatter::LcovFormatter + ] ) +SimpleCov.start("rails") + require "securerandom" require "digest/sha1"