diff --git a/.github/workflows/readme.yml b/.github/workflows/readme.yml index 75359c477f4..07ba299d958 100644 --- a/.github/workflows/readme.yml +++ b/.github/workflows/readme.yml @@ -5,14 +5,11 @@ on: - main pull_request: jobs: - readme_presence: + verify_readmes: runs-on: ubuntu-latest steps: - name: Checkout Repo uses: actions/checkout@v4 - - name: Install zsh - run: sudo apt-get update; sudo apt-get install zsh - - name: Run readme.sh - run: ./.github/workflows/scripts/readme.sh + run: ./verify_readmes.sh diff --git a/.github/workflows/scripts/readme.sh b/.github/workflows/scripts/readme.sh deleted file mode 100755 index 281d6690aec..00000000000 --- a/.github/workflows/scripts/readme.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/zsh -ex - -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -dirs=(`find . -type d -not -path "*/internal*" -not -path "*/test*" -not -path "*/example*" -not -path "*/.*" | sort`) -topdir=`pwd` - -for dir in $dirs; do - echo "checking $dir" - - cd $dir - pwd - if [ ! -f "README.md" ]; then - echo "couldn't find README.md for $dir" - exit 1 - fi - cd $topdir -done diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 62d3e856d6c..b55d07764e2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -208,6 +208,9 @@ Each (non-internal, non-test, non-documentation) module must contain a The README should not be a repetition of Go doc comments. +You can verify the presence of all README files with the `make verify-readmes` +command. + ## Style Guide One of the primary goals of this project is that it is actually used by diff --git a/Makefile b/Makefile index 6b6a01c1441..a3b86be97cf 100644 --- a/Makefile +++ b/Makefile @@ -8,13 +8,15 @@ ALL_GO_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | s OTEL_GO_MOD_DIRS := $(filter-out $(TOOLS_MOD_DIR), $(ALL_GO_MOD_DIRS)) ALL_COVERAGE_MOD_DIRS := $(shell find . -type f -name 'go.mod' -exec dirname {} \; | grep -E -v '^./example|^$(TOOLS_MOD_DIR)' | sort) +ALL_PACKAGES := $(shell find . -type d -not -path "*/internal*" -not -path "*/test*" -not -path "*/example*" -not -path "*/.*" | sort) + GO = go TIMEOUT = 60 .DEFAULT_GOAL := precommit .PHONY: precommit ci -precommit: generate dependabot-generate license-check misspell go-mod-tidy golangci-lint-fix test-default +precommit: generate dependabot-generate license-check misspell go-mod-tidy golangci-lint-fix verify-readmes test-default ci: generate dependabot-check license-check lint vanity-import-check build test-default check-clean-work-tree test-coverage # Tools @@ -305,3 +307,7 @@ add-tags: | $(MULTIMOD) .PHONY: lint-markdown lint-markdown: docker run -v "$(CURDIR):$(WORKDIR)" avtodev/markdown-lint:v1 -c $(WORKDIR)/.markdownlint.yaml $(WORKDIR)/**/*.md + +.PHONY: verify-readmes +verify-readmes: + ./verify_readmes.sh diff --git a/verify_readmes.sh b/verify_readmes.sh new file mode 100755 index 00000000000..1e87855eeaa --- /dev/null +++ b/verify_readmes.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + +set -euo pipefail + +dirs=$(find . -type d -not -path "*/internal*" -not -path "*/test*" -not -path "*/example*" -not -path "*/.*" | sort) + +missingReadme=false +for dir in $dirs; do + if [ ! -f "$dir/README.md" ]; then + echo "couldn't find README.md for $dir" + missingReadme=true + fi +done + +if [ "$missingReadme" = true ] ; then + echo "Error: some READMEs couldn't be found." + exit 1 +fi