Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always create output file; not only on error #199

Merged
merged 9 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ jobs:
continue-on-error: true
name: Test the lychee link checker action
steps:
# To use this repository's private action,
# we must check out the repository
- name: Checkout
uses: actions/checkout@v3

- name: test defaults
uses: ./
with:
fail: true

- name: test explicit lychee version
uses: ./
with:
lycheeVersion: 0.9.0

- name: test globs
uses: ./
with:
Expand All @@ -33,36 +34,59 @@ jobs:
'./**/*.html'
'./**/*.rst'
fail: true

- name: Install jq
run: sudo apt-get install jq

- name: test workflow inputs - Markdown
uses: ./
with:
args: -v fixtures/TEST.md
format: json
output: /tmp/foo.json
output: ${{ github.workspace }}/foo_md.json
fail: true

- 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: /tmp/foo.json
output: ${{ github.workspace }}/foo_rst.json
fail: true

- 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 .
fail: true

- name: test format override
uses: ./
with:
args: --format markdown -v fixtures/TEST.md
format: doesnotexist # gets ignored if format set in args
output: /tmp/foo.txt
output: ${{ github.workspace }}/foo.txt
fail: true

- name: test debug
uses: ./
with:
debug: true

- name: test custom GitHub token
uses: ./
with:
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ runs:
steps:
- name: Install lychee
run: |
# Cleanup artifacts from previous run in case it crashed
rm -rf "lychee-v${{ inputs.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz" lychee
curl -sLO "https://github.com/lycheeverse/lychee/releases/download/v${{ inputs.LYCHEEVERSION }}/lychee-v${{ inputs.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz"
tar -xvzf "lychee-v${{ inputs.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz"
rm "lychee-v${{ inputs.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz"
Expand Down
8 changes: 4 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ if [ ! -f "${LYCHEE_TMP}" ]; then
echo "No output. Check pipeline run to see if lychee panicked." > "${LYCHEE_TMP}"
fi

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

Expand All @@ -52,8 +52,8 @@ fi
# Pass lychee exit code to next step
echo "lychee_exit_code=$exit_code" >> $GITHUB_ENV

# If `fail` is set to `true`, propagate the real exit value to the workflow
# runner. This will cause the pipeline to fail on exit != 0.
# If `fail` is set to `true`, propagate the real exit code to the workflow
# runner. This will cause the pipeline to fail on `exit != 0`.
if [ "$INPUT_FAIL" = true ] ; then
exit ${exit_code}
fi
4 changes: 2 additions & 2 deletions fixtures/TEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Some more complex formatting to test that Markdown parsing works.
[![CC0](https://i.creativecommons.org/p/zero/1.0/88x31.png)](https://creativecommons.org/publicdomain/zero/1.0/)

Test HTTP and HTTPS for the same site.
http://spinroot.com/cobra/
https://spinroot.com/cobra/
http://google.com/
https://google.com/

test@example.com