lychee/.github/workflows/ci.yml
Matthias Endler 55797071b0
Fix nested URL extraction in verbatim elements (#988)
Skipping URLs in verbatim elements didn't take nested
elements into consideration, which were not verbatim.

For instance, the following HTML snippet would yield
`https://example.com` in non-verbatim mode, even if
it is nested inside a verbatim `<pre>` element:

```html
<pre><a href="https://example.com">link</a></pre>
```

This commit fixes the behavior for both `html5gum` and
`html5ever`.

Note that nested verbatim elements of the same kind
still are not handled correctly.

For instance,  the following HTML snippet would still yield
`https://example.com`:

```html
<pre>
  <pre></pre>
  <a href="https://example.com">link</a>
</pre>
```

The reason is that we currently only keep track of a single
verbatim element and not a stack of elements, which we
would need to unwind and resolve the situation.

Fixes https://github.com/lycheeverse/lychee/issues/986.
2023-03-11 15:18:25 +01:00

114 lines
3.1 KiB
YAML

name: CI
on:
repository_dispatch:
workflow_dispatch:
push:
branches:
- master
tags:
- "*.*.*"
pull_request:
types:
- opened
- synchronize
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
- name: Run tests
run: make test
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Run cargo fmt (check if all code is rustfmt-ed)
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Run cargo clippy (deny warnings)
uses: actions-rs/cargo@v1
with:
command: clippy
# --all-targets makes it lint tests too
args: --all-targets --all-features -- -D warnings
publish-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: cargo fetch
uses: actions-rs/cargo@v1
with:
command: fetch
- name: cargo publish lychee-lib
uses: actions-rs/cargo@v1
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
with:
command: publish
args: --dry-run --manifest-path lychee-lib/Cargo.toml
# Can't check lychee binary as it depends on the lib above
# and `--dry-run` doesn't allow unpublished crates yet.
# https://github.com/rust-lang/cargo/issues/1169
# `cargo-publish-all` is a solution but it doesn't work with
# Rust edition 2021.
# Therefore skip the check for now, which is probably fine
# because the binary is just a small wrapper around the CLI
# anyway.
#
# - name: cargo publish lychee
# uses: actions-rs/cargo@v1
# env:
# CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# with:
# command: publish
# args: --dry-run --manifest-path lychee-bin/Cargo.toml
publish:
if: startsWith(github.ref, 'refs/tags/')
needs:
- test
- lint
- publish-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: cargo fetch
uses: actions-rs/cargo@v1
with:
command: fetch
- name: cargo publish lychee-lib
uses: actions-rs/cargo@v1
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
with:
command: publish
args: --manifest-path lychee-lib/Cargo.toml
- name: Wait for crates.io publication
run: sleep 60s
shell: bash
- name: cargo publish lychee
uses: actions-rs/cargo@v1
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
with:
command: publish
args: --manifest-path lychee-bin/Cargo.toml