diff --git a/.github/helpers/check_urls.sh b/.github/helpers/check_urls.sh deleted file mode 100755 index d3aa1861..00000000 --- a/.github/helpers/check_urls.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash - -set -e - -IGNORE_FILES="" -IGNORE_PATTERNS="" - -while getopts ":f:d:p:" opt; do - case "${opt}" in - f) - IGNORE_FILES="${OPTARG}";; - d) - IGNORE_DIRS="${OPTARG}";; - p) - IGNORE_PATTERNS="${OPTARG}";; - \?) - echo "Invalid option -$OPTARG" - exit;; - esac -done - -read -r -a ignore_files <<<"$IGNORE_FILES" -read -r -a ignore_dirs <<<"$IGNORE_DIRS" -read -r -a ignore_patterns <<<"$IGNORE_PATTERNS" - -IGNORE_FILES_ARG="" -for item in "${ignore_files[@]}"; do - IGNORE_FILES_ARG="$IGNORE_FILES_ARG --exclude=$item" -done -IGNORE_DIRS_ARG="" -for item in "${ignore_dirs[@]}"; do - IGNORE_DIRS_ARG="$IGNORE_DIRS_ARG --exclude-dir=$item" -done - -#Find URLs in code: -urls=$(grep -oP '(http|ftp|https):\/\/([a-zA-Z0-9_-]+(?:(?:\.[a-zA-Z0-9_-]+)+))([a-zA-Z0-9_.,@?^=%&:\/~+#-]*[a-zA-Z0-9_@?^=%&\/~+#-])?' -rI $IGNORE_FILES_ARG $IGNORE_DIRS_ARG) - -fail_counter=0 - -FAILED_LINKS=() -CHECKED_LINKS=() -for item in $urls; do -# echo $item - skip=0 - for pattern in "${ignore_patterns[@]}"; do - [[ "$item" =~ $pattern ]] && skip=1 - done - - if [[ $skip == 1 ]]; then - echo "SKIPPING $item" - continue - fi - - filename=$(echo "$item" | cut -d':' -f1) - url=$(echo "$item" | cut -d':' -f2-) - echo -n "Checking $url from file $filename" - if [[ $(echo ${CHECKED_LINKS[@]} | fgrep -w $url) ]]; then - echo -e " \033[36malready checked\033[0m" - elif ! curl --head --silent --fail "$url" 2>&1 > /dev/null; then - echo -e " \033[0;31mNOT FOUND\033[0m" - FAILED_LINKS+=("$url from file $filename") - ((fail_counter=fail_counter+1)) - else - echo -e " \033[32mok\033[0m" - fi - CHECKED_LINKS+=("$url") -done - -echo "Failed files:" -printf '%s\n' "${FAILED_LINKS[@]}" -exit $fail_counter diff --git a/.github/workflows/check_links.yml b/.github/workflows/check_links.yml new file mode 100644 index 00000000..ca9f549b --- /dev/null +++ b/.github/workflows/check_links.yml @@ -0,0 +1,42 @@ +name: Check Links +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + +jobs: + check_links: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Restore lychee cache + id: restore-cache + uses: actions/cache/restore@v4 + with: + path: .lycheecache + key: cache-lychee-${{ github.run_id }}-${{ github.run_attempt }} + restore-keys: cache-lychee- + - name: Link Checker + id: lychee + uses: lycheeverse/lychee-action@v2 + with: + fail: true + args: > + --verbose + --no-progress + --cache + --cache-exclude-status '429, 403, 404, 502' + --max-cache-age 2d + --exclude '^http://192\.168\.56\.101' + --exclude 'kernel\.org\/pub\/linux\/kernel' + --exclude 'releases/download/v\$%7BURCAP_VERSION%7D/externalcontrol-\$%7BURCAP_VERSION%7D\.jar' + --max-concurrency 1 + './**/*.md' './**/*.html' './**/*.rst' './**/*.cpp' './**/*.h' './**/*.py' + - name: Save lychee cache + uses: actions/cache/save@v4 + if: always() + with: + path: .lycheecache + key: ${{ steps.restore-cache.outputs.cache-primary-key }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78a00955..e37421bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,14 +126,3 @@ jobs: fail_ci_if_error: true token: ${{ secrets.CODECOV_TOKEN }} flags: start_ursim - - check_links: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Check URLs - run: | - .github/helpers/check_urls.sh \ - -d ".git build CMakeModules debian" \ - -f "package.xml urcl_architecture.svg trajectory_interface.svg dataflow.graphml start_ursim.sh ursim_docker.rst" \ - -p "vnc\.html opensource\.org\/licenses\/BSD-3-Clause kernel\.org\/pub\/linux\/kernel"