diff --git a/.github/workflows/docs-url-alive-check.yaml b/.github/workflows/docs-url-alive-check.yaml deleted file mode 100644 index 99f7eb99f8..0000000000 --- a/.github/workflows/docs-url-alive-check.yaml +++ /dev/null @@ -1,50 +0,0 @@ -on: - schedule: - - cron: '0 23 * * 0' - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -permissions: {} - -name: Docs URL Alive Check -jobs: - test: - name: test - runs-on: ubuntu-22.04 - # don't run this action on forks - if: github.repository_owner == 'kata-containers' - env: - target_branch: ${{ github.base_ref }} - steps: - - name: Set env - run: | - echo "GOPATH=${GITHUB_WORKSPACE}" >> "$GITHUB_ENV" - - name: Checkout code - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - fetch-depth: 0 - persist-credentials: false - - - name: Install yq - run: | - ./ci/install_yq.sh - env: - INSTALL_IN_GOPATH: false - - - name: Read properties from versions.yaml - run: | - go_version="$(yq '.languages.golang.version' versions.yaml)" - [ -n "$go_version" ] - echo "GO_VERSION=${go_version}" >> "$GITHUB_ENV" - - - name: Setup Golang version ${{ env.GO_VERSION }} - uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 - with: - go-version: ${{ env.GO_VERSION }} - - - name: Docs URL Alive Check - run: | - make docs-url-alive-check diff --git a/Makefile b/Makefile index 5b13519ee9..0502ac65f2 100644 --- a/Makefile +++ b/Makefile @@ -43,9 +43,6 @@ generate-protocols: static-checks: static-checks-build bash tests/static-checks.sh -docs-url-alive-check: - bash ci/docs-url-alive-check.sh - build-and-publish-kata-debug: bash tools/packaging/kata-debug/kata-debug-build-and-upload-payload.sh ${KATA_DEBUG_REGISTRY} ${KATA_DEBUG_TAG} @@ -61,6 +58,5 @@ docs-serve: docs-build install-tarball \ default \ static-checks \ - docs-url-alive-check \ docs-build \ docs-serve diff --git a/ci/docs-url-alive-check.sh b/ci/docs-url-alive-check.sh deleted file mode 100755 index c135b8e743..0000000000 --- a/ci/docs-url-alive-check.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2021 Easystack Inc. -# -# SPDX-License-Identifier: Apache-2.0 - -set -e - -cidir=$(dirname "$0") -# shellcheck source=/dev/null -source "${cidir}/../tests/common.bash" - -run_docs_url_alive_check diff --git a/tests/common.bash b/tests/common.bash index c9c882876d..256265d344 100644 --- a/tests/common.bash +++ b/tests/common.bash @@ -1128,14 +1128,6 @@ function run_static_checks() bash "${this_script_dir}/static-checks.sh" "$@" } -function run_docs_url_alive_check() -{ - # Make sure we have the targeting branch - git remote set-branches --add origin "${branch}" - git fetch -a - bash "${this_script_dir}/static-checks.sh" --docs --all "github.com/kata-containers/kata-containers" -} - function run_get_pr_changed_file_details() { # Make sure we have the targeting branch diff --git a/tests/static-checks.sh b/tests/static-checks.sh index 15ab484f3b..a3f4078464 100755 --- a/tests/static-checks.sh +++ b/tests/static-checks.sh @@ -666,164 +666,6 @@ check_url() die "failed to check URL '${url}': errors: '${errors[*]}'" } -# Perform basic checks on documentation files -static_check_docs() -{ - local cmd="xurls" - - pushd "${repo_path}" - - if [[ ! "$(command -v "${cmd}")" ]] - then - info "Installing ${cmd} utility" - - local version - local url - - version=$(get_test_version "externals.xurls.version") - url=$(get_test_version "externals.xurls.url") - - # xurls is very fussy about how it's built. - go install "${url}@${version}" - - # shellcheck disable=SC2016 - command -v xurls &>/dev/null || - die 'xurls not found. Ensure that "$GOPATH/bin" is in your $PATH' - fi - - info "Checking documentation" - - local doc - local all_docs - local docs - local docs_status - local new_docs - local new_urls - local url - - pushd "${repo_path}" - - # shellcheck disable=SC2128 - all_docs=$(git ls-files "*.md" | grep -Ev "(grpc-rs|target)/" | sort || true) - all_docs=$(skip_paths "${all_docs[@]}") - - if [[ "${specific_branch}" = "true" ]] - then - info "Checking all documents in ${branch} branch" - docs="${all_docs}" - else - info "Checking local branch for changed documents only" - - docs_status=$(get_pr_changed_file_details || true) - docs_status=$(echo "${docs_status}" | grep "\.md$" || true) - - docs=$(echo "${docs_status}" | awk '{print $NF}' | sort) - # shellcheck disable=SC2128 - docs=$(skip_paths "${docs[@]}") - - # Newly-added docs - new_docs=$(echo "${docs_status}" | awk '/^A/ {print $NF}' | sort) - # shellcheck disable=SC2128 - new_docs=$(skip_paths "${new_docs[@]}") - - for doc in ${new_docs} - do - # A new document file has been added. If that new doc - # file is referenced by any files on this PR, checking - # its URL will fail since the PR hasn't been merged - # yet. We could construct the URL based on the users - # original PR branch and validate that. But it's - # simpler to just construct the URL that the "pending - # document" *will* result in when the PR has landed - # and then check docs for that new URL and exclude - # them from the real URL check. - url="https://${repo}/blob/${branch}/${doc}" - - new_urls+=" ${url}" - done - fi - - [[ -z "${docs}" ]] && info "No documentation to check" && return - - # shellcheck disable=SC2034 - local urls - local url_map - url_map=$(mktemp) - local invalid_urls - invalid_urls=$(mktemp) - local md_links - md_links=$(mktemp) - files_to_remove+=("${url_map}" "${invalid_urls}" "${md_links}") - - info "Checking document markdown references" - - local md_docs_to_check - - # All markdown docs are checked (not just those changed by a PR). This - # is necessary to guarantee that all docs are referenced. - md_docs_to_check="${all_docs}" - - # shellcheck disable=SC2016 - command -v kata-check-markdown &>/dev/null ||\ - (cd "${test_dir}/cmd/check-markdown" && make) - - # shellcheck disable=SC2016 - command -v kata-check-markdown &>/dev/null || \ - die 'kata-check-markdown command not found. Ensure that "$GOPATH/bin" is in your $PATH.' - - for doc in ${md_docs_to_check} - do - kata-check-markdown check "${doc}" - - # Get a link of all other markdown files this doc references - kata-check-markdown list links --format tsv --no-header "${doc}" |\ - grep "external-link" |\ - awk '{print $3}' |\ - sort -u >> "${md_links}" - done - - # clean the list of links - local tmp - tmp=$(mktemp) - - sort -u "${md_links}" > "${tmp}" - mv "${tmp}" "${md_links}" - - # A list of markdown files that do not have to be referenced by any - # other markdown file. - exclude_doc_regexs+=() - - exclude_doc_regexs+=(^CODE_OF_CONDUCT\.md$) - exclude_doc_regexs+=(^CONTRIBUTING\.md$) - exclude_doc_regexs+=(^SECURITY\.md$) - - # Magic github template files - exclude_doc_regexs+=(^\.github/.*\.md$) - - # The top level README doesn't need to be referenced by any other - # since it displayed by default when visiting the repo. - exclude_doc_regexs+=(^README\.md$) - - # Exclude READMEs for test integration - exclude_doc_regexs+=('^tests/cmd/.*/README\.md$') - - local exclude_pattern - - # Convert the list of files into an grep(1) alternation pattern. - local IFS='|' - # shellcheck disable=SC2034 - exclude_pattern="${exclude_doc_regexs[*]}" - unset IFS - - info "Checking document code blocks" - - # shellcheck disable=SC2034 - local doc_to_script_cmd="${cidir}/kata-doc-to-script.sh" - - # Synchronisation point - wait -} - static_check_eof() { local file="$1" @@ -1389,7 +1231,6 @@ main() --all) specific_branch="true" ;; --branch) branch="$2"; shift ;; --commits) func=static_check_commits ;; - --docs) func=static_check_docs ;; --dockerfiles) func=static_check_dockerfiles ;; --files) func=static_check_files ;; --force) force="true" ;;