TO-DROP: trace commands #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
workflow_dispatch: | |
repository_dispatch: | |
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 | |
name: Test the lychee link checker action | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: test defaults | |
uses: ./ | |
- name: test explicit lychee version | |
uses: ./ | |
with: | |
lycheeVersion: v0.14.0 | |
- name: test globs | |
uses: ./ | |
with: | |
args: >- | |
--exclude-mail | |
--verbose | |
--no-progress | |
'./**/*.md' | |
'./**/*.html' | |
'./**/*.rst' | |
- name: test --base argument | |
uses: ./ | |
with: | |
args: >- | |
--base . | |
--verbose | |
--no-progress | |
'./**/*.md' | |
'./**/*.html' | |
'./**/*.rst' | |
- 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: test output set in args and action input | |
id: output_set_in_args_and_action_input | |
uses: ./ | |
with: | |
args: --output foo - | |
output: bar | |
continue-on-error: true | |
- name: test output set in args and action input should fail - validation | |
if: steps.output_set_in_args_and_action_input.outcome != 'failure' | |
run: | | |
echo "Output set in args and action input should have failed." | |
exit 1 | |
- name: test failIfEmpty - no links in input should fail the pipeline | |
id: fail_if_empty_test | |
uses: ./ | |
with: | |
args: --verbose --no-progress fixtures/empty.md | |
debug: true | |
continue-on-error: true | |
# Explictly check the exit code of the previous step | |
# as it's expected to fail | |
- name: Check failIfEmpty | |
if: steps.fail_if_empty_test.outcome != 'failure' | |
run: | | |
echo "FailIfEmpty should have failed because no links were found." | |
exit 1 | |
- name: test disable failIfEmpty - it's okay if no links are found | |
uses: ./ | |
with: | |
args: --no-progress fixtures/empty.md | |
failIfEmpty: false | |
- name: Install jq | |
run: sudo apt-get install jq | |
- name: test workflow inputs - Markdown | |
uses: ./ | |
with: | |
args: -v fixtures/TEST.md | |
format: json | |
output: ${{ github.workspace }}/foo_md.json | |
- name: Validate JSON - Markdown | |
run: | | |
if ! jq empty ${{ github.workspace }}/foo_md.json; then | |
echo "Output file does not exist or is not valid JSON" | |
exit 1 | |
fi | |
- name: test workflow inputs - rST | |
uses: ./ | |
with: | |
args: -v fixtures/TEST.rst | |
format: json | |
output: ${{ github.workspace }}/foo_rst.json | |
- name: Validate JSON - rST | |
run: | | |
if ! jq empty ${{ github.workspace }}/foo_rst.json; then | |
echo "Output file does not exist or is not valid JSON" | |
exit 1 | |
fi | |
- name: directory | |
uses: ./ | |
with: | |
args: --exclude-mail . | |
- name: test format override | |
uses: ./ | |
with: | |
args: --format markdown -v fixtures/TEST.md | |
format: doesnotexist # gets ignored if format set in args | |
output: ${{ github.workspace }}/foo.txt | |
- name: test debug | |
uses: ./ | |
with: | |
debug: true | |
- name: test custom GitHub token | |
uses: ./ | |
with: | |
token: ${{ secrets.CUSTOM_TOKEN }} |