Skip to content

Commit 5df3420

Browse files
authored
added lychee config and workflow, fixes #718, fixes #722 (#721)
* added lychee config and workflow fixed xtask exit code * Update lychee.toml * fixed workflow run only on pr * fixed workflow invalid msg * fixed workflow exit * fixed fmt issues * added github token * updated xtask lychee to use config file fixed link error in intro (about.md) * workflow update use lychee cache * fixed wrong output and cache * fix link checker * fixed cache save and creation * invalid syntax fix * Fix #722 (Broken Links) - CONTRIBUTING.md (removed link as its not required and no longer available) - src/encoding/string/url-encode.md (updated form_urlencoded is not a part of url its re-exported) - README.md (removed travis CI link [404](https://www.travis-ci.com/rust-lang-nursery/rust-cookbook)) - src/development_tools/debugging/config_log/log-custom.md (log4rs::config::Config is a re-export from log4rs::config::runtime::Config) - src/web/scraping/broken.md (tokio::spawn to tokio::task::spawn) - src/web/clients/api/rate-limited.md (removed file rust src broken links broken and is not used or displayed on the current cookbook build) - src/cryptography/hashing/hmac.md (updated description, added tag type hint, and updated links) * added mdbook workflow * fixed branch name * added test report using workflow by https://github.com/innoq/action-cargo-test-report * fixed missing version * fixed workflow rust setup * removed caro2junit use nightly features instead * simplify workflow * fixed wrong summary * maybe fixed now? * exclude main.rs test * fixed broken link * Aktualisieren von check-links.yml * Aktualisieren von README.md * Aktualisieren von check-links.yml * Aktualisieren von about.md * Aktualisieren von check-links.yml * Aktualisieren von check-links.yml * Aktualisieren von check-links.yml
1 parent cf23fcd commit 5df3420

File tree

15 files changed

+185
-94
lines changed

15 files changed

+185
-94
lines changed

.github/workflows/check-links.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Links
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches:
7+
- master
8+
9+
jobs:
10+
linkChecker:
11+
runs-on: ubuntu-latest
12+
env:
13+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
CACHE_KEY: cache-lychee-${{ github.sha }}
15+
permissions:
16+
pull-requests: write
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Link Checker
21+
id: lychee
22+
uses: lycheeverse/[email protected]
23+
with:
24+
fail: false
25+
checkbox: false
26+
output: ./lychee/out.md
27+
args: "--mode task --base . --config ./ci/lychee.toml ."
28+
29+
- name: Save lychee cache
30+
uses: actions/cache/save@v4
31+
if: always()
32+
with:
33+
path: .lycheecache
34+
key: ${{ steps.restore-cache.outputs.cache-primary-key || env.CACHE_KEY }} # fallback in case the cache wasn't created yet
35+
36+
- name: Post Comment on Pull Request
37+
if: github.event_name == 'pull_request' && steps.lychee.outputs.exit_code != 0
38+
run: |
39+
echo "The link checker found some issues. Please review the report below:" > comment.md
40+
echo "" >> comment.md
41+
cat ./lychee/out.md >> comment.md
42+
gh pr comment ${{ github.event.pull_request.number }} --body-file comment.md
43+
44+
- name: Fail Workflow
45+
if: github.event_name == 'pull_request' && steps.lychee.outputs.exit_code != 0
46+
run: exit 1
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build and Deploy mdBook
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-deploy:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up cache for mdbook
18+
id: cache-mdbook
19+
uses: actions/cache@v3
20+
with:
21+
path: |
22+
~/.cargo/bin/mdbook
23+
key: mdbook-v0.4.43
24+
25+
- name: Install mdBook (if not cached)
26+
if: steps.cache-mdbook.outputs.cache-hit != 'true'
27+
run: |
28+
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.43/mdbook-v0.4.43-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin
29+
chmod +x ~/.cargo/bin/mdbook
30+
31+
- name: Build mdBook
32+
run: |
33+
mdbook build
34+
35+
- name: Deploy to GitHub Pages
36+
uses: peaceiris/actions-gh-pages@v4
37+
with:
38+
github_token: ${{ secrets.GITHUB_TOKEN }}
39+
publish_dir: ./book

.github/workflows/mdbook-test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Test Rust Project
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Rust
17+
uses: actions-rust-lang/setup-rust-toolchain@v1
18+
with:
19+
cache: 'true'
20+
toolchain: nightly
21+
22+
- name: Run tests
23+
id: cargo_test
24+
run: |
25+
cargo +nightly test --test skeptic -- -Z unstable-options --format junit --report-time --test-threads=1 | tee ./TEST-cookbook.xml
26+
27+
- name: List files for debugging
28+
if: always()
29+
run: ls -R
30+
31+
- name: Publish Test Report
32+
uses: mikepenz/[email protected]
33+
if: always()
34+
with:
35+
fail_on_failure: true
36+
require_tests: true
37+
summary: ${{ steps.cargo_test.outputs.summary }}
38+
report_paths: '**/TEST-*.xml'

CONTRIBUTING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,11 @@ after the code sample.
257257
> generator [`rand::Rng`].
258258
>
259259
> The [distributions available are documented here][rand-distributions].
260-
> An example using the [`Normal`] distribution is shown below.
261260
262261
[uniform distribution]: https://en.wikipedia.org/wiki/Uniform_distribution_(continuous)
263262
[`Distribution::sample`]: https://docs.rs/rand/*/rand/distributions/trait.Distribution.html#tymethod.sample
264263
[`rand::Rng`]: https://docs.rs/rand/*/rand/trait.Rng.html
265264
[rand-distributions]: https://docs.rs/rand/*/rand/distributions/index.html
266-
[`Normal`]: https://docs.rs/rand/*/rand/distributions/struct.Normal.html
267265

268266
#### Code
269267

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# A Rust Cookbook   [![Build Status travis]][travis]
22

33
[Build Status travis]: https://api.travis-ci.com/rust-lang-nursery/rust-cookbook.svg?branch=master
4-
[travis]: https://travis-ci.com/rust-lang-nursery/rust-cookbook
4+
5+
https://invalid.cc
56

67
**[Read it here]**.
78

ci/dictionary.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,4 +348,4 @@ YYYY
348348
zurich
349349
enum
350350
thiserror
351-
tempfile
351+
tempfile

ci/lychee.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Don't show interactive progress bar while checking links.
2+
no_progress = true
3+
4+
# Enable link caching. This can be helpful to avoid checking the same links on
5+
# multiple runs.
6+
cache = true
7+
8+
# Discard all cached requests older than this duration.
9+
max_cache_age = "2d"
10+
11+
user_agent = "curl/7.83. 1"
12+
13+
# Website timeout from connect to response finished.
14+
timeout = 20
15+
16+
# Minimum wait time in seconds between retries of failed requests.
17+
retry_wait_time = 20
18+
19+
# Comma-separated list of accepted status codes for valid links.
20+
accept = ["200", "429"] # 429 for ratelimits
21+
22+
# Request method
23+
method = "get"
24+
25+
# Custom request headers
26+
headers = []
27+
28+
# Exclude loopback IP address range and localhost from checking.
29+
exclude_loopback = false
30+
31+
# Check mail addresses
32+
include_mail = true

src/about.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ as are crates that are pending evaluation.
129129
{{#include links.md}}
130130

131131
[index]: intro.html
132-
[error-docs]: https://doc.rust-lang.org/book/error-handling.html
132+
[error-docs]: https://do.rust-lang.org/book/error-handling.html
133133
[error-blog]: https://brson.github.io/2016/11/30/starting-with-error-chain
134134
[error-chain]: https://docs.rs/error-chain/
135135
[Rust Libz Blitz]: https://internals.rust-lang.org/t/rust-libz-blitz/5184

src/cryptography/hashing/hmac.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
[![ring-badge]][ring] [![cat-cryptography-badge]][cat-cryptography]
44

5-
Uses [`ring::hmac`] to creates a [`hmac::Signature`] of a string then verifies the signature is correct.
6-
5+
The [`hmac::sign`] method is used to calculate the HMAC digest (also called a tag) of the message using the provided key.
6+
The resulting [`hmac::Tag`] structure contains the raw bytes of the HMAC,
7+
which can later be verified with[`hmac::verify`] to ensure the message has not been tampered with and comes from a trusted source.
78

89
```rust,edition2018
910
use ring::{hmac, rand};
@@ -17,12 +18,17 @@ fn main() -> Result<(), Unspecified> {
1718
let key = hmac::Key::new(hmac::HMAC_SHA256, &key_value);
1819
1920
let message = "Legitimate and important message.";
20-
let signature = hmac::sign(&key, message.as_bytes());
21+
let signature: hmac::Tag = hmac::sign(&key, message.as_bytes());
2122
hmac::verify(&key, message.as_bytes(), signature.as_ref())?;
2223
2324
Ok(())
2425
}
2526
```
2627

27-
[`hmac::Signature`]: https://briansmith.org/rustdoc/ring/hmac/struct.Signature.html
28-
[`ring::hmac`]: https://briansmith.org/rustdoc/ring/hmac/
28+
[`ring::hmac`]: https://docs.rs/ring/*/ring/hmac/index.html
29+
30+
[`hmac::sign`]: https://docs.rs/ring/*/ring/hmac/fn.sign.html
31+
32+
[`hmac::Tag`]: https://docs.rs/ring/*/ring/hmac/struct.Tag.html
33+
34+
[`hmac::verify`]: https://docs.rs/ring/*/ring/hmac/fn.verify.html

src/development_tools/debugging/config_log/log-custom.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ fn main() -> Result<()> {
4747
```
4848

4949
[`log4rs::append::file::FileAppender`]: https://docs.rs/log4rs/*/log4rs/append/file/struct.FileAppender.html
50-
[`log4rs::config::Config`]: https://docs.rs/log4rs/*/log4rs/config/struct.Config.html
50+
[`log4rs::config::Config`]: https://docs.rs/log4rs/*/log4rs/config/runtime/struct.Config.html
5151
[`log4rs::encode::pattern`]: https://docs.rs/log4rs/*/log4rs/encode/pattern/index.html
5252
[`log::LevelFilter`]: https://docs.rs/log/*/log/enum.LevelFilter.html

0 commit comments

Comments
 (0)