From ca1802758f302a1a91cf1cc88f2dea656aeaf645 Mon Sep 17 00:00:00 2001 From: Andrew Shu Date: Thu, 12 Aug 2021 18:18:20 -0700 Subject: [PATCH 1/5] Migrate from Travis CI to GitHub Actions --- .github/workflows/ci.yml | 41 +++++++++++++++++++++++++++ .travis.yml | 11 ------- README.md | 2 +- app_helpers.rb | 4 +-- config.yml.travis => config.yml.ci | 2 +- environment.rb | 4 +-- models/site.rb | 4 +-- tests/workers/archive_worker_tests.rb | 2 +- 8 files changed, 50 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml rename config.yml.travis => config.yml.ci (90%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..9008cb17 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: CI +on: [push, pull_request] +jobs: + test: + runs-on: ubuntu-18.04 + + services: + postgres: + image: postgres + env: + POSTGRES_DB: ci_test + POSTGRES_PASSWORD: citestpassword + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 + redis: + image: redis + # Set health checks to wait until redis has started + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps port 6379 on service container to the host + - 6379:6379 + + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.6 + bundler-cache: true + - run: sudo apt-get -y install chromium-browser + - run: bundle exec rake diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ceca0466..00000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: ruby -rvm: - - "2.6.0" -services: - - redis-server - - postgresql -before_script: - - psql -c 'create database travis_ci_test;' -U postgres -sudo: false -bundler_args: --jobs=1 -before_install: gem install bundler diff --git a/README.md b/README.md index 880babb4..deb2bf74 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # Neocities.org -[![Build Status](https://travis-ci.org/neocities/neocities.png?branch=master)](https://travis-ci.org/neocities/neocities) +[![Build Status](https://github.com/neocities/neocities/actions/workflows/ci.yml/badge.svg)](https://github.com/neocities/neocities/actions?query=workflow%3ACI) [![Coverage Status](https://coveralls.io/repos/neocities/neocities/badge.svg?branch=master&service=github)](https://coveralls.io/github/neocities/neocities?branch=master) The web site for Neocities! It's open source. Want a feature on the site? Send a pull request! diff --git a/app_helpers.rb b/app_helpers.rb index 3cd08ff1..7eaab158 100644 --- a/app_helpers.rb +++ b/app_helpers.rb @@ -119,7 +119,7 @@ def flash_display(opts={}) end def recaptcha_valid? - return true if ENV['RACK_ENV'] == 'test' || ENV['TRAVIS'] + return true if ENV['RACK_ENV'] == 'test' || ENV['CI'] return false unless params[:'g-recaptcha-response'] resp = Net::HTTP.get URI( 'https://www.google.com/recaptcha/api/siteverify?'+ @@ -137,7 +137,7 @@ def recaptcha_valid? end def hcaptcha_valid? - return true if ENV['RACK_ENV'] == 'test' || ENV['TRAVIS'] + return true if ENV['RACK_ENV'] == 'test' || ENV['CI'] return false unless params[:'h-captcha-response'] resp = Net::HTTP.get URI( diff --git a/config.yml.travis b/config.yml.ci similarity index 90% rename from config.yml.travis rename to config.yml.ci index 173757c3..ceff601f 100644 --- a/config.yml.travis +++ b/config.yml.ci @@ -1,4 +1,4 @@ -database: 'postgres://postgres@localhost/travis_ci_test' +database: 'postgres://postgres:citestpassword@localhost/ci_test' database_pool: 1 session_secret: 's3cr3t' recaptcha_public_key: '1234' diff --git a/environment.rb b/environment.rb index f7b02b22..8510c652 100644 --- a/environment.rb +++ b/environment.rb @@ -17,8 +17,8 @@ require 'active_support/core_ext/integer/time' Dir['./ext/**/*.rb'].each {|f| require f} # :nocov: -if ENV['TRAVIS'] - $config = YAML.load_file File.join(DIR_ROOT, 'config.yml.travis') +if ENV['CI'] + $config = YAML.load_file File.join(DIR_ROOT, 'config.yml.ci') else begin $config = YAML.load_file(File.join(DIR_ROOT, 'config.yml'))[ENV['RACK_ENV']] diff --git a/models/site.rb b/models/site.rb index cb3e14a1..fdb07ade 100644 --- a/models/site.rb +++ b/models/site.rb @@ -708,8 +708,8 @@ class Site < Sequel::Model return false unless valid_file_mime_type_and_ext?(mime_type, extname) - # clamdscan doesn't work on travis for testing - return true if ENV['TRAVIS'] == 'true' + # clamdscan doesn't work on continuous integration for testing + return true if ENV['CI'] == 'true' File.chmod 0666, uploaded_file[:tempfile].path line = Terrapin::CommandLine.new( diff --git a/tests/workers/archive_worker_tests.rb b/tests/workers/archive_worker_tests.rb index 90a748e2..8cfa9ea8 100644 --- a/tests/workers/archive_worker_tests.rb +++ b/tests/workers/archive_worker_tests.rb @@ -2,7 +2,7 @@ require_relative '../environment.rb' describe ArchiveWorker do it 'stores an IPFS archive' do - return if ENV['TRAVIS'] + return if ENV['CI'] site = Fabricate :site ipfs_hash = site.add_to_ipfs ArchiveWorker.new.perform site.id From 73579a8a94460c9c72a216ee9290073b6e6e59f0 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Sat, 12 Nov 2022 14:44:24 -0600 Subject: [PATCH 2/5] use ruby 3.1 with github actions --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9008cb17..da1e1496 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: - uses: actions/checkout@v2 - uses: ruby/setup-ruby@v1 with: - ruby-version: 2.6 + ruby-version: 3.1 bundler-cache: true - run: sudo apt-get -y install chromium-browser - run: bundle exec rake From b8578059dacb65276c83d72abdb746e9bf2be4f8 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Sat, 12 Nov 2022 14:46:49 -0600 Subject: [PATCH 3/5] try ubuntu 22.04 with github actions --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da1e1496..958bd8e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI on: [push, pull_request] jobs: test: - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 services: postgres: From 74df720aeaca13830f97b2d66378ec1d35982d27 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Sat, 12 Nov 2022 14:55:01 -0600 Subject: [PATCH 4/5] replace coveralls with coveralls_reborn --- Gemfile | 2 +- Gemfile.lock | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index 78307e1c..a53b83f5 100644 --- a/Gemfile +++ b/Gemfile @@ -29,7 +29,7 @@ gem 'geoip' gem 'io-extra', require: 'io/extra' #gem 'rye' gem 'base32' -gem 'coveralls', require: false +gem 'coveralls_reborn', require: false gem 'sanitize' gem 'will_paginate' gem 'simpleidn' diff --git a/Gemfile.lock b/Gemfile.lock index 19a2042d..e079490a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,12 +50,11 @@ GEM coderay (1.1.3) concurrent-ruby (1.1.10) connection_pool (2.3.0) - coveralls (0.7.1) - multi_json (~> 1.3) - rest-client - simplecov (>= 0.7) - term-ansicolor - thor + coveralls_reborn (0.25.0) + simplecov (>= 0.18.1, < 0.22.0) + term-ansicolor (~> 1.6) + thor (>= 0.20.3, < 2.0) + tins (~> 1.16) crack (0.4.5) rexml crass (1.0.6) @@ -318,7 +317,7 @@ DEPENDENCIES bcrypt capybara certified - coveralls + coveralls_reborn dav4rack! erubis fabrication From a2098a300ea61adfc34d8dc2e2dabf4de57ebc11 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Wed, 16 Nov 2022 15:47:40 -0600 Subject: [PATCH 5/5] put canonical url link on all pages --- views/layout.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/views/layout.erb b/views/layout.erb index 232d366a..b4ca497b 100644 --- a/views/layout.erb +++ b/views/layout.erb @@ -15,6 +15,8 @@ + + <% if meta_robots %>