Skip to content

Commit

Permalink
Merge pull request #2273 from sparklemotion/2204-nokogumbo-test-suite
Browse files Browse the repository at this point in the history
ci: nokogumbo test suite

---

**What problem is this PR intended to solve?**

Merge the remaining Nokogumbo tests into Nokogiri's test suite.

- [x] submodule @stevecheckoway's fork of html5lib-tests (see see rubys/nokogumbo#170 (comment))
- [x] make sure these tests only run under CRuby
- [x] gumbo tests

**Have you included adequate test coverage?**

Tests are the entire substance of this PR.


**Does this change affect the behavior of either the C or the Java implementations?**

Notably, these additional tests should only run under CRuby.
  • Loading branch information
flavorjones committed Jun 19, 2021
2 parents 855f7c0 + a40cbb0 commit 2516b5a
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 39 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,36 @@ jobs:
image: flavorjones/nokogiri-test:mri-3.0
steps:
- uses: actions/checkout@v2
with:
submodules: true
- run: bundle install --local || bundle install
- run: bundle exec rake rubocop

gumbo:
needs: ["rubocop"]
strategy:
fail-fast: false
matrix:
plat: ["ubuntu", "windows", "macos"]
runs-on: ${{matrix.plat}}-latest
steps:
- name: configure git crlf
if: matrix.plat == 'windows'
run: |
git config --system core.autocrlf false
git config --system core.eol lf
- uses: actions/checkout@v2
with:
submodules: true
- uses: MSP-Greg/setup-ruby-pkgs@v1
with:
ruby-version: "3.0"
apt-get: "ragel"
brew: "ragel"
mingw: "ragel"
bundler-cache: true
- run: bundle exec rake gumbo:test

basic:
needs: ["rubocop"]
strategy:
Expand All @@ -37,6 +64,8 @@ jobs:
image: flavorjones/nokogiri-test:${{matrix.image}}
steps:
- uses: actions/checkout@v1 # v1 because of https://github.com/actions/checkout/issues/334
with:
submodules: true
- run: bundle install --local || bundle install
- run: bundle exec rake compile -- --${{matrix.sys}}-system-libraries
- run: bundle exec rake test
Expand All @@ -53,6 +82,8 @@ jobs:
image: flavorjones/nokogiri-test:mri-${{matrix.ruby}}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/cache@v2
if: matrix.sys == 'disable'
with:
Expand All @@ -74,6 +105,8 @@ jobs:
image: flavorjones/nokogiri-test:mri-${{matrix.ruby}}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/cache@v2
if: matrix.sys == 'disable'
with:
Expand All @@ -94,6 +127,8 @@ jobs:
image: flavorjones/nokogiri-test:alpine
steps:
- uses: actions/checkout@v1 # v1 because of https://github.com/actions/checkout/issues/334
with:
submodules: true
# skip cache because of https://github.com/actions/checkout/issues/334
- run: bundle install --local || bundle install
- run: bundle exec rake compile -- --${{matrix.sys}}-system-libraries
Expand All @@ -110,6 +145,8 @@ jobs:
image: flavorjones/nokogiri-test:alpine
steps:
- uses: actions/checkout@v1 # v1 because of https://github.com/actions/checkout/issues/334
with:
submodules: true
# skip cache because of https://github.com/actions/checkout/issues/334
- run: bundle install --local || bundle install
- run: bundle exec rake compile -- --${{matrix.sys}}-system-libraries
Expand All @@ -129,6 +166,8 @@ jobs:
image: flavorjones/nokogiri-test:mri-${{matrix.ruby}}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/cache@v2
if: matrix.sys == 'disable'
with:
Expand All @@ -152,6 +191,8 @@ jobs:
image: flavorjones/nokogiri-test:mri-${{matrix.ruby}}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/cache@v2
if: matrix.sys == 'disable'
with:
Expand All @@ -171,6 +212,8 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{matrix.ruby}}
Expand All @@ -197,6 +240,8 @@ jobs:
git config --system core.autocrlf false
git config --system core.eol lf
- uses: actions/checkout@v2
with:
submodules: true
- uses: MSP-Greg/setup-ruby-pkgs@v1
with:
ruby-version: "${{matrix.ruby}}"
Expand All @@ -219,6 +264,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{matrix.ruby}}
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/gem-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
image: "larskanis/rake-compiler-dock-mri-x86_64-linux:1.1.0"
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/cache@v2
with:
path: ports/archives
Expand All @@ -44,6 +46,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: MSP-Greg/setup-ruby-pkgs@v1
with:
ruby-version: "${{matrix.ruby}}"
Expand All @@ -63,6 +67,8 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.0"
Expand All @@ -81,6 +87,8 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: MSP-Greg/setup-ruby-pkgs@v1
with:
ruby-version: "3.0"
Expand All @@ -106,6 +114,8 @@ jobs:
image: "larskanis/rake-compiler-dock-mri-${{matrix.plat}}:1.1.0"
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/cache@v2
with:
path: ports/archives
Expand All @@ -126,6 +136,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{matrix.ruby}}"
Expand All @@ -144,6 +156,8 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{matrix.ruby}}"
Expand Down Expand Up @@ -181,6 +195,8 @@ jobs:
image: "larskanis/rake-compiler-dock-jruby:1.1.0"
steps:
- uses: actions/checkout@v2
with:
submodules: true
- run: ./scripts/test-gem-build gems java
- uses: actions/upload-artifact@v2
with:
Expand All @@ -197,6 +213,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{matrix.ruby}}"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/truffle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
image: flavorjones/nokogiri-test:truffle-nightly
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/cache@v2
with:
path: ports/archives
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
image: flavorjones/nokogiri-test:mri-3.0
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Setup libxml2
run: |
git clone --depth=1 https://gitlab.gnome.org/GNOME/libxml2
Expand All @@ -47,6 +49,8 @@ jobs:
image: flavorjones/nokogiri-test:mri-3.0
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Setup libxml2
run: |
git clone --depth=1 https://gitlab.gnome.org/GNOME/libxml2
Expand Down Expand Up @@ -77,6 +81,8 @@ jobs:
git config --system core.autocrlf false
git config --system core.eol lf
- uses: actions/checkout@v2
with:
submodules: true
- uses: MSP-Greg/setup-ruby-pkgs@ucrt
with:
ruby-version: "head"
Expand All @@ -101,6 +107,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: MSP-Greg/setup-ruby-pkgs@v1
with:
ruby-version: "head"
Expand All @@ -118,6 +126,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: ruby/setup-ruby@v1
with:
ruby-version: "jruby-head"
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "test/html5lib-tests"]
path = test/html5lib-tests
url = https://github.com/stevecheckoway/html5lib-tests.git
branch = all-error-fixes
23 changes: 23 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,21 @@ If you want to build Nokogiri against a modified version of libxml2, clone libxm
That script also takes an optional command to run with the proper environment variables set to use the local libxml2 library, which can be useful when trying to `git bisect` against libxml2.


### gumbo HTML5 parser

To run the test suite for the gumbo parser:

``` sh
bundle exec rake gumbo
```

To make sure to run additional html5lib tests for Nokogiri's HTML5 parser:

``` sh
git submodule update --init # test/html5lib-tests
bundle exec rake compile test
```


## Style Guide

Expand Down Expand Up @@ -182,6 +197,7 @@ The `ci.yml` pipeline includes jobs to:

- basic security sanity check: run rubocop
- fast feedback for obvious failures: run against system libraries on vanilla ubuntu
- run the gumbo parser tests on ubuntu, macos, and windows
- run on all supported versions of CRuby:
- once with packaged libraries
- once with system libraries
Expand Down Expand Up @@ -217,6 +233,13 @@ The `truffle.yml` pipeline tests TruffleRuby nightlies with a few different comp
We rely heavily on Valgrind to catch memory bugs by running in combination with every version of CRuby. We use suppressions, too -- because some Rubies seem to have memory issues? See the files in the `/suppressions` directory and `/rakelib/test.rake` for more information.


### Conventions

- Always checkout the source code including submodules (for the html5lib tests)
- When testing packaged libraries (not system libraries), cache either `ports/` (for compiled libraries) or `ports/archives/` (for just tarballs)
- note that `libgumbo` is built outside of `ports/` to allow us to do this caching safely


## Building gems

As a prerequisite please make sure you have `docker` correctly installed.
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
require "bundler"
NOKOGIRI_SPEC = Bundler.load_gemspec("nokogiri.gemspec")

task default: [:rubocop, :compile, :test]
task default: [:rubocop, :gumbo, :compile, :test]
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ install:
- ruby --version
- gem --version
- gem install bundler --conservative
- git submodule update --init
- bundle config --local path vendor/bundle
- bundle install
- IF DEFINED INSTALL_PACKAGES ( ridk exec pacman --noconfirm --needed --sync %INSTALL_PACKAGES% )
Expand Down
1 change: 1 addition & 0 deletions gumbo-parser/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
googletest
src/*.o
38 changes: 0 additions & 38 deletions nokogumbo-import/appveyor.yml

This file was deleted.

1 change: 1 addition & 0 deletions rakelib/check-manifest.rake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ task :check_manifest do
.cross_rubies
.editorconfig
.gitignore
.gitmodules
.yardopts
CHANGELOG.md
CODE_OF_CONDUCT.md
Expand Down
Loading

0 comments on commit 2516b5a

Please sign in to comment.