Skip to content

Commit

Permalink
Merge branch 'master' into nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
mre authored Apr 25, 2024
2 parents f487471 + 2b973e8 commit 1a931e2
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ahmadnassri/[email protected]
with:
github-token: ${{ secrets.AUTOMERGE_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
linkChecker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Link Checker
uses: ./ # Uses an action in the root directory
Expand All @@ -22,7 +22,7 @@ jobs:

- name: Create Issue From File
if: env.lychee_exit_code != 0
uses: peter-evans/create-issue-from-file@v4
uses: peter-evans/create-issue-from-file@v5
with:
title: Link Checker Report
content-filepath: ./lychee/out.md
Expand Down
71 changes: 70 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ on:
- push
- pull_request

env:
CUSTOM_OUTPUT_RELATIVE_PATH: lychee/custom_output.md
CUSTOM_OUTPUT_ABSOLUTE_PATH: /tmp/report.md
CUSTOM_OUTPUT_DUMP_PATH: /tmp/dump.md

jobs:
lychee-action:
runs-on: ubuntu-latest
continue-on-error: true
name: Test the lychee link checker action
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: test defaults
uses: ./
Expand All @@ -35,6 +40,70 @@ jobs:
'./**/*.rst'
fail: true

- name: test --base argument
uses: ./
with:
args: >-
--base .
--verbose
--no-progress
'./**/*.md'
'./**/*.html'
'./**/*.rst'
fail: true

- name: test custom output relative path - creation
uses: ./
with:
output: "${{ env.CUSTOM_OUTPUT_RELATIVE_PATH }}"
debug: true

- name: test custom output relative path - validation
run: |
echo "Checking custom output file at ${{ env.CUSTOM_OUTPUT_RELATIVE_PATH }}"
if [ ! -f "${{ env.CUSTOM_OUTPUT_RELATIVE_PATH }}" ]; then
echo "Not found"
exit 1
else
echo "Found. Contents:"
cat "${{ env.CUSTOM_OUTPUT_RELATIVE_PATH }}"
fi
- name: test custom output absolute path - creation
uses: ./
with:
output: "${{ env.CUSTOM_OUTPUT_ABSOLUTE_PATH }}"
debug: true

- name: test custom output absolute path - validation
run: |
echo "Checking custom output file at ${{ env.CUSTOM_OUTPUT_ABSOLUTE_PATH }}"
if [ ! -f "${{ env.CUSTOM_OUTPUT_ABSOLUTE_PATH }}" ]; then
echo "Not found"
exit 1
else
echo "Found. Contents:"
cat "${{ env.CUSTOM_OUTPUT_ABSOLUTE_PATH }}"
fi
- name: test dump with custom output path - creation
uses: ./
with:
args: --dump './**/*.md' './**/*.html' './**/*.rst'
output: "${{ env.CUSTOM_OUTPUT_DUMP_PATH }}"
debug: true

- name: test dump with custom output path - validation
run: |
echo "Checking dump output file at ${{ env.CUSTOM_OUTPUT_DUMP_PATH }}"
if [ ! -f "${{ env.CUSTOM_OUTPUT_DUMP_PATH }}" ]; then
echo "Not found"
exit 1
else
echo "Found. Contents:"
cat "${{ env.CUSTOM_OUTPUT_DUMP_PATH }}"
fi
- name: Install jq
run: sudo apt-get install jq

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
name: Test cache
steps:
- name: Restore lychee cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: .lycheecache
key: cache-lychee-${{ github.sha }}
restore-keys: cache-lychee-

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Lychee URL checker
uses: lycheeverse/lychee-action@v1
Expand Down
32 changes: 21 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ jobs:
linkChecker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v1.8.0
uses: lycheeverse/lychee-action@v1.9.0

- name: Create Issue From File
if: env.lychee_exit_code != 0
Expand Down Expand Up @@ -65,14 +65,24 @@ jobs:
linkChecker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Link Checker
uses: lycheeverse/lychee-action@v1.8.0
uses: lycheeverse/lychee-action@v1.9.0
with:
fail: true
```

You may want to add additional arguments to the above. In particular, if you're testing a site directly from the file system (as in the above), you'll likely want to set the argument `--base .` to ensure that **all links** (including root-relative paths) in the files are tested. You don't need to do this if you're testing a hosted site.

```yaml
- name: Link Checker
uses: lycheeverse/[email protected]
with:
fail: true
args: --base . --verbose --no-progress './**/*.md' './**/*.html' './**/*.rst'
```

## Passing arguments

This action uses [lychee] for link checking.
Expand All @@ -99,10 +109,10 @@ Here is how to pass the arguments.

```yml
- name: Link Checker
uses: lycheeverse/lychee-action@v1.8.0
uses: lycheeverse/lychee-action@v1.9.0
with:
# Check all markdown and html files in repo (default)
args: --verbose --no-progress './**/*.md' './**/*.html' './**/*.rst'
args: --base . --verbose --no-progress './**/*.md' './**/*.html' './**/*.rst'
# Use json as output format (instead of markdown)
format: json
# Use different output file path
Expand Down Expand Up @@ -131,9 +141,9 @@ In order to mitigate issues regarding rate limiting or to reduce stress on exter
restore-keys: cache-lychee-
- name: Run lychee
uses: lycheeverse/lychee-action@v1.8.0
uses: lycheeverse/lychee-action@v1.9.0
with:
args: "--cache --max-cache-age 1d ."
args: "--base . --cache --max-cache-age 1d ."
```

It will compare and save the cache based on the given key.
Expand All @@ -151,9 +161,9 @@ If you need more control over when caches are restored and saved, you can split
restore-keys: cache-lychee-
- name: Run lychee
uses: lycheeverse/lychee-action@v1.8.0
uses: lycheeverse/lychee-action@v1.9.0
with:
args: "--cache --max-cache-age 1d ."
args: "--base . --cache --max-cache-age 1d ."
- name: Save lychee cache
uses: actions/cache/save@v3
Expand Down Expand Up @@ -224,7 +234,7 @@ For example:

```yml
- name: Link Checker
uses: lycheeverse/lychee-action@ec7614d7605b47efb08dc370f6d0a71884cba944 # for v1.8.0
uses: lycheeverse/lychee-action@22134d37a1fff6c2974df9c92a7c7e1e86a08f9c # for v1.9.0
```

## Credits
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ inputs:
required: false
lycheeVersion:
description: "Use custom version of lychee link checker"
default: v0.13.0
default: v0.15.0
required: false
output:
description: "Summary output file path"
Expand Down Expand Up @@ -56,7 +56,7 @@ runs:
id: lychee
env:
# https://github.com/actions/runner/issues/665
INPUT_GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
INPUT_TOKEN: ${{ inputs.TOKEN }}
INPUT_ARGS: ${{ inputs.ARGS }}
INPUT_DEBUG: ${{ inputs.DEBUG }}
INPUT_FAIL: ${{ inputs.FAIL }}
Expand Down
6 changes: 2 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ exit_code=$?

if [ ! -f "${LYCHEE_TMP}" ]; then
echo "No output. Check pipeline run to see if lychee panicked." > "${LYCHEE_TMP}"
fi

# If we have any output, create a report in the designated directory
if [ -f "${LYCHEE_TMP}" ]; then
else
# If we have any output, create a report in the designated directory
mkdir -p "$(dirname -- "${INPUT_OUTPUT}")"
cat "${LYCHEE_TMP}" > "${INPUT_OUTPUT}"

Expand Down

0 comments on commit 1a931e2

Please sign in to comment.