This is an automated email from the ASF dual-hosted git repository. klesh pushed a commit to branch kw-fix-ci in repository https://gitbox.apache.org/repos/asf/incubator-devlake-website.git
commit 0634e2cf6c953fa83c77ae414a4fa401da4af609 Author: Klesh Wong <[email protected]> AuthorDate: Wed May 17 13:41:38 2023 +0800 fix: link checker always fails on imgur --- .github/workflows/link-schedule.yaml | 20 ++++++------ .github/workflows/pr_ci.yaml | 61 +++++++++++++----------------------- .lycheeignore | 6 ++++ 3 files changed, 36 insertions(+), 51 deletions(-) diff --git a/.github/workflows/link-schedule.yaml b/.github/workflows/link-schedule.yaml index e8199587ac..4712c772d4 100644 --- a/.github/workflows/link-schedule.yaml +++ b/.github/workflows/link-schedule.yaml @@ -3,13 +3,13 @@ name: Check links daily on: workflow_dispatch: schedule: - - cron: "0 0 * * *" + - cron: "18 0 * * *" permissions: issues: write # to create an issue when link check fails env: - OUTPUT_FILE: lychee/out.md + OUTPUT_FILE: lychee.md jobs: build-and-check-links: @@ -23,10 +23,6 @@ jobs: uses: actions/setup-node@main with: node-version: 17.8.x - - name: Build Docusaurus website - run: | - npm install - npm run build - name: Install lychee env: LYCHEEVERSION: 0.12.0 @@ -59,13 +55,15 @@ jobs: LYCHEE_TMP="$(mktemp)" GITHUB_WORKFLOW_URL="https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}?check_suite_focus=true" - lychee --output ${LYCHEE_TMP} -E -i -n -t 45 --max-concurrency 64 -a 429,401,403 -m 10 -- 'build' '*.md' - exit_code=$? - if [ $exit_code -ne 0 ]; then - mkdir -p "$(dirname -- "${OUTPUT_FILE}")" - cat "${LYCHEE_TMP}" > "${OUTPUT_FILE}" + if ! lychee --output ${OUTPUT_FILE} \ + -E -i -n -t 5 --max-concurrency 64 -a 429,401,403 -m 10 -f markdown -s http -s https -X HEAD \ + '**/*.md' + then echo "" >> "${OUTPUT_FILE}" # add a new line echo "[Full Github Actions output](${GITHUB_WORKFLOW_URL})" >> "${OUTPUT_FILE}" + exit 1 + else + rm -f "${OUTPUT_FILE}" fi # if lychee run failed, create an issue - name: Create Issue From File diff --git a/.github/workflows/pr_ci.yaml b/.github/workflows/pr_ci.yaml index 7d3ed22073..3818cadf7e 100644 --- a/.github/workflows/pr_ci.yaml +++ b/.github/workflows/pr_ci.yaml @@ -8,29 +8,9 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@main - - - name: Use Node.js 17.8.x - uses: actions/setup-node@main + - uses: actions/checkout@v2 with: - node-version: 17.8.x - - name: Replace base url - run: | - # replace base url to localhost to support change of doc structure - sed -i 's#https://devlake.apache.org#http://local.devlake.apache.org#g' docusaurus.config.js - - name: Edit hosts - run: | - # why we need this: - # lychee will ignore links to localhost, so we need to add a new domain to avoid this - echo "127.0.0.1 local.devlake.apache.org" | sudo tee -a /etc/hosts - - name: Build Docusaurus website - run: | - npm install - npm run build - - name: Install http-server - run: | - sudo npm install -g http-server + fetch-depth: 0 - name: Install lychee env: LYCHEEVERSION: 0.12.0 @@ -47,22 +27,23 @@ jobs: env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} run: | - # to run a local server, so that lychee can check links on it rather than on devlake.apache.org - sudo http-server ./build -s -p 80 -a 0.0.0.0 & - # wait for http-server to start - npm install wait-on - npx wait-on http://local.devlake.apache.org -t 60000 - # For parameter description, see https://github.com/lycheeverse/lychee#commandline-parameters - # -E, --exclude-all-private Exclude all private IPs from checking. - # -i, --insecure Proceed for server connections considered insecure (invalid TLS) - # -n, --no-progress Do not show progress bar. - # -t, --timeout <timeout> Website timeout in seconds from connect to response finished [default:20] - # --max-concurrency <max-concurrency> Maximum number of concurrent network requests [default: 128] - # -a --accept <accept> Comma-separated list of accepted status codes for valid links - # -m, --max-redirects <MAX_REDIRECTS> - - # 'build': the site directory to check - # './*.md': all markdown files in the root directory - - lychee -E -i -n -t 45 --max-concurrency 64 -a 401,403 -m 10 -- 'build' '*.md' + # test external link for modified files only, the rest are tested by the docusaurus already + lychee -E -i -n -t 45 --max-concurrency 64 -a 409,401,403 -m 10 -s http -s https -X HEAD -- $(git diff --name-only ${{ github.event.pull_request.base.sha }}... | grep -P '\.md$') + - name: Use Node.js 17.8.x + uses: actions/setup-node@main + with: + node-version: 17.8.x + - name: Replace base url + run: | + # replace base url to localhost to support change of doc structure + sed -i 's#https://devlake.apache.org#http://local.devlake.apache.org#g' docusaurus.config.js + - name: Edit hosts + run: | + # why we need this: + # lychee will ignore links to localhost, so we need to add a new domain to avoid this + echo "127.0.0.1 local.devlake.apache.org" | sudo tee -a /etc/hosts + - name: Build Docusaurus website + run: | + npm install + npm run build diff --git a/.lycheeignore b/.lycheeignore index 70a3951a4c..b0d2a2d3a6 100644 --- a/.lycheeignore +++ b/.lycheeignore @@ -10,3 +10,9 @@ https://merico.feishu.cn.* .*sample-url.* https://github.com/dailidong + +https://i.imgur.com/* +https://example.org/* +https://*.example.org/* +http://example.org/* +http://*.example.org/* \ No newline at end of file
