diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 051330d9..403389ab 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,8 +9,52 @@ on: - '*' jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby: ['3.0', '3.1', '3.2'] + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + - uses: arduino/setup-task@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Show repository information + run: task info + - name: Run tests + run: task test + - name: Coveralls + uses: coverallsapp/github-action@v2 + + release: + runs-on: ubuntu-latest + needs: test + env: + GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.1' + - uses: arduino/setup-task@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Build and release gem + run: task gem:build gem:push + docker: runs-on: ubuntu-latest + needs: test steps: - name: Git describe id: ghd @@ -18,14 +62,16 @@ jobs: - name: Check outputs run: | echo "describe: ${{ steps.ghd.outputs.describe }}" - - - name: Set up QEMU + - name: Set up QEMU uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - - name: Login to GitHub Container Registry + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: registry: ghcr.io @@ -36,14 +82,11 @@ jobs: uses: docker/metadata-action@v4 with: images: | + docker.io/aksw/jekyll-rdf ghcr.io/aksw/jekyll-rdf - - - name: Build and push + - name: Build and push uses: docker/build-push-action@v3 with: - # according to https://github.com/docker/build-push-action/issues/761#issuecomment-1383822381 - driver-opts: | - image=moby/buildkit:v0.10.6 push: true platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 build-args: VERSION=${{ steps.ghd.outputs.describe }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ba8af76d..00000000 --- a/.travis.yml +++ /dev/null @@ -1,33 +0,0 @@ -language: ruby -services: - - docker -rvm: -- 2.3.8 -- 2.5.3 -- 2.7.0 -- ruby-head -matrix: - allow_failures: - - rvm: ruby-head -before_install: -- docker run -p 3030:3030 -d stain/jena-fuseki:latest ./fuseki-server --mem /remote -- cd test/theme-gem -- bundle install -- cd ../.. -script: -- bundle exec rake test -deploy: - - provider: rubygems - api_key: - secure: D8rx4lfdlvWFjXPrHTOXudIrUpjBHu++4ebWzNcXNdk8ccNtRbkWCqK7vOp7BAXu8NXGQOT/XoHmcwuzOpaLMiPL6B+eNTPWnC2wqeQUlZcZak6btFXwMivKXRT5oyIP/UjciucLDN9jq+54fdr5M7+nJ+3D7upUA2P3ymb+69U0l0bXl9WA+c92LRi/wXXeyxdpImHym8PxBagS6GPiHswcHoeRRq5vNEmo/E9RYV5F0Kzyj8vOchO/83cDeqeQEPX969AtO0AKZczWfNx2qOBgcYcUmxfOdAooOnFYjw3A9QZgI3B/T7LC1137mCLQCcb/e0cFPiwQYxDXS8SEEd1t4t/4Tw/zUh+TFuSAbCPJz1tG91KYhcVBDzsvQh1dU0WY7TDXRrasvNU7HJ+TMGIq7nC+QvSRJ1SyKsI89aLKA8fAO06DwI/7LodG+G/0MAxFO5XLu1EBJ8k+mxdkbSqoZxSdtvvWkAUkdjWXtOtGNUhYtuVTJrzjrWUOM2YuhmnGAwJg8UgUKzDvjNCQ0Zm2q5TiYZT5nsv8FwE6zjSK7ETnp+ofW/RwxbZs7DNTDTShKAyoy2NEKrPfFvkFkoUSP3yR+e8hJpRo2hJFC/3GxgnTr4bdI814Y5UOBfGjVXUKsodMhtk0uhJCIQMm8Jri1o5600szSW+lG20KSkg= - gem: jekyll-rdf - on: - condition: $TRAVIS_RUBY_VERSION = 2.7.0 - branch: master - - provider: rubygems - api_key: - secure: D8rx4lfdlvWFjXPrHTOXudIrUpjBHu++4ebWzNcXNdk8ccNtRbkWCqK7vOp7BAXu8NXGQOT/XoHmcwuzOpaLMiPL6B+eNTPWnC2wqeQUlZcZak6btFXwMivKXRT5oyIP/UjciucLDN9jq+54fdr5M7+nJ+3D7upUA2P3ymb+69U0l0bXl9WA+c92LRi/wXXeyxdpImHym8PxBagS6GPiHswcHoeRRq5vNEmo/E9RYV5F0Kzyj8vOchO/83cDeqeQEPX969AtO0AKZczWfNx2qOBgcYcUmxfOdAooOnFYjw3A9QZgI3B/T7LC1137mCLQCcb/e0cFPiwQYxDXS8SEEd1t4t/4Tw/zUh+TFuSAbCPJz1tG91KYhcVBDzsvQh1dU0WY7TDXRrasvNU7HJ+TMGIq7nC+QvSRJ1SyKsI89aLKA8fAO06DwI/7LodG+G/0MAxFO5XLu1EBJ8k+mxdkbSqoZxSdtvvWkAUkdjWXtOtGNUhYtuVTJrzjrWUOM2YuhmnGAwJg8UgUKzDvjNCQ0Zm2q5TiYZT5nsv8FwE6zjSK7ETnp+ofW/RwxbZs7DNTDTShKAyoy2NEKrPfFvkFkoUSP3yR+e8hJpRo2hJFC/3GxgnTr4bdI814Y5UOBfGjVXUKsodMhtk0uhJCIQMm8Jri1o5600szSW+lG20KSkg= - gem: jekyll-rdf - on: - condition: $TRAVIS_RUBY_VERSION = 2.7.0 - branch: develop diff --git a/CHANGELOG.md b/CHANGELOG.md index 169885a3..cd292ba0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unrelease] ### Added -- +- Install git in the docker image ### Changed - @@ -15,6 +15,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - +## [4.1.0] - 2023-06-03 + +### Fixed +- Support for Ruby 3.1 +- Build system + ## [4.0.4] - 2023-02-21 ### Changed diff --git a/Dockerfile b/Dockerfile index 9bf57de9..aaca743c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ CMD /usr/local/bundle/bin/jekyll build FROM ruby:3.1-slim COPY --from=builder /jekyll-rdf/docker-resources/ /docker-resources COPY --from=builder /usr/local/bundle/ /usr/local/bundle/ -RUN apt-get update && apt-get -y install build-essential && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get -y install build-essential git && rm -rf /var/lib/apt/lists/* WORKDIR /data diff --git a/Taskfile.yml b/Taskfile.yml index 5a24bf06..198f0373 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,8 +1,15 @@ version: '3' env: - VERSION: + BUNDLE_PATH: .vendor + +vars: + GIT_DESCRIBE: sh: git describe --tags --dirty --always + GEM_VERSION: + sh: ruby -e "if Gem::Version.new(ARGV[0]).prerelease? then puts Gem::Version.new(Gem::Version.new(ARGV[0].split('-')[0]).bump().to_s + '-' + ARGV[0].split('-')[1..].join('.')) else puts Gem::Version.new(ARGV[0]) end" {{.GIT_DESCRIBE}} + GEM_NAME: jekyll-rdf + DOCKER_IMAGE: aksw/jekyll-rdf tasks: @@ -11,7 +18,54 @@ tasks: cmds: - task -a + info: + desc: Output some variables + cmds: + - | + echo "GIT_DESCRIBE: {{.GIT_DESCRIBE}}" + echo "GEM_VERSION: {{.GEM_VERSION}}" + echo "GEM_NAME: {{.GEM_NAME}}" + echo "DOCKER_IMAGE: {{.DOCKER_IMAGE}}" + + install: + desc: Install jekyll rdf and its dependencies with bundle + cmds: + - bundle install + + gem:build: + desc: Build the ruby gem + cmds: + - gem build {{.GEM_NAME}}.gemspec + + gem:push: + desc: Push the gem to rubygems.org + cmds: + - gem push {{.GEM_NAME}}-{{.GEM_VERSION}}.gem + docker:build: desc: The list of all defined tasks cmds: - - docker build --no-cache --build-arg VERSION={{.VERSION}} -t jekyll-rdf:{{.VERSION}} . + - docker build --no-cache --build-arg VERSION={{.GEM_VERSION}} -t {{.DOCKER_IMAGE}}:{{.GEM_VERSION}} . + + test: + desc: Run the tests + deps: + - task: test:setup + cmds: + - bundle exec rake test + + test:setup: + desc: Setup the test environment + cmds: + - task: test:setup:endpoint-container + - | + cd test/theme-gem + bundle install + - bundle install + + test:setup:endpoint-container: + desc: Start a saprql endpoint for the tests + cmds: + - docker run --rm -d -p 3030:3030 --name jekyll_rdf_test_endpoint stain/jena-fuseki:4.8.0 ./fuseki-server --mem /remote + status: + - '[ "$( docker inspect --format "{{`{{.State.Running}}`}}" jekyll_rdf_test_endpoint )" = "true" ]' diff --git a/jekyll-rdf.gemspec b/jekyll-rdf.gemspec index 22c1f1e5..f8b7377c 100644 --- a/jekyll-rdf.gemspec +++ b/jekyll-rdf.gemspec @@ -1,7 +1,14 @@ # coding: utf-8 RELEASE_VERSION = case when ENV['VERSION'] then ENV['VERSION'] - else `git describe --tags --dirty --always` + else + version = `git describe --tags --dirty --always` + # if Gem::Version.new(ARGV[0]).prerelease? then puts Gem::Version.new(Gem::Version.new(ARGV[0].split('-')[0]).bump().to_s + '-' + ARGV[0].split('-')[1..].join('.')) else puts Gem::Version.new(ARGV[0]) end + if Gem::Version.new(version).prerelease? then + Gem::Version.new(Gem::Version.new(version.split('-')[0]).bump().to_s + '-' + version.split('-')[1..].join('.')) + else + Gem::Version.new(version) + end end Gem::Specification.new do |s| @@ -17,14 +24,14 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'linkeddata', '~> 3.2', '>= 3.2.0' s.add_runtime_dependency 'sparql-client', '~> 3.2', '>= 3.2.0' s.add_runtime_dependency 'jekyll', '>= 4.2', '>= 4.2.1' - s.add_development_dependency 'rake', '~> 13.0' + s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6' s.add_development_dependency 'rest-client', '~> 2.0', '>= 2.0.1' - s.add_development_dependency 'coveralls', '~> 0.8' + s.add_development_dependency 'simplecov', '~> 0.22.0' s.add_development_dependency 'test-unit', '~> 3.0' s.add_development_dependency 'shoulda-context', '~> 1.1' s.add_development_dependency 'rspec', '~> 3.0' s.add_development_dependency 'pry-byebug', '~> 3.4' s.add_development_dependency 'rdoc', '~> 6.2', '>= 6.2.1' - s.add_development_dependency 'jekyll-theme-jod', '~> 0.2' + s.add_development_dependency 'jekyll-theme-jod', '~> 0.3' s.add_development_dependency 'kramdown-parser-gfm', '~> 1.1' end diff --git a/lib/jekyll/helper/rdf_hook_helper.rb b/lib/jekyll/helper/rdf_hook_helper.rb index e208bd69..e52929ae 100644 --- a/lib/jekyll/helper/rdf_hook_helper.rb +++ b/lib/jekyll/helper/rdf_hook_helper.rb @@ -43,13 +43,10 @@ def backload_prefixes page, payload base_path = page.instance_variable_get(:@base_dir) base_path ||= payload.site["source"] end - rescue NoMethodError => ne - #just in case the error was caused by something different then a missing template - if(ne.message.eql? "undefined method `data' for nil:NilClass") - return - else - raise - end + rescue MissingTemplate + # the case that a template is missing + # aka. undefined method `data' for nil:NilClass + return end if(page.data["rdf_prefixes"].nil? && !(prefix_path.nil? || base_path.nil?)) Jekyll::JekyllRdf::Helper::RdfHelper.load_prefixes( @@ -70,7 +67,13 @@ def search_prefix_definition layout, rdf_prefix_path return nil end + class MissingTemplate < StandardError + end + def check_prefix_definition layout + if layout.nil? + raise MissingTemplate.new "Missing template" + end unless(layout.data["rdf_prefix_path"].nil?) return [layout.instance_variable_get(:@base_dir), layout.data["rdf_prefix_path"]] end diff --git a/test/cases/dontFailIfLayoutNoFound/test_prefixes.rb b/test/cases/dontFailIfLayoutNoFound/test_prefixes.rb index dd31a9ee..43625571 100644 --- a/test/cases/dontFailIfLayoutNoFound/test_prefixes.rb +++ b/test/cases/dontFailIfLayoutNoFound/test_prefixes.rb @@ -1,9 +1,9 @@ require 'test_helper' class TestPrefixes < Test::Unit::TestCase - context "load_prefixes form RdfPageHelper" do + context "load_prefixes from RdfPrefixHelper" do include RdfTestUtility - should "check that the prefix search doesnot fail of an undefined layout is specified" do + should "check that the prefix search doesnot fail if an undefined layout is specified" do setup_jekyll File.dirname(__FILE__) blogfile = File.read(File.join(@source, "_site/2019/02/12/Blogpost.html")) diff --git a/test/cases/pagesMissingTemplate/test_missing_template.rb b/test/cases/pagesMissingTemplate/test_missing_template.rb index 49070812..8003abd1 100644 --- a/test/cases/pagesMissingTemplate/test_missing_template.rb +++ b/test/cases/pagesMissingTemplate/test_missing_template.rb @@ -2,7 +2,7 @@ class TestMissingTemplate < Test::Unit::TestCase include RdfTestUtility - context "load_data form RdfPageHelper" do + context "load_data from RdfPageHelper" do should "exit page generation if Jekyll did not load its mapped layout" do #We can't recreate this case with MWE TestHelper::setErrOutput setup_jekyll File.dirname(__FILE__) @@ -11,4 +11,3 @@ class TestMissingTemplate < Test::Unit::TestCase end end end - diff --git a/test/cases/remoteGraphs/test_remote.rb b/test/cases/remoteGraphs/test_remote.rb index 4b82cff9..54e70c9f 100644 --- a/test/cases/remoteGraphs/test_remote.rb +++ b/test/cases/remoteGraphs/test_remote.rb @@ -1,10 +1,12 @@ require 'test_helper' require 'rest_client' +require 'uri' class TestGeneral < Test::Unit::TestCase include RSpec::Matchers include RdfTestUtility - RestClient.post('http://localhost:3030/remote/upload', :graph => "http://localhost:3030/remote/data/graph1", :name_of_file_param => File.new(File.join(File.dirname(__FILE__), "_data/knowledge-base.ttl"))) + graph_param = URI::encode_www_form("graph" => "http://localhost:3030/remote/data/graph1") + RestClient.put("http://localhost:3030/remote/?" + graph_param, File.read(File.join(File.dirname(__FILE__), "_data/knowledge-base.ttl")), :content_type => "text/turtle;charset=utf-8") context "A remote sparql endpoint on a specified default graph" do should "keep rdf_get and rdf_property usable" do setup_jekyll File.dirname(__FILE__) diff --git a/test/cases/remoteSPARQL/test_remote.rb b/test/cases/remoteSPARQL/test_remote.rb index 5677acd3..0988f698 100644 --- a/test/cases/remoteSPARQL/test_remote.rb +++ b/test/cases/remoteSPARQL/test_remote.rb @@ -4,7 +4,7 @@ class TestGeneral < Test::Unit::TestCase include RSpec::Matchers include RdfTestUtility - RestClient.post('http://localhost:3030/remote/upload', :name_of_file_param => File.new(File.join(File.dirname(__FILE__), "_data/knowledge-base.ttl"))) + RestClient.put("http://localhost:3030/remote/?default", File.read(File.join(File.dirname(__FILE__), "_data/knowledge-base.ttl")), :content_type => "text/turtle;charset=utf-8") context "A remote sparql endpoint" do should "keep rdf_get and rdf_property usable" do setup_jekyll File.dirname(__FILE__) diff --git a/test/test_helper.rb b/test/test_helper.rb index 471ce2a9..447ed2e7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,13 +2,11 @@ require 'shoulda-context' require 'rspec/expectations' require 'simplecov' -require 'coveralls' require 'ResourceHelper' require 'RdfTestUtility' SimpleCov.formatters = SimpleCov::Formatter::MultiFormatter.new([ SimpleCov::Formatter::HTMLFormatter, - Coveralls::SimpleCov::Formatter ]) SimpleCov.start do add_filter ["/.vendor", "/vendor", "/test"]