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

Validate existing contributor #57

Merged
merged 165 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
165 commits
Select commit Hold shift + click to select a range
dbb4857
add contributing workflow
SKairinos Dec 18, 2023
f180947
add contributing script
SKairinos Dec 19, 2023
eb0ad5a
sds
SKairinos Dec 19, 2023
8699c6c
add contributing script
SKairinos Dec 19, 2023
2c8ff2e
quick save
SKairinos Dec 20, 2023
7b46f99
fix workflow
SKairinos Dec 20, 2023
28296af
fix trigger
SKairinos Dec 20, 2023
16f8c0b
remove example user
SKairinos Dec 20, 2023
0c521e1
remove temp code
SKairinos Dec 20, 2023
ca348e8
fix triggers
SKairinos Dec 20, 2023
a45b149
rename job
SKairinos Dec 20, 2023
41304ce
fetch main branch
SKairinos Dec 20, 2023
86b8b5e
keep .venv
SKairinos Dec 28, 2023
8c13973
setup python scripts dir
SKairinos Dec 28, 2023
7496a53
update pipeline
SKairinos Dec 28, 2023
9bcef30
house keeping
SKairinos Dec 28, 2023
953b311
test
SKairinos Dec 28, 2023
80b1d5a
fix new line
SKairinos Dec 28, 2023
4015786
fix fetch main
SKairinos Dec 28, 2023
13da74d
replace logging with print
SKairinos Dec 28, 2023
718737c
test
SKairinos Dec 28, 2023
7a9aa64
fetch branch
SKairinos Dec 28, 2023
e5bb478
set cwd
SKairinos Dec 28, 2023
2a5cd2f
fix prints and paths
SKairinos Dec 28, 2023
9e0a0a2
fix print
SKairinos Dec 28, 2023
8437eb3
show response json
SKairinos Dec 28, 2023
d6fae88
test
SKairinos Dec 28, 2023
518d42f
fix dd auth
SKairinos Dec 28, 2023
7c8d4e5
test
SKairinos Dec 28, 2023
35b611a
test
SKairinos Dec 28, 2023
2610370
test
SKairinos Dec 28, 2023
a74b987
test
SKairinos Dec 28, 2023
15bd17b
test
SKairinos Dec 28, 2023
a4adece
remove test
SKairinos Dec 28, 2023
86cf505
test
SKairinos Dec 29, 2023
b1706bd
test
SKairinos Dec 29, 2023
d02b853
test echo env var
SKairinos Dec 29, 2023
ea20409
test open
SKairinos Dec 29, 2023
8c46dbf
test multi env vars
SKairinos Dec 29, 2023
0629d5e
keep venv
SKairinos Dec 29, 2023
afe1a96
test send-email action
SKairinos Dec 29, 2023
5947459
use action_path
SKairinos Dec 29, 2023
cb4efd2
cat file
SKairinos Dec 29, 2023
dfacc04
cat file
SKairinos Dec 29, 2023
605eee8
fix action
SKairinos Dec 29, 2023
e55132e
set env vars
SKairinos Dec 29, 2023
e66306f
add comments
SKairinos Dec 29, 2023
d17953f
test json loads
SKairinos Dec 29, 2023
2ed7441
test json loads pt2
SKairinos Dec 29, 2023
44a81ed
test json loads pt3
SKairinos Dec 29, 2023
d923343
send test email
SKairinos Dec 29, 2023
c420f10
house keeping
SKairinos Dec 29, 2023
699f37b
use send-email action
SKairinos Dec 29, 2023
f1e561e
fix pipeline
SKairinos Dec 29, 2023
06d3971
rename file
SKairinos Dec 29, 2023
c83c84e
fix module doc string
SKairinos Dec 29, 2023
614be6d
use html url
SKairinos Dec 29, 2023
1db39fb
test
SKairinos Dec 29, 2023
e2900aa
try review trigger
SKairinos Dec 29, 2023
9a9ca59
on pull_request_target
SKairinos Dec 29, 2023
d74b1d3
test
SKairinos Jan 5, 2024
9cd1d62
add env var
SKairinos Jan 5, 2024
9ddd977
checkout
SKairinos Jan 5, 2024
e1f803f
reviews
SKairinos Jan 5, 2024
1ba46b3
verify new contributor test
SKairinos Jan 5, 2024
a419ce0
top level workflow
SKairinos Jan 5, 2024
788ff7c
remove gh token secret
SKairinos Jan 5, 2024
dfa5979
test
SKairinos Jan 5, 2024
805c454
rename file
SKairinos Jan 5, 2024
bb5458f
rename file
SKairinos Jan 5, 2024
8fb62b1
fix ref
SKairinos Jan 5, 2024
9481286
rename file
SKairinos Jan 5, 2024
8d15f35
test
SKairinos Jan 5, 2024
38339a8
test
SKairinos Jan 5, 2024
3195e3f
fix ref
SKairinos Jan 5, 2024
3434cd6
test
SKairinos Jan 5, 2024
faf1245
pipe output
SKairinos Jan 5, 2024
25e98a6
print latest state
SKairinos Jan 5, 2024
3e7f6f4
fix assertion
SKairinos Jan 5, 2024
31e453d
add .venv file
SKairinos Jan 5, 2024
6329910
root dir per script
SKairinos Jan 5, 2024
4479606
checkout: false
SKairinos Jan 5, 2024
c814c04
pass values
SKairinos Jan 5, 2024
623a773
duplicate workflow
SKairinos Jan 5, 2024
f82343c
test
SKairinos Jan 5, 2024
c77a799
output email address
SKairinos Jan 5, 2024
aa4925b
test
SKairinos Jan 5, 2024
5bdae9e
test
SKairinos Jan 5, 2024
d636e35
echo event name
SKairinos Jan 5, 2024
b3adf35
test
SKairinos Jan 5, 2024
d28ffe0
not pull request
SKairinos Jan 5, 2024
b3a9082
fix pr checkout
SKairinos Jan 5, 2024
6eaa7a2
test
SKairinos Jan 5, 2024
946bbf9
test
SKairinos Jan 5, 2024
08334a6
ref
SKairinos Jan 5, 2024
b227e9b
force
SKairinos Jan 5, 2024
f4908b9
test
SKairinos Jan 5, 2024
c29a4e2
test
SKairinos Jan 5, 2024
c6759eb
test
SKairinos Jan 5, 2024
1b0ff95
test
SKairinos Jan 5, 2024
877869e
test
SKairinos Jan 5, 2024
46d1c99
test
SKairinos Jan 5, 2024
7d0cbeb
set pr num
SKairinos Jan 6, 2024
ff5a6bc
no secret
SKairinos Jan 6, 2024
7df3b9b
workflow call outputs
SKairinos Jan 6, 2024
33c7ec4
validate new contributor
SKairinos Jan 6, 2024
5421535
test
SKairinos Jan 6, 2024
f58984d
test
SKairinos Jan 6, 2024
36f903e
test
SKairinos Jan 6, 2024
61258a3
rename
SKairinos Jan 6, 2024
6aa4659
test
SKairinos Jan 6, 2024
3d86179
test
SKairinos Jan 6, 2024
4b4f0ac
test
SKairinos Jan 6, 2024
ee0f39a
fix script
SKairinos Jan 6, 2024
4a0e9cd
fix script
SKairinos Jan 6, 2024
c49d8cc
fix
SKairinos Jan 6, 2024
c282578
test
SKairinos Jan 6, 2024
d4abe7d
fix
SKairinos Jan 6, 2024
9be5d61
fix
SKairinos Jan 6, 2024
f715146
fix
SKairinos Jan 6, 2024
ec87901
fix
SKairinos Jan 6, 2024
65e1136
tidy up
SKairinos Jan 6, 2024
421415d
fix
SKairinos Jan 6, 2024
ff9f823
create script
SKairinos Jan 8, 2024
5e51ebe
workflow
SKairinos Jan 8, 2024
6e2024a
feeback
SKairinos Jan 8, 2024
5392240
Merge branch 'new_contributor_validations' into validate_existing_con…
SKairinos Jan 8, 2024
74f7d87
Merge branch 'main' into validate_existing_contributor
SKairinos Jan 8, 2024
135f812
rename files
SKairinos Jan 8, 2024
4da95e2
add comment
SKairinos Jan 8, 2024
b764921
fix
SKairinos Jan 9, 2024
e98503b
cd
SKairinos Jan 9, 2024
718c852
path
SKairinos Jan 9, 2024
9adb2e4
echo
SKairinos Jan 9, 2024
5eb8d35
test
SKairinos Jan 9, 2024
fe25c01
fix path
SKairinos Jan 9, 2024
5652174
fix
SKairinos Jan 9, 2024
b9650bf
echo pwd
SKairinos Jan 9, 2024
daf541c
wdir
SKairinos Jan 9, 2024
3fbf09f
test
SKairinos Jan 9, 2024
f9df0e8
rename files
SKairinos Jan 9, 2024
44e86e8
test
SKairinos Jan 9, 2024
c4df24c
names
SKairinos Jan 9, 2024
3fe19f8
test
SKairinos Jan 9, 2024
8313b71
test
SKairinos Jan 9, 2024
9619bc7
test
SKairinos Jan 9, 2024
6e80adc
fix paths
SKairinos Jan 9, 2024
d4c75f7
test
SKairinos Jan 9, 2024
9d60f52
fix
SKairinos Jan 9, 2024
4dddec7
test
SKairinos Jan 9, 2024
662a497
test
SKairinos Jan 9, 2024
6ea7224
test
SKairinos Jan 9, 2024
4286197
test
SKairinos Jan 9, 2024
d03e69d
remove input
SKairinos Jan 9, 2024
e4f89e8
test
SKairinos Jan 9, 2024
c32afa7
aaa
SKairinos Jan 9, 2024
f204a31
bbb
SKairinos Jan 9, 2024
15232b3
input pull request
SKairinos Jan 10, 2024
2ab2439
test
SKairinos Jan 10, 2024
f7c3ea9
test
SKairinos Jan 10, 2024
bdf1119
pleasework
SKairinos Jan 10, 2024
114cbe9
pleasework
SKairinos Jan 10, 2024
627e6a3
123
SKairinos Jan 10, 2024
30906cd
should work
SKairinos Jan 10, 2024
41d22c5
ref: main
SKairinos Jan 10, 2024
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
Empty file.
16 changes: 16 additions & 0 deletions .github/scripts/python/validate-existing-contributors/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]
black = "==23.1.0"
pytest = "==7.2.1"
mypy = "==1.6.1"
pylint = "==3.0.2"
types-requests = "==2.31.0.10"

[requires]
python_version = "3.11"
229 changes: 229 additions & 0 deletions .github/scripts/python/validate-existing-contributors/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 90 additions & 0 deletions .github/scripts/python/validate-existing-contributors/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
"""
© Ocado Group
Created on 08/01/2024 at 09:47:25(+00:00).

Validate all contributors have signed the contribution agreement.
"""

import json
import os
import typing as t
from email.utils import parseaddr

PullRequest = t.Dict[str, t.Any]
Contributors = t.Set[str]

# pylint: disable-next=line-too-long
CONTRIBUTING_FILE_NAME = "CONTRIBUTING.md"
CONTRIBUTORS_HEADER = "### 👨\u200d💻 Contributors 👩\u200d💻"


def get_inputs():
"""Get script's inputs.

Returns:
A JSON object of the pull request.
"""

pull_request: PullRequest = json.loads(os.environ["PULL_REQUEST"])

return pull_request


def get_signed_contributors() -> Contributors:
"""Get the contributors that have signed the contribution agreement.

Returns:
A set of the contributors' email addresses.
"""

with open(
f"../../../../{CONTRIBUTING_FILE_NAME}",
"r",
encoding="utf-8",
) as contributing:
lines = contributing.read().splitlines()

# NOTE: +2 because we don't want the header and its proceeding blank line.
lines = lines[lines.index(CONTRIBUTORS_HEADER) + 2 :]

return {parseaddr(line)[1] for line in lines}


def assert_contributors(
pull_request: PullRequest,
signed_contributors: Contributors,
):
"""Assert that all contributors have signed the contribution agreement.

Args:
pull_request: The JSON object of the pull request.
signed_contributors: The contributors that have signed the contribution
agreement.
"""

contributors: Contributors = {
author["email"]
for commit in pull_request["commits"]
for author in commit["authors"]
}

unsigned_contributors = contributors.difference(signed_contributors)

assert not unsigned_contributors, (
"The following contributors have not signed the agreement:"
f" {', '.join(unsigned_contributors)}."
)


def main():
"""Entry point."""

pull_request = get_inputs()

signed_contributors = get_signed_contributors()

assert_contributors(pull_request, signed_contributors)


if __name__ == "__main__":
main()
41 changes: 41 additions & 0 deletions .github/workflows/validate-existing-contributors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Validate Existing Contributors

on:
workflow_call:

env:
PYTHON_VERSION: 3.11
WORKING_DIR: codeforlife-workspace/.github/scripts/python/validate-existing-contributors

jobs:
validate-existing-contributors:
runs-on: ubuntu-latest
steps:
- name: 🛫 Checkout Pull Request
uses: actions/checkout@v4

- name: 🔎 View Pull Request's Commits
id: view-pr
run: echo "PULL_REQUEST=$(gh pr view ${{ github.event.pull_request.number }} --json commits)" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 🛫 Checkout Workspace
uses: actions/checkout@v4
with:
repository: ocadotechnology/codeforlife-workspace
ref: main
path: codeforlife-workspace

- name: 🐍 Set up Python ${{ env.PYTHON_VERSION }} Environment
uses: ocadotechnology/codeforlife-workspace/.github/actions/python/setup-environment@main
with:
checkout: 'false'
python-version: ${{ env.PYTHON_VERSION }}
working-directory: ${{ env.WORKING_DIR }}

- name: 🕵️ Validate Existing Contributors
working-directory: ${{ env.WORKING_DIR }}
run: pipenv run python .
env:
PULL_REQUEST: ${{ steps.view-pr.outputs.PULL_REQUEST }}