Skip to content

Commit

Permalink
move readmes verification into precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
dmathieu committed Mar 26, 2024
1 parent b553e31 commit 10ceff9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 0 additions & 19 deletions .github/workflows/scripts/readme.sh

This file was deleted.

3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
21 changes: 21 additions & 0 deletions verify_readmes.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 10ceff9

Please sign in to comment.