Compare commits

..

1 Commits

Author SHA1 Message Date
Dawa Ometto f3fd06ef7a Update test.yaml 2021-11-06 13:36:32 +01:00
14 changed files with 66 additions and 125 deletions
+2 -2
View File
@@ -34,5 +34,5 @@ jobs:
run: echo ${{ steps.docker_build.outputs.digest }}
- name: docker state
run: docker image ls
- name: Run gollum as test
run: docker run -e CI=true ${{ env.CI_IMAGE }} --irb
- name: Run tests
run: docker run -e CI=true -w /app --entrypoint bundle ${{ env.CI_IMAGE }} exec rake
+11 -28
View File
@@ -1,46 +1,29 @@
name: Ruby Build
on: [push, pull_request]
jobs:
jruby_build:
name: JRuby (${{ matrix.ruby }})
build:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: [jruby-9.2.18]
ruby: [2.4.0, 2.6.0, 3.0.0, jruby-9.2.18.0]
steps:
- run: echo "The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v2
- run: echo "The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- name: Set up Java
uses: actions/setup-java@v2
- uses: actions/setup-java@v2
with:
distribution: 'adopt'
distribution: 'temurin'
java-version: '11'
- name: Set up Ruby
uses: ruby/setup-ruby@v1
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
run: bundle exec rake
mri_build:
name: Ruby (${{ matrix.ruby }})
runs-on: ubuntu-latest
strategy:
matrix:
ruby: [2.6, 2.7, 3.0]
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
- name: exec rake
run: bundle exec rake
+5 -16
View File
@@ -1,11 +1,9 @@
FROM ruby:2.7-alpine AS builder
FROM ruby:2.7
ENV DEBIAN_FRONTEND="noninteractive"
RUN apk add \
build-base \
cmake \
git \
icu-dev \
openssl-dev
RUN apt-get update && apt-get install -y \
libicu-dev \
cmake
COPY Gemfile* /tmp/
COPY gollum.gemspec* /tmp/
@@ -25,15 +23,6 @@ WORKDIR /app
COPY . /app
RUN bundle exec rake install
FROM ruby:2.7-alpine
COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
RUN apk add \
bash \
git
VOLUME /wiki
WORKDIR /wiki
COPY docker-run.sh /docker-run.sh
+4 -21
View File
@@ -1,26 +1,9 @@
source 'https://rubygems.org'
gem 'warbler', platforms: :jruby
# FIXME:
#
# There's an issue in 1.12.5 that causes XHTML elements to be generated badly,
# causing Gollum's test suite to fail.[1] The issue has been fixed upstream,
# but we're still waiting for a new Nokogiri point release.
#
# However, 1.12.5 is a security patch, so we don't want end users to use an
# older version of Nokogiri. But this is safe to do in our CI environment.
#
# Once there's a new Nokogiri release, we can remove this dependency and JRuby
# CI should pass normally again.
#
# Note that Nokogiri 1.11+ does not support Ruby v2.4.x anymore. So to make our
# current CI workflows pass, we should only try to install this version of
# Nokogiri for newer Ruby versions.
#
# [1]: https://github.com/gollum/gollum/issues/1779
gem 'nokogiri', '1.12.4' unless RUBY_VERSION.include? '2.4'
if RUBY_PLATFORM == 'java'
gem 'warbler'
end
gemspec
gem 'rake', '~> 13.0'
gem 'rake', '~> 13.0'
+1 -1
View File
@@ -206,7 +206,7 @@ begin
rescue OptionParser::InvalidOption => e
puts "gollum: #{e.message}"
puts 'gollum: try \'gollum --help\' for more information'
exit 1
exit
end
# --gollum-path wins over ARGV[0]
+1 -2
View File
@@ -6,5 +6,4 @@ if [ ! -d .git ]; then
fi
# Start gollum service
[[ "$@" != *--mathjax* ]] && echo "WARNING: Mathjax will soon be disabled by default. To explicitly enable it, use --mathjax" >&2
exec gollum $@ --mathjax
gollum --mathjax
+1
View File
@@ -44,6 +44,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rack-test', '~> 0.6.3'
s.add_development_dependency 'shoulda', '~> 3.6.0'
s.add_development_dependency 'minitest-reporters', '~> 1.3.6'
s.add_development_dependency 'twitter_cldr', '~> 3.2.0'
s.add_development_dependency 'mocha', '~> 1.8.0'
s.add_development_dependency 'test-unit', '~> 3.3.0'
+3 -3
View File
@@ -20,7 +20,6 @@ require 'gollum/views/layout'
require 'gollum/views/editable'
require 'gollum/views/has_page'
require 'gollum/views/has_user_icons'
require 'gollum/views/has_math'
require 'gollum/views/pagination'
require 'gollum/views/rss.rb'
require 'gollum/views/template_cascade'
@@ -126,7 +125,6 @@ module Precious
@css = settings.wiki_options[:css]
@js = settings.wiki_options[:js]
@mathjax_config = settings.wiki_options[:mathjax_config]
@mathjax = settings.wiki_options[:mathjax]
@use_static_assets = settings.wiki_options.fetch(:static, settings.environment != :development)
@static_assets_path = settings.wiki_options.fetch(:static_assets_path, ::File.join(File.dirname(__FILE__), 'public/assets'))
@@ -219,6 +217,7 @@ module Precious
if page = wikip.page
@page = page
@content = page.text_data
@mathjax = wiki.mathjax
@etag = page.sha
mustache :edit
else
@@ -240,7 +239,7 @@ module Precious
halt 500 unless tempfile.is_a? Tempfile
if wiki.per_page_uploads
dir = request.referer.match(/^https?:\/\/#{request.host_with_port}\/(.*)/)[1]
dir = request.referer.sub(request.base_url, '')
# remove base path if it is set
dir.sub!(/^#{wiki.base_path}/, '') if wiki.base_path
# remove base_url and gollum/* subpath if necessary
@@ -614,6 +613,7 @@ module Precious
# Extensions and layout data
@editable = true
@toc_content = wiki.universal_toc ? @page.toc_data : nil
@mathjax = wiki.mathjax
@h1_title = wiki.h1_title
@bar_side = wiki.bar_side
@allow_uploads = wiki.allow_uploads
+2 -3
View File
@@ -2,7 +2,6 @@ module Precious
module Views
class Create < Layout
include Editable
include HasMath
attr_reader :page, :name
@@ -42,9 +41,9 @@ module Precious
def content
@template_page
end
private
def find_format
@found_format ||= (Gollum::Page.format_for("#{@name}#{@ext}") || default_markup)
end
+5 -2
View File
@@ -3,7 +3,6 @@ module Precious
class Edit < Layout
include Editable
include HasPage
include HasMath
attr_reader :page, :content
@@ -19,6 +18,10 @@ module Precious
def page_name
@name
end
def mathjax
@mathjax
end
def header
if @header.nil?
@@ -64,7 +67,7 @@ module Precious
def etag
@etag
end
def allow_uploads
@allow_uploads
end
-11
View File
@@ -1,11 +0,0 @@
module Precious
module HasMath
def mathjax
@mathjax
end
def mathjax_config
@mathjax_config
end
end
end
+15 -8
View File
@@ -2,10 +2,9 @@ module Precious
module Views
class Page < Layout
include HasPage
include HasMath
attr_reader :content, :page, :header, :footer, :preview, :historical
VALID_COUNTER_STYLES = ['decimal', 'decimal-leading-zero', 'arabic-indic', 'armenian', 'upper-armenian',
'lower-armenian', 'bengali', 'cambodian', 'khmer', 'cjk-decimal', 'devanagari', 'georgian', 'gujarati', 'gurmukhi',
'hebrew', 'kannada', 'lao', 'malayalam', 'mongolian', 'myanmar', 'oriya', 'persian', 'lower-roman', 'upper-roman',
@@ -62,11 +61,11 @@ module Precious
def editable
@editable
end
def search
true
end
def history
true
end
@@ -74,11 +73,11 @@ module Precious
def latest_changes
true
end
def overview
true
true
end
def allow_editing
@allow_editing
end
@@ -158,6 +157,14 @@ module Precious
@toc_content
end
def mathjax
@mathjax
end
def mathjax_config
@mathjax_config
end
def use_identicon
@page.wiki.user_icons == 'identicon'
end
@@ -175,7 +182,7 @@ module Precious
# Returns Hash.
def metadata
@page.metadata
end
end
# Access to embedded metadata.
#
+1
View File
@@ -6,6 +6,7 @@ require 'mocha/setup'
require 'fileutils'
require 'minitest/reporters'
require 'minitest/spec'
require 'twitter_cldr'
require 'tmpdir'
# Silence locale validation warning
+15 -28
View File
@@ -39,29 +39,31 @@ context "Frontend" do
assert_match /<pre><code>one\ntwo\nthree\nfour\n<\/code><\/pre>\n/m, last_response.body
end
def nfd utf8
TwitterCldr::Normalization.normalize(utf8, using: :nfd)
end
test 'mathjax assets are served' do
get '/gollum/assets/mathjax/MathJax.js'
assert last_response.ok?
end
test "UTF-8 headers href preserved" do
page_content = <<~TEXT
## 한글
page = 'utfh1'
text = nfd('한글')
Test page "utfh1" content.
TEXT
# don't use h1 or it will be promoted to replace file name
# which doesn't generate a normal header link
@wiki.write_page(page, :markdown, '## ' + text,
{ :name => 'user1', :email => 'user1' });
@wiki.write_page('utfh1',
:markdown,
page_content,
{name: 'user1', email: 'user1'})
get page
expected = "<h2 class=\"editable\"><a class=\"anchor\" (href|id)=\"(#)?#{text}\" (href|id)=\"(#)?#{text}\"></a>#{text}</h2>"
actual = nfd(last_response.body)
get 'utfh1'
expected = "<h2 class=\"editable\"><a class=\"anchor\" (href|id)=\"(#)?한글\" (href|id)=\"(#)?한글\"></a>한글</h2>"
assert_match /#{expected}/, last_response.body
assert_match /#{expected}/, actual
end
test 'rss feed' do
channel_title = <<EOF
<title>Gollum Wiki Latest Changes</title>
@@ -445,21 +447,6 @@ EOF
Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false})
end
test "upload a file with https referer" do
temp_upload_file = Tempfile.new(['https_upload', '.file']) << 'abc'
temp_upload_file.close
Precious::App.set(:wiki_options, {allow_uploads: true, per_page_uploads: true})
post "/gollum/upload_file", {:file => Rack::Test::UploadedFile.new(::File.open(temp_upload_file))}, {'HTTP_REFERER' => 'https://localhost:4567/Home.md', 'HTTP_HOST' => 'localhost:4567'}
assert_equal 302, last_response.status # redirect is expected
@wiki.clear_cache
# Find the file in a page-specific subdir (here: Home), based on referer
file = @wiki.file("uploads/Home/#{::File.basename(temp_upload_file.path)}")
assert_equal 'abc', file.raw_data
Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false})
end
test "guard against uploading an existing file" do
temp_upload_file = Tempfile.new(['upload', '.file']) << 'abc'
temp_upload_file.close