diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd6c3375022..610ca99a9ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,19 +3,18 @@ name: Continuous Integration on: push: branches: - - master - - /.*-stable/ + - 4.2-stable pull_request: branches: - - master - - /.*-stable/ + - 4.2-stable jobs: ci: if: "!contains(github.event.commits[0].message, '[ci skip]')" name: 'Ruby ${{ matrix.ruby_version }}' runs-on: 'ubuntu-latest' - + env: + CI: true strategy: fail-fast: false matrix: @@ -23,7 +22,6 @@ jobs: - 2.5 - 2.7 - jruby-9.2.11.1 - steps: - uses: actions/checkout@v2 with: @@ -35,12 +33,8 @@ jobs: bundler-cache: true - name: Run Unit Tests run: bash script/test - env: - CI: true - name: Run Cucumber Features run: bash script/cucumber - env: - CI: true - name: Sanity Check run: bash script/default-site @@ -69,34 +63,22 @@ jobs: if: "!contains(github.event.commits[0].message, '[ci skip]')" name: 'Profile Docs Site (Ruby ${{ matrix.ruby_version }})' runs-on: 'ubuntu-latest' + env: + CI: true strategy: fail-fast: false matrix: ruby_version: - - 2.4 # Minimum required Ruby version in gemspec + - 2.5 steps: - uses: actions/checkout@v2 with: fetch-depth: 5 - name: "Set up Ruby ${{ matrix.ruby_version }}" - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby_version }} - - name: Cache dependencies - uses: actions/cache@v1 - with: - path: vendor/bundle - key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: | - ${{ runner.os }}-gems- - - name: 'Update Rubygems and Bundler' - run: | - gem update --system --no-document - gem update bundler --no-document - - name: Set up bundle - run: | - bundle config path vendor/bundle - bundle install --jobs 4 --retry 3 + bundler-cache: true - name: Build Docs site with --profile run: bash script/profile-docs - name: Profile memory usage of building Docs site diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000000..d181e6d0a6d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Release Gem + +on: + push: + branches: + - master + - "*-stable" + paths: + - "lib/**/version.rb" + +jobs: + release: + if: "github.repository_owner == 'jekyll'" + name: "Release Gem (Ruby ${{ matrix.ruby_version }})" + runs-on: "ubuntu-latest" + strategy: + fail-fast: true + matrix: + ruby_version: + - 2.7 + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + - name: "Set up Ruby ${{ matrix.ruby_version }}" + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby_version }} + bundler-cache: true + - name: Build and Publish Gem + uses: ashmaroli/release-gem@dist + with: + gemspec_name: jekyll + env: + GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_GEM_PUSH_API_KEY }} diff --git a/.github/workflows/third-party.yml b/.github/workflows/third-party.yml index 37cba590f8f..9e97fbe4d01 100644 --- a/.github/workflows/third-party.yml +++ b/.github/workflows/third-party.yml @@ -3,14 +3,20 @@ name: Third-Party Repository Profiling on: push: branches: - - master + - 4.2-stable pull_request: branches: - - master + - 4.2-stable jobs: build_n_profile: if: "!contains(github.event.commits[0].message, '[ci skip]')" runs-on: 'ubuntu-latest' + env: + BUNDLE_GEMFILE: "sandbox/Gemfile" + BUNDLE_PATH: "vendor/bundle" + BUNDLE_JOBS: 4 + BUNDLE_RETRY: 3 + CI: true steps: - name: Checkout Jekyll uses: actions/checkout@v2 @@ -23,23 +29,10 @@ jobs: repository: ashmaroli/tomjoht.github.io path: sandbox - name: Set up Ruby - uses: actions/setup-ruby@v1 + uses: ruby/setup-ruby@v1 with: ruby-version: 2.7 - - name: Set up Dependencies Cache - uses: actions/cache@v1 - with: - path: sandbox/vendor/bundle - key: ubuntu-latest-gems-${{ hashFiles('**/Gemfile.lock') }} - restore-keys: | - ubuntu-latest-gems- - - name: Set up Dependencies - run: | - gem update --system --no-document - gem update bundler --no-document - bundle config gemfile sandbox/Gemfile - bundle config path vendor/bundle - bundle install --jobs 4 --retry 3 + bundler-cache: true - name: Run Jekyll Build 3 times run: | bundle exec jekyll build -s sandbox -d sandbox/_site --trace diff --git a/.rubocop.yml b/.rubocop.yml index bdd4b4240f6..5aa079bd359 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,6 +10,7 @@ Jekyll/NoPutsAllowed: - rake/*.rake AllCops: + SuggestExtensions: false TargetRubyVersion: 2.4 Include: - lib/**/*.rb @@ -303,6 +304,8 @@ Style/RedundantArgument: Enabled: true Style/RedundantAssignment: Enabled: true +Style/RedundantBegin: + Enabled: false Style/RedundantFetchBlock: Enabled: false Style/RedundantFileExtensionInRequire: diff --git a/Gemfile b/Gemfile index f386003620e..384a575b4e7 100644 --- a/Gemfile +++ b/Gemfile @@ -23,14 +23,17 @@ group :test do gem "nokogiri", "~> 1.7" gem "rspec" gem "rspec-mocks" - gem "rubocop", "~> 1.0" - gem "rubocop-performance" + gem "rubocop", "~> 1.12.0" + gem "rubocop-performance", "~> 1.11.0" gem "test-dependency-theme", :path => File.expand_path("test/fixtures/test-dependency-theme", __dir__) gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__) gem "test-theme-skinny", :path => File.expand_path("test/fixtures/test-theme-skinny", __dir__) gem "test-theme-symlink", :path => File.expand_path("test/fixtures/test-theme-symlink", __dir__) - gem "jruby-openssl" if RUBY_ENGINE == "jruby" + if RUBY_ENGINE == "jruby" + gem "http_parser.rb", "~> 0.6.0" + gem "jruby-openssl" + end end # diff --git a/History.markdown b/History.markdown index 6f5f70e1e6f..b13cfcf0343 100644 --- a/History.markdown +++ b/History.markdown @@ -1,3 +1,22 @@ +## 4.2.2 / 2022-03-03 + +### Bug Fixes + + * Lock `http_parser.rb` gem to `v0.6.x` on JRuby. + +### Development Fixes + + * Backport #8830 for v4.2.x: Add a workflow to build gems consistently (#8869) + * Lock `rubocop-performance` to `v1.11.x`. + +## 4.2.1 / 2021-09-27 + +### Bug Fixes + + * Backport #8620 for v4.2.x: Revert #7253: "Don't reset site.url to localhost:4000 by default" (#8808) + * Backport #8756 for v4.2.x: Respect collections_dir config within include tag (#8794) + * Backport #8786 for v4.2.x: Fix regression in Convertible module from v4.2.0 (#8793) + ## 4.2.0 / 2020-12-14 ### Minor Enhancements diff --git a/docs/_docs/step-by-step/01-setup.md b/docs/_docs/step-by-step/01-setup.md index adfabac5ba1..b53b8cb4300 100644 --- a/docs/_docs/step-by-step/01-setup.md +++ b/docs/_docs/step-by-step/01-setup.md @@ -79,8 +79,16 @@ called `_site`. * `jekyll serve` - Does the same thing except it rebuilds any time you make a change and runs a local web server at `http://localhost:4000`. -When you're developing a site you'll use `jekyll serve` as it updates with any -changes you make. +{: .note .info} +When you're developing a site, use `jekyll serve`. To force the browser to refresh with every change, use `jekyll serve --livereload`. +If there's a conflict or you'd like Jekyll to serve your development site at a different URL, use the `--host` and `--port` arguments, +as described in the [serve command options]({{ '/docs/configuration/options/#serve-command-options' | relative_url }}). + +{: .note .warning} +The version of the site that `jekyll serve` builds in `_site` is not suited for deployment. Links and asset URLs in sites created +with `jekyll serve` will use `https://localhost:4000` or the value set with command-line configuration, instead of the values set +in [your site's configuration file]({{ '/docs/configuration/' | relative_url }}). To learn about how to build your site when it's +ready for deployment, read the [Deployment]({{ '/docs/step-by-step/10-deployment/' | relative_url }}) section of this tutorial. Run `jekyll serve` and go to http://localhost:4000 in diff --git a/docs/_docs/step-by-step/10-deployment.md b/docs/_docs/step-by-step/10-deployment.md index df44d4513cb..8071b8a9840 100644 --- a/docs/_docs/step-by-step/10-deployment.md +++ b/docs/_docs/step-by-step/10-deployment.md @@ -143,7 +143,21 @@ to do this is to run a production build: JEKYLL_ENV=production bundle exec jekyll build ``` -And copy the contents of `_site` to your server. +And then copy the contents of `_site` to your server. + +
+
Destination folders are cleaned on site builds
+

+ The contents of _site are automatically cleaned, by default, when + the site is built. Files or folders that are not created by your site's build + process will be removed. +

+

+ Some files could be retained by specifying them within the keep_files + configuration directive. Other files could be retained by keeping them in your + assets directory. +

+
A better way is to automate this process using a [CI](/docs/deployment/automated/) or [3rd party](/docs/deployment/third-party/). diff --git a/features/create_sites.feature b/features/create_sites.feature index fd63ff60be5..cd6e1b6c0c8 100644 --- a/features/create_sites.feature +++ b/features/create_sites.feature @@ -184,17 +184,17 @@ Feature: Create sites Given I have a _posts directory And I have the following post: | title | date | layout | content | - | entry1 | 2020-12-31 | post | content for entry1. | + | entry1 | 2040-12-31 | post | content for entry1. | | entry2 | 2007-12-31 | post | content for entry2. | When I run jekyll build Then I should get a zero exit status And the _site directory should exist And I should see "content for entry2" in "_site/2007/12/31/entry2.html" - And the "_site/2020/12/31/entry1.html" file should not exist + And the "_site/2040/12/31/entry1.html" file should not exist When I run jekyll build --future Then I should get a zero exit status And the _site directory should exist - And the "_site/2020/12/31/entry1.html" file should exist + And the "_site/2040/12/31/entry1.html" file should exist Scenario: Basic site with layouts, posts and related posts Given I have a _layouts directory diff --git a/features/incremental_rebuild.feature b/features/incremental_rebuild.feature index 2ced57a6d81..2d22d2e1940 100644 --- a/features/incremental_rebuild.feature +++ b/features/incremental_rebuild.feature @@ -67,6 +67,25 @@ Feature: Incremental rebuild And the _site directory should exist And I should see "Basic Site with include tag: Regenerated by Jekyll" in "_site/index.html" + Scenario: Rebuild when a dependency of document in custom collection_dir is changed + Given I have a _includes directory + And I have a configuration file with "collections_dir" set to "collections" + And I have a collections/_posts directory + And I have the following post within the "collections" directory: + | title | date | layout | content | + | Wargames | 2009-03-27 | default | Basic Site with include tag: {% include about.html %} | + And I have an "_includes/about.html" file that contains "Generated by Jekyll" + When I run jekyll build -I + Then I should get a zero exit status + And the _site directory should exist + And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/2009/03/27/wargames.html" + When I wait 1 second + Then I have an "_includes/about.html" file that contains "Regenerated by Jekyll" + When I run jekyll build -I + Then I should get a zero exit status + And the _site directory should exist + And I should see "Basic Site with include tag: Regenerated by Jekyll" in "_site/2009/03/27/wargames.html" + Scenario: A themed-site and incremental regeneration Given I have a configuration file with "theme" set to "test-theme" And I have an "index.md" page that contains "Themed site" diff --git a/features/post_excerpts.feature b/features/post_excerpts.feature index 9a76b9b9517..1df1b541a69 100644 --- a/features/post_excerpts.feature +++ b/features/post_excerpts.feature @@ -108,7 +108,7 @@ Feature: Post excerpts Then I should get a zero exit status And I should not see "Kramdown warning" in the build output But I should see exactly "

Install Jekyll

" in "_site/just-text-excerpt.html" - And I should see "

Alpha 1

" in "_site/text-and-footnote.html" + And I should see "

Alpha 1

" in "_site/text-and-footnote.html" And I should see "

Omega sigma 

" in "_site/text-and-footnote.html" And I should see "

Read docs

" in "_site/text-and-reference-link.html" And I should see "

Check out jekyll

" in "_site/text-and-self-refencing-link.html" diff --git a/features/rendering.feature b/features/rendering.feature index e13fe17f5a7..4639e3b0968 100644 --- a/features/rendering.feature +++ b/features/rendering.feature @@ -207,3 +207,35 @@ Feature: Rendering And I should see "series named {{ site.title }}" in "_site/index.html" And I should see "{% link series/first-part.md %}" in "_site/index.html" And I should see "{% link series/last-part.md %}" in "_site/index.html" + + Scenario: Render content of another page + Given I have an "index.md" page that contains "__Hello World__" + And I have an "about.md" page that contains "{{ page.name }}" + And I have a "test.json" file with content: + """ + --- + --- + + { + "hpages": [ + {%- for page in site.html_pages %} + { + "url" : {{ page.url | jsonify }}, + "name" : {{ page.name | jsonify }}, + "path" : {{ page.path | jsonify }}, + "title" : {{ page.title | jsonify }}, + "layout" : {{ page.layout | jsonify }}, + "content": {{ page.content | jsonify }}, + "excerpt": {{ page.excerpt | jsonify }} + }{% unless forloop.last %},{% endunless -%} + {% endfor %} + ] + } + """ + When I run jekyll build + Then I should get a zero exit status + And the _site directory should exist + But I should not see "content\": \"{{ page.name }}" in "_site/test.json" + And I should not see "content\": \"__Hello World__" in "_site/test.json" + But I should see "content\": \"

about.md

" in "_site/test.json" + And I should see "content\": \"

Hello World

" in "_site/test.json" diff --git a/lib/jekyll/commands/new.rb b/lib/jekyll/commands/new.rb index 4623ddafba4..150b4aa7360 100644 --- a/lib/jekyll/commands/new.rb +++ b/lib/jekyll/commands/new.rb @@ -99,6 +99,9 @@ def gemfile_contents # Performance-booster for watching directories on Windows gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin] + # Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem + # do not have a Java counterpart. + gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby] RUBY end diff --git a/lib/jekyll/commands/serve.rb b/lib/jekyll/commands/serve.rb index c3d0621aec5..7357b9398bf 100644 --- a/lib/jekyll/commands/serve.rb +++ b/lib/jekyll/commands/serve.rb @@ -249,9 +249,6 @@ def format_url(ssl_enabled, address, port, baseurl = nil) def default_url(opts) config = configuration_from_options(opts) - auth = config.values_at("host", "port").join(":") - return config["url"] if auth == "127.0.0.1:4000" - format_url( config["ssl_cert"] && config["ssl_key"], config["host"] == "127.0.0.1" ? "localhost" : config["host"], diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index 905afe573ff..b9f7a93fbd7 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -112,7 +112,11 @@ def render_liquid(content, payload, info, path) # # Returns the Hash representation of this Convertible. def to_liquid(attrs = nil) - further_data = attribute_hash(attrs || self.class::ATTRIBUTES_FOR_LIQUID) + further_data = \ + (attrs || self.class::ATTRIBUTES_FOR_LIQUID).each_with_object({}) do |attribute, hsh| + hsh[attribute] = send(attribute) + end + Utils.deep_merge_hashes defaults, Utils.deep_merge_hashes(data, further_data) end @@ -246,13 +250,6 @@ def defaults @defaults ||= site.frontmatter_defaults.all(relative_path, type) end - def attribute_hash(attrs) - @attribute_hash ||= {} - @attribute_hash[attrs] ||= attrs.each_with_object({}) do |attribute, hsh| - hsh[attribute] = send(attribute) - end - end - def no_layout? data["layout"] == "none" end diff --git a/lib/jekyll/tags/include.rb b/lib/jekyll/tags/include.rb index 1c3b86fe3f4..cda2ef4e8c6 100644 --- a/lib/jekyll/tags/include.rb +++ b/lib/jekyll/tags/include.rb @@ -234,12 +234,17 @@ def realpath_prefixed_with?(path, dir) end def add_include_to_dependency(inclusion, context) - return unless context.registers[:page]&.key?("path") + page = context.registers[:page] + return unless page&.key?("path") + + absolute_path = \ + if page["collection"] + @site.in_source_dir(@site.config["collections_dir"], page["path"]) + else + @site.in_source_dir(page["path"]) + end - @site.regenerator.add_dependency( - @site.in_source_dir(context.registers[:page]["path"]), - inclusion.path - ) + @site.regenerator.add_dependency(absolute_path, inclusion.path) end end diff --git a/lib/jekyll/version.rb b/lib/jekyll/version.rb index 1b23b987f93..5a1c19d2d26 100644 --- a/lib/jekyll/version.rb +++ b/lib/jekyll/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Jekyll - VERSION = "4.2.0" + VERSION = "4.2.2" end diff --git a/test/test_commands_serve.rb b/test/test_commands_serve.rb index d9286a93b67..455eb703673 100644 --- a/test/test_commands_serve.rb +++ b/test/test_commands_serve.rb @@ -232,6 +232,12 @@ def serve(opts) expect(Jekyll).to receive(:env).and_return("development") expect(Jekyll::Commands::Serve).to receive(:start_up_webrick) end + should "set the site url by default to `http://localhost:4000`" do + @merc.execute(:serve, "watch" => false, "url" => "https://jekyllrb.com/") + + assert_equal 1, Jekyll.sites.count + assert_equal "http://localhost:4000", Jekyll.sites.first.config["url"] + end should "take `host`, `port` and `ssl` into consideration if set" do @merc.execute(:serve,