Skip to content

Commit

Permalink
Move to poetry (#16)
Browse files Browse the repository at this point in the history
Signed-off-by: John Mertic <[email protected]>
  • Loading branch information
jmertic authored Nov 16, 2024
1 parent 3861725 commit 017255b
Show file tree
Hide file tree
Showing 12 changed files with 355 additions and 218 deletions.
16 changes: 12 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@ runs:
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: '3.x'
- name: Install poetry
uses: abatilo/actions-poetry@e78f54a89cb052fff327414dd9ff010b5d2b4dbd # v3.0.1
- name: Install dependencies
shell: bash
working-directory: ./lfx-tac-actions
run: |
poetry install
- name: Run build
working-directory: ./tac-repo
working-directory: ./lfx-tac-actions
shell: bash
env:
LANDSCAPE_URL: ${{ inputs.landscape_url }}
Expand All @@ -48,9 +55,10 @@ runs:
GH_TOKEN: ${{ env.token }}
GITHUB_TOKEN: ${{ env.token }}
run: |
python ../lfx-tac-actions/updateprojects.py
python ../lfx-tac-actions/updatetacmembers.py
python ../lfx-tac-actions/updatetacagendaitems.py
poetry run updateprojects -o ../tac-repo/_data/projects.csv
poetry run updatetacmembers -o ../tac-repo/_data/tacmembers.csv
poetry run updatetacagendaitems -o ../tac-repo/_data/meeting-agenda-items.csv
poetry run updateclomonitor -o ../tac-repo/_data/clomonitor.yaml
- name: Get current date
id: date
uses: Kaven-Universe/github-action-current-date-time@f2c12d90cff9c3e7b1f50430886e632fe31fcee1 # v1.4.0
Expand Down
8 changes: 8 additions & 0 deletions lfx_tac_actions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python3
#
# Copyright this project and it's contributors
# SPDX-License-Identifier: Apache-2.0
#
# encoding=utf8


68 changes: 68 additions & 0 deletions lfx_tac_actions/updateclomonitor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env python3
#
# Copyright this project and its contributors
# SPDX-License-Identifier: Apache-2.0
#
# encoding=utf8

import yaml
import argparse
import urllib.request
import urllib.parse
import json
import os

def main():
parser = argparse.ArgumentParser()
parser.add_argument("-o", "--output", help="filename to save output to",default='_data/clomonitor.yaml')
args = parser.parse_args()

if os.environ.get("LANDSCAPE_URL") != '' and os.environ.get("ARTWORK_URL") != '':
landscapeHostedProjects = '{}/api/projects/all.json'.format(os.environ.get("LANDSCAPE_URL"))
projectEntries = []

with urllib.request.urlopen(landscapeHostedProjects) as hostedProjectsResponse:
projectData = json.load(hostedProjectsResponse)
for project in projectData:
if project.get('maturity') == 'emeritus':
continue
print("Processing {}...".format(project.get('name')))

# grab correct logo from artwork repo
logo_url = ''
logo_url_dark = ''
if project.get('artwork_url'):
urlparts = urllib.parse.urlparse(project.get('artwork_url'))
with urllib.request.urlopen('{}://{}/assets/data.json'.format(urlparts.scheme,urlparts.netloc)) as artworkResponse:
artworkData = json.load(artworkResponse)
logo_url = '{}://{}{}{}'.format(urlparts.scheme,urlparts.netloc,urlparts.path,artworkData.get(urlparts.path,{}).get('primary_logo'))
logo_url_dark = '{}://{}{}{}'.format(urlparts.scheme,urlparts.netloc,urlparts.path,artworkData.get(urlparts.path,{}).get('dark_logo'))
else:
logo_url = project.get('logo')
logo_url_dark = project.get('logo')

projectEntry = {
'name': project.get('annotations',{}).get('slug'),
'display_name': project.get('name'),
'description': project.get('description'),
'category': 'Visual Effects and Computer Graphics',
'logo_url': logo_url,
'logo_url_dark': logo_url_dark,
'devstats_url': project.get('dev_stats_url'),
'maturity': project.get('maturity'),
'repositories': []
}
for repo in project.get('repositories',[]):
projectEntry['repositories'].append({
'name': repo.get('url').rsplit('/', 1)[-1],
'url': repo.get('url'),
'exclude': ['clomonitor']
})
projectEntries.append(projectEntry)

with open(args.output, 'w') as cloMonitorFileObject:
print("Saving file {}".format(args.output))
yaml.dump(projectEntries, cloMonitorFileObject, sort_keys=False, indent=2)

if __name__ == '__main__':
main()
64 changes: 64 additions & 0 deletions lfx_tac_actions/updateprojects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env python3
#
# Copyright this project and its contributors
# SPDX-License-Identifier: Apache-2.0
#
# encoding=utf8

import csv
import urllib.request
import json
import os
import argparse

def main():
parser = argparse.ArgumentParser()
parser.add_argument("-o", "--output", help="filename to save output to",default='_data/projects.csv')
args = parser.parse_args()

if os.environ.get("LANDSCAPE_URL") != '':
landscapeHostedProjects = '{}/api/projects/all.json'.format(os.environ["LANDSCAPE_URL"])

csvRows = []
with urllib.request.urlopen(landscapeHostedProjects) as hostedProjectsResponse:
projectData = json.load(hostedProjectsResponse)
for project in projectData:
categories = []
categories.append("{category} / {subcategory}".format(category=project.get('category'),subcategory=project.get('subcategory')))
for additional_category in project.get('additional_categories',{}):
categories.append("{category} / {subcategory}".format(category=additional_category['category'],subcategory=additional_category['subcategory']))
print("Processing {}...".format(project.get('name')))
csvRows.append({
'Name': project.get('name'),
'Level': project.get('maturity'),
'Logo URL': project.get('logo_url'),
'Slug': project.get('annotations',{}).get('slug'),
'Categories': ','.join(categories),
'Website': project.get('homepage_url'),
'Chair': project.get('annotations',{}).get('chair'),
'TAC Representative': project.get('annotations',{}).get('TAC_representative'),
'Documentation': project.get('extra',{}).get('documentation_url'),
'Calendar': project.get('annotations',{}).get('calendar_url'),
'Artwork': project.get('artwork_url'),
'iCal': project.get('annotations',{}).get('ical_url'),
'LFX Insights URL': project.get('dev_stats_url'),
'Accepted Date': project.get('accepted_at'),
'Last Review Date': project.get('extra',{}).get('annual_review_date'),
'Next Review Date': project.get('annotations',{}).get('next_annual_review_date'),
'Slack URL': project.get('slack_url'),
'Chat Channel': project.get('chat_channel'),
'Mailing List': project.get('mailing_list_url'),
'Github Org': project.get('annotations',{}).get('project_org'),
'Best Practices Badge ID': project.get('bestPracticeBadgeId') ,
'Primary Github Repo': project.get('repo_url'),
'Contributed By': project.get('annotations',{}).get('contributed_by'),
})

with open(args.output, 'w') as projectsCsvFileObject:
print("Saving file {}".format(args.output))
writer = csv.DictWriter(projectsCsvFileObject, fieldnames = csvRows[0].keys())
writer.writeheader()
writer.writerows(csvRows)

if __name__ == '__main__':
main()
67 changes: 67 additions & 0 deletions lfx_tac_actions/updatetacagendaitems.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env python3
#
# Copyright this project and its contributors
# SPDX-License-Identifier: Apache-2.0
#
# encoding=utf8

import sys
import csv
import json
import os
import subprocess
from urllib.parse import urlparse
import argparse

def main():
parser = argparse.ArgumentParser()
parser.add_argument("-o", "--output", help="filename to save output to",default='_data/tacmembers.csv')
args = parser.parse_args()

if os.environ.get("TAC_AGENDA_GH_PROJECT_URL") != '':
urlparts = urlparse(os.environ.get("TAC_AGENDA_GH_PROJECT_URL")).path.split('/')
if urlparts and urlparts[1] == 'orgs' and urlparts[3] == 'projects':
command = subprocess.run("gh project item-list {gh_project_id} --owner {gh_org} --format json --limit 100".format(gh_project_id=urlparts[4],gh_org=urlparts[2]), shell=True, capture_output=True)
jsonProjectData = command.stdout

csvRows = []
try:
projectData = json.loads(jsonProjectData)
except:
print("Invalid response from gh client: '{}'".format(command.stderr))
sys.exit(0)

for item in projectData.get('items',[]):
print("Processing {}...".format(item['content']['title']))
meetingItem = {
'title': item.get('content',{}).get('title'),
'url': item.get('content',{}).get('url'),
'number': item.get('content',{}).get('number'),
'scheduled_date': item.get('scheduled Date'),
'status': item.get('status'),
'last_review_date': item.get('last Review Date'),
}
if '1-new-project-wg' in item.get('labels',{}):
meetingItem['meeting_label'] = '1-new-project-wg'
elif '2-annual-review' in item.get('labels',{}):
meetingItem['meeting_label'] = '2-annual-review'
elif '2-annual-review-tac' in item.get('labels',{}):
meetingItem['meeting_label'] = '2-annual-review'
elif '2-annual-review-sig' in item.get('labels',{}):
meetingItem['meeting_label'] = '2-annual-review-sig'
elif '3-tac-meeting-long' in item.get('labels',{}):
meetingItem['meeting_label'] = '3-tac-meeting-long'
elif '4-tac-meeting-short' in item.get('labels',{}):
meetingItem['meeting_label'] = '4-tac-meeting-short'
else:
meetingItem['meeting_label'] = None
csvRows.append(meetingItem)

with open(args.output, 'w') as csvFileObject:
print("Saving file {}".format(args.output))
writer = csv.DictWriter(csvFileObject, fieldnames = csvRows[0].keys())
writer.writeheader()
writer.writerows(csvRows)

if __name__ == '__main__':
main()
47 changes: 47 additions & 0 deletions lfx_tac_actions/updatetacmembers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python3
#
# Copyright this project and its contributors
# SPDX-License-Identifier: Apache-2.0
#
# encoding=utf8

import argparse
import csv
import urllib.request
import json
import os
from urllib.parse import urlparse

def main():
parser = argparse.ArgumentParser()
parser.add_argument("-o", "--output", help="filename to save output to",default='_data/tacmembers.csv')
args = parser.parse_args()

if os.environ.get("LFX_TAC_COMMITTEE_URL") != '':
urlparts = urlparse(os.environ.get("LFX_TAC_COMMITTEE_URL")).path.split('/')
if urlparts and urlparts[1] == 'project' and urlparts[3] == 'collaboration' and urlparts[4] == 'committees':
committeeURL = 'https://api-gw.platform.linuxfoundation.org/project-service/v2/public/projects/{project_id}/committees/{committee_id}/members'.format(project_id=urlparts[2],committee_id=urlparts[5])
csvRows = []

with urllib.request.urlopen(committeeURL) as committeeURLResponse:
committeeURLResponseJSON = json.load(committeeURLResponse)
for committeeMember in committeeURLResponseJSON['Data']:
print("Processing {} {}...".format(committeeMember['FirstName'].title(),committeeMember['LastName'].title()))
csvRows.append({
'Full Name': "{} {}".format(committeeMember['FirstName'].title(),committeeMember['LastName'].title()),
'Account Name: Account Name': committeeMember['Organization']['Name'] if 'Organization' in committeeMember and 'Name' in committeeMember['Organization'] else None,
'Appointed By': committeeMember['AppointedBy'] if 'AppointedBy' in committeeMember else None,
'Voting Status': committeeMember['VotingStatus'] if 'VotingStatus' in committeeMember else None,
'Special Role': committeeMember['Role'] if 'Role' in committeeMember else None,
'Title': committeeMember['Title'] if 'Title' in committeeMember else None,
'HeadshotURL': committeeMember['LogoURL'] if 'LogoURL' in committeeMember else None
})

with open(args.output, 'w') as tacmembersCsvFileObject:
print("Saving file {}".format(args.output))
writer = csv.DictWriter(tacmembersCsvFileObject, fieldnames = csvRows[0].keys())
writer.writeheader()
writer.writerows(csvRows)

if __name__ == '__main__':
main()
Loading

0 comments on commit 017255b

Please sign in to comment.