Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CONTRIB: Automate AUTHORS file update #10308

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Akshay Venkatesh <akvenkatesh@nvidia.com>
Aleksey Senin <alekseys@nvidia.com>
Alexey Rivkin <arivkin@nvidia.com>
Alex Margolin <alex.margolin@huawei.com>
Alex Mikheev <alexm@mellanox.com>
Alexey Rivkin <arivkin@nvidia.com>
Alina Sklarevich <alinas@mellanox.com>
Anatoly Vildemanov <anatolyv@nvidia.com>
Andrey Maslennikov <andreyma@mellanox.com>
Expand Down
25 changes: 25 additions & 0 deletions buildlib/pr/codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,31 @@ jobs:
fi
condition: eq(variables['Build.Reason'], 'PullRequest')

- job: author
displayName: AUTHORS file update check
pool:
name: MLNX
demands:
- ucx_docker -equals yes
container: fedora
steps:
- checkout: self
clean: true
fetchDepth: 100
retryCountOnTaskFailure: 5

- bash: |
set -eEx

BASE_SOURCEVERSION=$(git rev-parse HEAD^)
range="$BASE_SOURCEVERSION..$(Build.SourceVersion)"

echo "Looking for missing AUTHORS on commit range ${range}"
./contrib/authors_update.sh "$range"
git diff --exit-code
displayName: AUTHORS file check


- job: codespell
displayName: codespell check
pool:
Expand Down
45 changes: 45 additions & 0 deletions contrib/authors_update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
#
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# See file LICENSE for terms.
#

set -eEu -o pipefail

range="${1?Provide commit range like orig/v1.17..orig/v1.18}"
michal-shalev marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like -> , for example:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


michal-shalev marked this conversation as resolved.
Show resolved Hide resolved
if [ ! -w AUTHORS ]
then
echo "AUTHORS file not accessible"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is not writable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, but -w also covers the case where file does not exist

exit 1
fi

# Failure message triggered if range is not valid
lines=$(git log --no-merges --pretty=format:"%an%x09%ae" "$range" | sort | uniq)
if [ -z "$lines" ]
then
echo "Error: empty range \"$range\""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provided range is empty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

exit 1
fi

tmp=$(mktemp --tmpdir=./)
grep @ AUTHORS >"$tmp"

echo "Names:"

echo -e "$lines" | \
while IFS=$'\t' read -r name email; do
line="$name <$email>"

# Check for known email, or identical name
if ! grep -iqw "$email" "$tmp" && ! grep -iq "$name" "$tmp"; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you pls add comment what this does?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

echo "$line" >>"$tmp"
echo "++ $line"
else
echo " $line"
fi
done

LC_COLLATE=C sort -o "$tmp"{,}
grep -v @ AUTHORS >>"$tmp"
mv "$tmp" AUTHORS
Loading