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

Create Github plugin #907

Closed
2 tasks done
Tracked by #898
jmcook1186 opened this issue Jul 11, 2024 · 8 comments · Fixed by Green-Software-Foundation/if-github-plugin#1
Closed
2 tasks done
Tracked by #898

Create Github plugin #907

jmcook1186 opened this issue Jul 11, 2024 · 8 comments · Fixed by Green-Software-Foundation/if-github-plugin#1
Assignees
Milestone

Comments

@jmcook1186
Copy link
Contributor

jmcook1186 commented Jul 11, 2024

sub of #898

what

A plugin that requests data about Github repositories using the Github API using personal authorization tokens stored in environment variables.

context

Code storage and distribution is an important component of quantifying the environmental impacts of software projects. Github is the industry standard platform for hosting code. They expose an API that serves repository metrics incuding repo size and frequency of clones etc that can be used to assess the environmental impacts of the project storage and distribution.

Specifically, the plugin should return the following:

value API endpoint Docs link
number of time the repo was clones curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/traffic/clones https://docs.github.com/en/rest/metrics/traffic?apiVersion=2022-11-28
repo size in kb curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/repos https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28

SoW

  • create plugin that returns the requested data from theGithub API
  • create in dedicated IF repository (not a builtin)
  • add plugin to Explorer

Acceptance criteria

  • The plugin retrieves size and clones data from the Github API. size should be converted from kb to GB for consistency with other IF plugins.

Note that the traffic metrics only extend back as far as the most recent four weeks. You can request the total for any of those weeks or the whole preceding month. I think the right way to handle this in IF is to offer two options: last week or last month.

GIVEN the plugin works as expected and I have a valid auth token in .env
WHEN I run the following manifest:

name: github demo
description:
tags:
initialize:
  plugins:
    github-plugin:
      method: GithubAPI
      path: github-api
      config:
        repo-name: Green-Software-Foundation/if
        time: 'week' # can be week or month
tree:
  children:
    github:
      pipeline:
        observe:
         - github-plugin
      config:
      defaults:
      inputs:
        - timestamp: 2023-08-06T00:00
          duration: 2419200

Then I get the following output (the last week's clones and the current repo size converted from kb to GB:

name: github demo
description:
tags:
initialize:
  plugins:
    github-plugin:
      method: GithubAPI
      path: github-api
      config:
        repo-name: Green-Software-Foundation/if
        time: 'week' # can be week or month
tree:
  children:
    github:
      pipeline:
        observe:
         - github-plugin
      config:
      defaults:
      inputs:
        - timestamp: 2023-08-06T00:00
          duration: 2419200
      outputs:
        - timestamp: 2023-08-06T00:00
          duration: 2419200
          size: 0.0017
          clones: 34
      

Note to be listed it has to meet some basic standards for documentation and repository structure.

@jmcook1186 jmcook1186 self-assigned this Jul 11, 2024
@jmcook1186 jmcook1186 added this to IF Jul 11, 2024
@jmcook1186 jmcook1186 moved this to In Refinement in IF Jul 11, 2024
@zanete zanete modified the milestones: Inputs and Outputs, Sci-Fi Day Jul 11, 2024
@zanete
Copy link

zanete commented Jul 11, 2024

@manushak please take a look through the AC to confirm you're happy with it

@manushak
Copy link
Contributor

yeah, it seems clear

@zanete zanete moved this from In Refinement to Blocked in IF Jul 12, 2024
@zanete zanete moved this from Blocked to Ready in IF Jul 12, 2024
@manushak manushak moved this from Ready to In Progress in IF Jul 16, 2024
@manushak
Copy link
Contributor

@jmcook1186 can you provide me the dedicated repo for this plugin (in SoW create in dedicated IF repository (not a builtin)) ?

@manushak
Copy link
Contributor

@jmcook1186 we can't get repo clones for a month; the maximum range is 14 days. According to the GitHub API:
Get the total number of clones and breakdown per day or week for the last 14 days. Timestamps are aligned to UTC midnight of the beginning of the day or week. Week begins on Monday.

We can skip the time property because we have duration and timestamp, unless these properties are not used. If the range exceeds 14 days, we can show data for 14 days and display a warning.

What do you think?

@jmcook1186
Copy link
Contributor Author

Hi @manushak

ok interesting - could we do 2 week max, but infer an actual time range from the timesteps and duration?

Making you a repo now.

@manushak
Copy link
Contributor

thanks @jmcook1186 for the repo
yeah, the logic that I've created is working like you mentioned.

@manushak manushak moved this from In Progress to Pending Review in IF Jul 18, 2024
@manushak manushak linked a pull request Jul 18, 2024 that will close this issue
@zanete zanete moved this from Pending Review to In Progress in IF Jul 22, 2024
@zanete zanete moved this from In Progress to Pending Review in IF Jul 23, 2024
@zanete zanete assigned jmcook1186 and jawache and unassigned jawache Jul 23, 2024
@zanete
Copy link

zanete commented Jul 24, 2024

Minor update required to update the IF core version if there are no new comments

@zanete zanete moved this from Pending Review to Testing in IF Jul 24, 2024
@github-project-automation github-project-automation bot moved this from Testing to Done in IF Jul 24, 2024
@zanete zanete moved this from Done to Blocked in IF Jul 30, 2024
@zanete zanete reopened this Jul 30, 2024
@zanete
Copy link

zanete commented Jul 30, 2024

Manifest examples need to be updated after phased execution release

@manushak manushak moved this from Blocked to Done in IF Aug 5, 2024
@zanete zanete closed this as completed Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants