lychee/.github/workflows/rust.yml
Matthias 251332efe2
Cache absolute_path to decrease allocations (#346)
* Cache `absolute_path` to decrease allocations

While profiling local file handling, I noticed that resolving paths was taking a
significant amount of time. It also caused quite a few allocations.
By caching the path and using a constant value for the current
directory, we can reduce the number of allocs by quite a lot.
For example, when testing on the sentry documentation, we do 50,4%
less allocations in total now. That's just a single test-case of course,
but it's probably also helping in many other cases as well.

* Defer to_string for attr.value to reduce allocs
* Use Tendrils instead of Strings for parsing (another ~1.5% less allocs)
* Move option parsing code into separate module
* Handle base dir more correctly
* Temporarily disable dry run
2021-10-05 01:37:43 +02:00

85 lines
2.1 KiB
YAML

on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: clippy
- 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 -- --deny warnings
publish-check:
name: publish check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: cargo fetch
uses: actions-rs/cargo@v1
with:
command: fetch
- uses: actions-rs/install@v0.1
with:
crate: cargo-publish-all
version: latest
# This currently doesn't work.
# TODO: Re-enable once https://gitlab.com/torkleyy/cargo-publish-all/-/issues/3
# is resolved.
# See also https://github.com/lycheeverse/lychee/pull/346#issuecomment-928355735
#- run: cargo-publish-all --dry-run
publish:
if: ${{ startsWith(github.ref, 'refs/tags/') }}
needs:
- test
- lint
- publish-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: cargo fetch
uses: actions-rs/cargo@v1
with:
command: fetch
- uses: actions-rs/install@v0.1
with:
crate: cargo-publish-all
version: latest
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- run: cargo-publish-all