Bump actions/cache from 5 to 6 #55
Workflow file for this run
This file contains hidden or 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
| --- | |
| name: Check for presentation links in README | |
| on: pull_request | |
| jobs: | |
| build: | |
| name: Lint README | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v7 | |
| - name: Lint markdown files | |
| run: | | |
| # define excluded files and directories | |
| # zstd directory is just images from the `zstd.md` file | |
| excluded_dirs=(".git" ".github" "." "zstd") | |
| excluded_files=("README.md" "LICENSE.md") | |
| failures=0 | |
| # construct exclusion directories arguments for `find` | |
| dir_exclude_args=() | |
| for dir in "${excluded_dirs[@]}"; do | |
| dir_exclude_args+=(! -name "$dir") | |
| done | |
| # construct exclusion files arguments for `find` | |
| file_exclude_args=() | |
| for file in "${excluded_files[@]}"; do | |
| file_exclude_args+=(! -name "$file") | |
| done | |
| # find the top level presenatation folders | |
| dirs=$(find . -maxdepth 1 -type d "${dir_exclude_args[@]}" | sed 's|^\./||') | |
| # find the top level presenatation files | |
| md_files=$(find . -maxdepth 1 -type f -name "*.md" "${file_exclude_args[@]}" | sed 's|^\./||') | |
| # aggregate a list of all the links in the README | |
| readme_entries=$(grep -oP '\[.*?\]\(\K[^)]+' README.md) | |
| # make sure that each presenatation directory is linked in the README | |
| for dir in $dirs; do | |
| if ! echo "$readme_entries" | grep -q "^$dir"; then | |
| failures=$((failures + 1)) | |
| # get the $dir/index.md file if it exists for warning logging | |
| primary_md_file="$dir/" | |
| if [[ -f "$dir/index.md" ]]; then | |
| primary_md_file="$dir/index.md" | |
| else | |
| # find the first markdown file within the directory and link to that if no index.md is present | |
| primary_md_file=$(find "$dir" -maxdepth 1 -type f -name "*.md" | head -n 1) | |
| # if nothing was found in find, fallback to the directory itself | |
| [[ -z "$primary_md_file" ]] && primary_md_file="$dir" | |
| fi | |
| echo "::warning file=$primary_md_file,title=Unlinked Directory::Missing link to this directory in README.md" | |
| fi | |
| done | |
| # make sure that each presenatation file is linked in the README | |
| for md in $md_files; do | |
| if ! echo "$readme_entries" | grep -q "^$md"; then | |
| failures=$((failures + 1)) | |
| echo "::warning file=$md,title=Unlinked File::Missing link to this file in README.md" | |
| fi | |
| done | |
| # if nothing is missing, this will exit with status 0. if not, it'll exit with the number of missing links | |
| exit $failures |