GithubHelp home page GithubHelp logo

jstrieb / github-stats Goto Github PK

View Code? Open in Web Editor NEW
2.7K 9.0 580.0 2.05 MB

Better GitHub statistics images for your profile, with stats from private repos too

License: GNU General Public License v3.0

Python 100.00%
github-stats statistics profile visualizations github github-api github-actions git-scraping statistics-images stats-images

github-stats's Introduction

Generate visualizations of GitHub user and repository statistics with GitHub Actions. Visualizations can include data for both private repositories, and for repositories you have contributed to, but do not own.

Generated images automatically switch between GitHub light theme and GitHub dark theme.

Background

When someone views a profile on GitHub, it is often because they are curious about a user's open source projects and contributions. Unfortunately, that user's stars, forks, and pinned repositories do not necessarily reflect the contributions they make to private repositories. The data likewise does not present a complete picture of the user's total contributions beyond the current year.

This project aims to collect a variety of profile and repository statistics using the GitHub API. It then generates images that can be displayed in repository READMEs, or in a user's Profile README.

Since the project runs on GitHub Actions, no server is required to regularly regenerate the images with updated statistics. Likewise, since the user runs the analysis code themselves via GitHub Actions, they can use their GitHub access token to collect statistics on private repositories that an external service would be unable to access.

Disclaimer

If the project is used with an access token that has sufficient permissions to read private repositories, it may leak details about those repositories in error messages. For example, the aiohttp library—used for asynchronous API requests—may include the requested URL in exceptions, which can leak the name of private repositories. If there is an exception caused by aiohttp, this exception will be viewable in the Actions tab of the repository fork, and anyone may be able to see the name of one or more private repositories.

Due to some issues with the GitHub statistics API, there are some situations where it returns inaccurate results. Specifically, the repository view count statistics and total lines of code modified are probably somewhat inaccurate. Unexpectedly, these values will become more accurate over time as GitHub caches statistics for your repositories. Additionally, repositories that were last contributed to more than a year ago may not be included in the statistics due to limitations in the results returned by the API.

For more information on inaccuracies, see issue #2, #3, and #13.

Installation

  1. Create a personal access token (not the default GitHub Actions token) using the instructions here. Personal access token must have permissions: read:user and repo. Copy the access token when it is generated – if you lose it, you will have to regenerate the token.
    • Some users are reporting that it can take a few minutes for the personal access token to work. For more, see #30.
  2. Create a copy of this repository by clicking here. Note: this is not the same as forking a copy because it copies everything fresh, without the huge commit history.
  3. Go to the "Secrets" page of your copy of the repository. If this is the README of your copy, click this link to go to the "Secrets" page. Otherwise, go to the "Settings" tab of the newly-created repository and go to the "Secrets" page (bottom left).
  4. Create a new secret with the name ACCESS_TOKEN and paste the copied personal access token as the value.
  5. It is possible to change the type of statistics reported by adding other repository secrets.
    • To ignore certain repos, add them (in owner/name format e.g., jstrieb/github-stats) separated by commas to a new secret—created as before—called EXCLUDED.
    • To ignore certain languages, add them (separated by commas) to a new secret called EXCLUDED_LANGS. For example, to exclude HTML and TeX you could set the value to html,tex.
    • To show statistics only for "owned" repositories and not forks with contributions, add an environment variable (under the env header in the main workflow) called EXCLUDE_FORKED_REPOS with a value of true.
    • These other values are added as secrets by default to prevent leaking information about private repositories. If you're not worried about that, you can change the values directly in the Actions workflow itself.
  6. Go to the Actions Page and press "Run Workflow" on the right side of the screen to generate images for the first time.
    • The images will be automatically regenerated every 24 hours, but they can be regenerated manually by running the workflow this way.
  7. Take a look at the images that have been created in the generated folder.
  8. To add your statistics to your GitHub Profile README, copy and paste the following lines of code into your markdown content. Change the username value to your GitHub username.
    ![](https://raw.githubusercontent.com/username/github-stats/master/generated/overview.svg#gh-dark-mode-only)
    ![](https://raw.githubusercontent.com/username/github-stats/master/generated/overview.svg#gh-light-mode-only)
    ![](https://raw.githubusercontent.com/username/github-stats/master/generated/languages.svg#gh-dark-mode-only)
    ![](https://raw.githubusercontent.com/username/github-stats/master/generated/languages.svg#gh-light-mode-only)
  9. Link back to this repository so that others can generate their own statistics images.
  10. Star this repo if you like it!

Support the Project

There are a few things you can do to support the project:

  • Star the repository (and follow me on GitHub for more)
  • Share and upvote on sites like Twitter, Reddit, and Hacker News
  • Report any bugs, glitches, or errors that you find

These things motivate me to to keep sharing what I build, and they provide validation that my work is appreciated! They also help me improve the project. Thanks in advance!

If you are insistent on spending money to show your support, I encourage you to instead make a generous donation to one of the following organizations. By advocating for Internet freedoms, organizations like these help me to feel comfortable releasing work publicly on the Web.

Related Projects

github-stats's People

Contributors

erikw avatar idiotwu avatar josedefreitas avatar jstrieb avatar klodovsky avatar poetsec avatar rahul-jha98 avatar w3bdesign avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

github-stats's Issues

Inaccurate statistics

Hello 👋.

I followed all the steps stated in the readme file correctly. Added the correct perms, I clicked the links provided in both steps 2 and 3 and I named the secret correctly.
However, these are the generated images:


and

My fork

They do not match my actual stats whatsoever.
As I wrote, I've done all the steps correctly. I tried reloading the page and re-running the workflow, but the result was the same. I don't know if it's an issue with the API or I actually did something wrong...

Thank you in advance.

Let Actions Push To Another Branch

Currently, the GitHub actions will create a lot of commits on the master branch. I think using the following settings should make the history clean.

    # Commits all changed files to the repository
    - name: Commit to the repo
      run: |
        git config --global user.name "jstrieb/github-stats"
        git config --global user.email "github-stats[bot]@jstrieb.github.io"
        git branch -M generated
        git add .
        # "echo" returns true so the build succeeds, even if no changed files
        git commit -m 'Update generated files' || echo
        # <username> should be replaced
        git push -f https://<username>:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.git generated

Initial commit failed with Error: Process completed with exit code 128.

I followed the instructions in the README but the GitHub workflow failed. Here is some information.

My personal access token permissions

image

Step: generate images

Run python3 --version
Python 3.8.12
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned [20](https://github.com/tanjuntao/github-stats/runs/6331838497?check_suite_focus=true#step:6:20)2. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
A path returned 202. Retrying...
There were too many 202s. Data for this repository will be incomplete.

Step: commit to the repo

Run git config --global user.name "jstrieb/github-stats"
[master adc985c] Update generated files
 2 files changed, 33 insertions(+), [12](https://github.com/tanjuntao/github-stats/runs/6331838497?check_suite_focus=true#step:7:12)3 deletions(-)
remote: Permission to tanjuntao/github-stats.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/tanjuntao/github-stats/': The requested URL returned error: 403
Error: Process completed with exit code 128.

I don't get where the problem comes from, would you please provide some suggestions?

Too many stars ?

Hi,

I tried your repo, and the result tells me I have lots of stars & forks, it's a little bit unrealistic

Are you counting the starts of all repositories I contributed to ?

image

I think these are the correct values:

⭐    Total Stars:                            3,183
➕    Total Commits:                          2,512
📦    Contributed to:                            42

source
api requests

Failed to generate images

I followed the installation guide in README.md. I created a secret with the access token, even then it the log says access token is missing.

  python3 --version
  python3 generate_images.py
  shell: /usr/bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.8.8/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.8.8/x64/lib
    ACCESS_TOKEN: 
    GITHUB_TOKEN: ***
    EXCLUDED: 
    EXCLUDED_LANGS: 
    EXCLUDE_FORKED_REPOS: false
Python 3.8.8
Traceback (most recent call last):
  File "generate_images.py", line 119, in <module>
    asyncio.run(main())
  File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/opt/hostedtoolcache/Python/3.8.8/x64/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "generate_images.py", line 100, in main
    raise Exception("A personal access token is required to proceed!")
Exception: A personal access token is required to proceed!
Error: Process completed with exit code 1.

Overflow problem !

In small width devices some content of language.svg is overflowing. I was trying to fix it and if found the bug.

Problem:

foreignObject {
  width: calc(100% - 10px - 32px);
  height: calc(100% - 10px - 24px);
}

vivo-v5s-5 5-720 x 1280

Fix:

But without the height and width property everything is fine.

foreignObject {
}

dddd

Package as an action/separate codebase from generated images

At the moment this project has potential, but the suggested install process is a bit clunky because when I fork it, the code comes with your generated images. As soon as a user starts generating their own images and the histories diverge, it then it becomes potentially fiddly to pull in any changes or bugfixes from upstream into the forks.

If the action code were decoupled from your generated image history in a separate repo with an action.yml the "install" process for a new user could be more like: Create an empty repo and create a workflow:

name: Generate Images
on:
  schedule:
    - cron: '0 * * * *'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Generate Images
        uses: jstrieb/github-stats@master
        with:
          ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
          EXCLUDED: ${{ secrets.EXCLUDED }}

which would be much slicker as each user repo would only contain the user's own image history.

Bot Can't Commit

I have done everything you said on the tutorial but it seems like the bot cant have access to the repo...

image

Add: Dark Theme

It would be nice to have a dark theme like the tokyonight or dracula

Counting stars and forks from forks

Hi!

I just generated stats for my profile, and it resulted in the following:
image (the true file is located here)

The stats looks strange, because I counted and I don't know if I even have 10 stars, and it says I got more than 2000. Does the action count stars and forks including forks? I realize this might be a design decision, but I figured I might ask.

Anyway, congratz on the tool! It looks nice and it has valuable information such as repository views and all-time contributions.

How to show stats in Readme

My Images are generated in generated Folder but I don't know how to show them in read me file........Plz help me

aiohttp failed for rest query

Getting the following error during the Generate images step:

Run python3 --version
  python3 --version
  python3 generate_images.py
  shell: /usr/bin/bash -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.8.8/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.8.8/x64/lib
    ACCESS_TOKEN: ***
    GITHUB_TOKEN: ***
    EXCLUDED: 
    EXCLUDED_LANGS: 
    EXCLUDE_FORKED_REPOS: false
Python 3.8.8
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
There were too many 202s. Data for this repository will be incomplete.
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
There were too many 202s. Data for this repository will be incomplete.

Repository views stuck at 0

I've been using this template for a while now, and never have had any problem with how my repo views are displayed. However, since a recent manual run of the workflow, my repo views have been stuck at 0. I can't work out why this is, because this isn't an accurate number.
Any help would be appreciated.

Display all languages

I am a programming language collector. This may seem like a crazy question, but is there a way to display ALL languages in languages.svg instead of just the top 13? It seems to have picked up all the languages I wanted it to, they just don't all show, not even as other %
(yes, I know a lot of lag would be involved, I am just wondering if it is possible)

Explain EXCLUDED_LANGS casing or make it case-insensitive

The current implementation expects the languages to be in the same style as displayed on GitHub e.g.

  • HTML, not html
  • Ruby, not ruby

My first instict when I set up EXCLUDED_LANGS was to make something like html,tex. Not until reading the source code I saw that the code expects the exclude list to be using the same casing as GitHub has. Thus to exclude HTML and Tex files, we must write HTML,TeX.

I propose one of these:

  • We make the lookup case-insensitive i.e. normalize both each repo's languages and the user's set EXCLUDED_LANGS to lower-case.
    languages = await self.languages
    if name in self._exclude_langs:
  • If not, we should explain in the README that the EXCLUDED_LANGS should have languages as displayed in the generated image / as shown on the GitHub repo page

Ability to output a debug dump

Some days ago, a new language added in my languages.svg file.

The thing is, the only "link" I have with this language is that I recently viewed this repo, which is written in Zig: https://github.com/Jarred-Sumner/bun

I know that I can exclude this language (because I don't want to have it in my stats), but I'd be curious to have some logs or even enable some kind of debug dump file, to see where does this language comes from in my stats. What repo is responsible for adding this language in my stats.

I tried to run this template repo locally, but it generated empty images. Even when I set ACCESS_TOKEN and GITHUB_ACTOR as environment variables.

Java Code gets displayed as Kotlin and vice versa

As the title says, the extension counts all my Java code as Kotlin and vice versa. Initially, it did not create this issue (especially when I was coding on Java exclusively), but I started to do some Android Development stuff on Kotlin which messed it up.

Here's a screenshot from right now:

Here's a screenshot from an earlier commit:

I only have one repository in Kotlin, so the latter seems more correct (plus most of my code is still on Java).

Update cronjob schedule

Hi!

Nice work, but I believe running the github action every hour is a bit overkill. (Over 3000 commits on just generated image)
Maybe everyday or every month could be a bit more reasonable.

What do you think?

Still not so convenient

It still need to add this files to the repo, even to every repo so that the stats can be updated.

But it's possible to checkout another user's repo in GitHub Action...why not just checkout this repo and use the python source files inside?

Decreased lines of code changed

I don't know why this is happening to me. Whenever there is a new commit, something gets reduced.
Screenshot_20210831-070108
As in the above image the changed lines of code have been reduced.

https://api.github.com/

well i got a problem while runing this code it just gave me the error: "A path returned 202" so i looked at the code and where the error was and at the github docs about the api so i added the term "/{owner}/" between the url and what it was requesting what fixed my error (after i set the variable "owner")
(bc i have no clue how to make pull request or whatever i just added it as a issue)

Commit doesn't work

I followed the readme for the installation and it does work. but once the workflow tries to update, it doesn't work this is the error and i don't really have an idea how i could fix it.

Run git config --global user.name "jstrieb/github-stats"
[master 0b12a96] Update generated files
 2 files changed, 34 insertions(+), 115 deletions(-)
To https://github.com/yvarim/github-stats
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/yvarim/github-stats'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Error: Process completed with exit code 1.

Action fails to run

Github action started failing after no changes to repo or access token.
Output below:

Traceback (most recent call last):
  File "generate_images.py", line 61, in generate_languages
    sorted_languages = sorted((await s.languages).items(), reverse=True,
  File "/home/runner/work/github-stats/github-stats/github_stats.py", line 385, in languages
    await self.get_stats()
  File "/home/runner/work/github-stats/github-stats/github_stats.py", line 308, in get_stats
    name = repo.get("nameWithOwner")
AttributeError: 'NoneType' object has no attribute 'get'
Traceback (most recent call last):
  File "generate_images.py", line 108, in <module>
    asyncio.run(main())
  File "/opt/hostedtoolcache/Python/3.8.6/x64/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/opt/hostedtoolcache/Python/3.8.6/x64/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "generate_images.py", line 104, in main
    await asyncio.gather(generate_languages(s), generate_overview(s))
  File "generate_images.py", line 36, in generate_overview
    output = re.sub("{{ name }}", await s.name, output)
  File "/home/runner/work/github-stats/github-stats/github_stats.py", line 352, in name
    await self.get_stats()
  File "/home/runner/work/github-stats/github-stats/github_stats.py", line 308, in get_stats
    name = repo.get("nameWithOwner")
AttributeError: 'NoneType' object has no attribute 'get'
Error: Process completed with exit code 1.

Allow to exclude some languages

Languages like "HTML" or "Jupyter Notebook" sometimes should not be shown in the stats because a notebook file may be very heavy. Anyway, I think there are folks who just want to hide some languages. Perhaps we can add a line to github_stats.py like this.

No name's github stats

I am trying to implement the stats on readme. I have created all the files and folders and yaml file but I am getting No name's github stats and no stats. I am an attaching the image for reference:

Screenshot 2022-07-06 at 2 58 34 PM

This is my main.yml file:

# This is a basic workflow to help you get started with Actions

name: Generate Stats Images

# Controls when the action will run. Triggers the workflow on push events
on:
  push:
  schedule:
    - cron: "0 0 * * *"
  workflow_dispatch:

permissions:
  contents: write

# A workflow run is made up of one or more jobs that can run sequentially or in
# parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Sequence of tasks that will be executed as part of the job
    steps:
    # Checks-out repository under $GITHUB_WORKSPACE, so the job can access it
    - uses: actions/checkout@v2

    # Run using Python 3.8 for consistency and aiohttp
    - name: Set up Python 3.8
      uses: actions/setup-python@v2
      with:
        python-version: '3.8'
        architecture: 'x64'

    # Cache dependencies. From:
    # https://github.com/actions/cache/blob/master/examples.md#python---pip
    - uses: actions/cache@v2
      with:
        path: ~/.cache/pip
        key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
        restore-keys: |
          ${{ runner.os }}-pip-


    # Install dependencies with `pip`
    - name: Install requirements
      run: |
        python3 -m pip install --upgrade pip setuptools wheel
        python3 -m pip install -r requirements.txt

    - name: Generate images
      run: |
        python3 --version
        python3 generate_images.py
      env:
        ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
        GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
        EXCLUDE_FORKED_REPOS: true

    # Commits all changed files to the repository
    - name: Commit to the output branch of repo
      run: |
        git config --global user.name "reveurguy"
        git config --global user.email "[email protected]"
        git add .
        git commit -m 'temp commit' || echo
        git checkout output1 2>/dev/null || git checkout --orphan output1 && git rm -rf . && git checkout master -- generated/
        # "echo" returns true so the build succeeds, even if no changed files
        git commit -m 'Update generated files' || echo
        git push origin output1 -f

Error generating images

I've forked the repo into my own repo here and I've done all the setup steps. The Generate images actions step fails. The log contains hundreds of lines that say A path returned 202. Retrying..., and the following error:

Traceback (most recent call last):
  File "generate_images.py", line 105, in <module>
    asyncio.run(main())
  File "/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "generate_images.py", line 101, in main
    await asyncio.gather(generate_languages(s), generate_overview(s))
  File "generate_images.py", line 41, in generate_overview
    changed = (await s.lines_changed)[0] + (await s.lines_changed)[1]
  File "/home/runner/work/github-stats/github-stats/github_stats.py", line 437, in lines_changed
    author = author_obj.get("author", {}).get("login", "")
AttributeError: 'str' object has no attribute 'get'

Builds failing - REST API returning 202 and never 200.

Queries erroring with code 202.

When the Action to generate images is run, it sits endlessly and keeps throwing out "A path returned 202. Retrying..." and "There were too many 202s. Data for this repository will be incomplete.".

I suspect this might be a side effect of the changes to the OAuth API, as shown here: https://www.githubstatus.com/incidents/6gpzw3mdnkwj
Status on the API itself seems fine.

I have checked in multiple of the forked repos and have seen the same issue occurring, after spending ages trying to figure out if it was mine 😂

Stats don't account for "old" contributions

The query used to get the users contributions apparently only includes repositories to which the user has recently contributed to.

{
  viewer {
    repositoriesContributedTo(first: 100, includeUserRepositories: false, contributionTypes: [COMMIT, PULL_REQUEST, REPOSITORY, PULL_REQUEST_REVIEW]) {
      nodes {
        nameWithOwner
      }
    }
  }
}

Tested via https://docs.github.com/en/free-pro-team@latest/graphql/overview/explorer

It appears that older contributions have to be queried seperately somehow, for example by scraping the users profile, by abusing the search api or via third party tools such as BigQuery: https://stackoverflow.com/a/63427144

Failed to commit to repo

Workflow action fails after making a commit.

Link to failed action log:
https://github.com/yooksi/github-stats/runs/1885488408?check_suite_focus=true#step:7:1

 [master 2e497c2] Update generated files
 2 files changed, 33 insertions(+), 51 deletions(-)
To https://github.com/yooksi/github-stats
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/yooksi/github-stats'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Error: Process completed with exit code 1.

Adding Stats Contents

Hello, is it possible to add more stats contents such as Issues and Pull Requests? Thank you

Action Not Run

How Tu Run Action ?

I've been added my ACCES_TOKEN in Secret , but i don't know how to run it

I've been already commit a simple message

But Nothiing

image

Add instructions on how to update copy of template

It's nice to be up to date with the latest development in this main repo. For example I would like to get recently merged #65 in to my own copy of this repo.

As we create copies from this template repo instead of a fork, it's a bit more tricky to make the update. Are there already some instructions on how this can be done?

I did the following to update my own copy. There are for sure easier and better ways, but it did the job for me now.

In my copy of this repo at the master branch:

git remote add template [email protected]:jstrieb/github-stats.git
git fetch template

# Remove all bot commits to make my git history cleaner. Maybe not necessary?
# Reference: https://stackoverflow.com/a/8058619/265508
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --commit-filter '
    if [ "$GIT_AUTHOR_EMAIL" = "[email protected]:jstrieb/github-stats.git" ];
    then
            skip_commit "$@";
    else
            git commit-tree "$@";
    fi' HEAD

# Squash merge upstream changes in to 1 new commit.
git merge -Xtheirs --squash --allow-unrelated-histories template/master
git commit -m "Update from template"
git push -f origin master

I think we should add some instructions to the README on how people can keep their copies up to date with this repo :). If it involves a few shell commands, ideally they should be directly copy-and-pasteable for ultimate user convenience.

Relevant discussion on SO:
https://stackoverflow.com/questions/56577184/github-pull-changes-from-a-template-repository#56577320

Shouldn't the env variable be "EXCLUDED_LANGS"?

Hello 👋.

I'm opening this issue because I have some problems while adding excluded languages to my fork's secrets. I added them just as the instruction says; however, when I ran the workflow, the languages.svg file didn't get updated, but the overview.svg did. I was reading the code while I noticed that in the main.yml file, at line 57 it says "EXCLUDED_LANGS: ${{ secrets.EXCLUDE_LANGS }}". In the README file at the point 5 it says that if you want to exclude languages you need to create a secret called EXCLUDED_LANGS. I'm not experienced in GitHub Actions, but I guess secrets.EXCLUDE_LANGS should match the name of the secret (which, according to the README should be EXLUDED_LANGS (with that "D" at the end)). I was about to open a PR but as I'm not sure if that's the case I preferred to open an issue 😅.

Inaccurate stars by github copilot repo

Hi!

I found this repo a while ago and am trying it out.
Most of it works fine 👍, but there was a problem with my Star count being excessively high.
(EXCLUDE_FORKED_REPOS option is true)

capture

Referring to issue #18 , when I ran it locally, the copilot repo(github/copilot-preview) was included in the statistics.

I added this to EXCLUDED and it now looks fine.
I haven't contributed to the copilot repo, but it seems to be included as part of a private repo. (maybe?🤔)

I'm not sure if it's a bug or not. However, I'm leaving this as an issue as there may be other users who may have the same problem.

Thanks for making a nice project!

Generate images error

Getting this error:

Run python3 --version
Python 3.8.5
Traceback (most recent call last):
  File "generate_images.py", line 105, in <module>
    asyncio.run(main())
  File "/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "generate_images.py", line 101, in main
    await asyncio.gather(generate_languages(s), generate_overview(s))
  File "generate_images.py", line 41, in generate_overview
    changed = (await s.lines_changed)[0] + (await s.lines_changed)[1]
  File "/home/runner/work/github-stats/github-stats/github_stats.py", line 435, in lines_changed
    r = await self.queries.query_rest(f"/repos/{repo}/stats/contributors")
  File "/home/runner/work/github-stats/github-stats/github_stats.py", line 93, in query_rest
    return r.json()
  File "/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/hostedtoolcache/Python/3.8.5/x64/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
##[error]Process completed with exit code 1.

Try to generate images but languages.svg doesn't generate [Error 202]

I get this error message in the "generate" stage:

Python 3.8.12
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
There were too many 202s. Data for this repository will be incomplete.
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
There were too many 202s. Data for this repository will be incomplete.
A path returned 202. Retrying...
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
There were too many 202s. Data for this repository will be incomplete.
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
There were too many 202s. Data for this repository will be incomplete.
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
aiohttp failed for rest query
There were too many 202s. Data for this repository will be incomplete.

AssertionError assert(self._name is not None)

Hello. I tried forking this and I'm getting builds failing with

Python 3.8.6
Traceback (most recent call last):
  File "generate_images.py", line 107, in <module>
    asyncio.run(main())
  File "/opt/hostedtoolcache/Python/3.8.6/x64/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/opt/hostedtoolcache/Python/3.8.6/x64/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "generate_images.py", line 103, in main
    await asyncio.gather(generate_languages(s), generate_overview(s))
  File "generate_images.py", line 36, in generate_overview
    output = re.sub("{{ name }}", await s.name, output)
  File "/home/runner/work/github-stats/github-stats/github_stats.py", line 347, in name
    assert(self._name is not None)
AssertionError

Error: Process completed with exit code 1.

example https://github.com/chris48s/github-stats/runs/1250004507

Any thoughts on what may be going wrong? I had a look through a few other forks and I haven't spotted anyone else with the same issue.

Issues opened stat

It would be great to have a statistic that shows how much issues a user has opened.
Due to the support nature of issues such contributions usually get overlooked, but are actually quite important.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.