Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into mm
Browse files Browse the repository at this point in the history
Signed-off-by: ashing <[email protected]>
  • Loading branch information
ronething committed Sep 6, 2023
2 parents 868f693 + f8cec5f commit d103915
Show file tree
Hide file tree
Showing 28 changed files with 1,757 additions and 3,282 deletions.
41 changes: 26 additions & 15 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
INPUT_WAKATIME_API_KEY=""
INPUT_SHOW_TIMEZONE="True"
INPUT_SHOW_PROJECTS="False"
INPUT_SHOW_EDITORS="False"
INPUT_SHOW_OS="False"
INPUT_SHOW_LANGUAGE="False"
INPUT_GH_TOKEN=""
INPUT_SYMBOL_VERSION="1"
INPUT_SHOW_LINES_OF_CODE="False"
INPUT_SHOW_LOC_CHART="False"
INPUT_SHOW_PROFILE_VIEWS="False"
INPUT_SHOW_TOTAL_CODE_TIME="True"
INPUT_SHOW_SHORT_INFO="False"
INPUT_SHOW_COMMIT="False"
INPUT_SHOW_DAYS_OF_WEEK="True"
INPUT_WAKATIME_API_KEY=YOUR_WAKATIME_API_KEY
INPUT_GH_TOKEN=YOUR_GITHUB_TOKEN_KEY
INPUT_PUSH_BRANCH_NAME=main
INPUT_PULL_BRANCH_NAME=main
INPUT_SECTION_NAME=waka
INPUT_SHOW_TIMEZONE=True
INPUT_SHOW_PROJECTS=True
INPUT_SHOW_EDITORS=True
INPUT_SHOW_OS=True
INPUT_SHOW_LANGUAGE=True
INPUT_SYMBOL_VERSION=1
INPUT_SHOW_LINES_OF_CODE=True
INPUT_SHOW_LOC_CHART=True
INPUT_SHOW_PROFILE_VIEWS=True
INPUT_SHOW_TOTAL_CODE_TIME=True
INPUT_SHOW_SHORT_INFO=True
INPUT_SHOW_COMMIT=True
INPUT_SHOW_DAYS_OF_WEEK=True
INPUT_SHOW_LANGUAGE_PER_REPO=True
INPUT_SHOW_UPDATED_DATE=True
INPUT_UPDATED_DATE_FORMAT=%d/%m/%Y %H:%M:%S
INPUT_COMMIT_BY_ME=True
INPUT_COMMIT_MESSAGE=Updated with Dev Metrics
INPUT_COMMIT_SINGLE=True
INPUT_DEBUG_LOGGING=True
DEBUG_RUN=True
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 99
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 99
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 99
46 changes: 46 additions & 0 deletions .github/workflows/build_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: PUBLISH_IMAGE

on:
push:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
publish-server-image:
name: Publish 'waka-readme-stats' image
runs-on: ubuntu-latest

steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Set up Docker Buildx 🐋
uses: docker/setup-buildx-action@v2

- name: Log in to the container registry 🚪
uses: docker/login-action@v2
with:
username: wakareadmestats
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker 🏋️
id: meta
uses: docker/metadata-action@v4
with:
images: wakareadmestats/waka-readme-stats
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker image 🏗️
uses: docker/build-push-action@v4
with:
push: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/releases') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
84 changes: 84 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI

on:
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
ci:
name: Run Test and Review PR
runs-on: ubuntu-latest

steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Setup Python 3.11 🐍
uses: actions/setup-python@v4
with:
python-version: 3.11
cache: 'pip'

- name: Install Dependencies 📥
run: pip install -r requirements.txt

- name: Create Assets Folder 📥
run: mkdir assets

- name: Create Previous Comments 🫣
uses: int128/hide-comment-action@v1
with:
starts-with: "README stats current output:"

- name: Run Action Preview on Current Code 🧪
id: make-stats
env:
INPUT_GH_TOKEN: ${{ secrets.INPUT_GITHUB_TOKEN }}
INPUT_WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
INPUT_SHOW_TIMEZONE: True
INPUT_SHOW_PROJECTS: True
INPUT_SHOW_EDITORS: True
INPUT_SHOW_OS: True
INPUT_SHOW_LANGUAGE: True
INPUT_SYMBOL_VERSION: 1
INPUT_SHOW_LINES_OF_CODE: True
INPUT_SHOW_LOC_CHART: True
INPUT_SHOW_PROFILE_VIEWS: True
INPUT_SHOW_TOTAL_CODE_TIME: True
INPUT_SHOW_SHORT_INFO: True
INPUT_SHOW_COMMIT: True
INPUT_SHOW_DAYS_OF_WEEK: True
INPUT_SHOW_LANGUAGE_PER_REPO: True
INPUT_SHOW_UPDATED_DATE: True
INPUT_COMMIT_BY_ME: True
INPUT_DEBUG_LOGGING: True # Not for prod
DEBUG_RUN: True # Not for prod
run: python3 sources/main.py

- name: Save Branch Name Without Slashes 📛
if: ${{ github.ref != 'refs/heads/master' }}
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
BRANCH_NAME=${{ env.BRANCH_NAME }}
BRANCH_NAME=${BRANCH_NAME////_}
echo BRANCH_NAME=${BRANCH_NAME} >> $GITHUB_ENV
- name: Upload Artifact 📦
uses: actions/upload-artifact@v3
if: ${{ github.ref != 'refs/heads/master' }}
with:
name: ${{ format('github-pages-for-branch-{0}', env.BRANCH_NAME) }}
path: assets

- name: Create Comment 💬
uses: jungwinter/comment@v1
with:
type: create
body: ${{ steps.make-stats.outputs.README_CONTENT }}
issue_number: ${{ github.event.number }}
token: ${{ secrets.GITHUB_TOKEN }}
56 changes: 56 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CodeQL

on:
push:
branches: master
pull_request:
workflow_dispatch:
schedule:
- cron: '30 13 * * 6'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]

steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Setup Python 3.11 🐍
uses: actions/setup-python@v4
with:
python-version: 3.11
cache: 'pip'

- name: Install dependencies 📥
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV
- name: Initialize CodeQL 🧑‍💻
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: security-and-quality
setup-python-dependencies: false

- name: Perform CodeQL Analysis 📈
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
24 changes: 24 additions & 0 deletions .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CODESTYLE

on:
push:

jobs:
lint:
name: Run codestyle check
runs-on: ubuntu-latest

steps:
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Setup Python 3.11 🐍
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install Dependencies 📥
run: pip install -r requirements.txt

- name: Run Codestyle ✔️
run: flake8 --max-line-length=160 --exclude venv,assets . && black --line-length=160 --check --exclude='/venv/|/assets/' .
19 changes: 19 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Dependency review
on: pull_request

permissions:
contents: read
pull-requests: write

jobs:
dependency-review:
runs-on: ubuntu-latest

steps:
- name: Checkout repository 🛎️
uses: actions/checkout@v3

- name: Dependency review 👀
uses: actions/dependency-review-action@v3
with:
comment-summary-in-pr: true
16 changes: 14 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Environment files:
*.env
*.png
node_modules/

# Generated graph images:
assets/

# Cloned repo path:
repo/

# Library roots:
venv/

# Python caches:
__pycache__/

# IDE configuration files:
.vscode
.idea
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Once you've worked on your feature/bugfix etc, you can open a pull request using

### Setting up development environment

This project is written in Python, requires **Python 3.6 or higher**, and uses `pip` .
This project is written in Python, requires **Python 3.8 or higher**, and uses `pip` .

To set it up, just fork + clone it, install all the dependencies:

Expand Down
25 changes: 11 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
FROM nikolaik/python-nodejs:python3.9-nodejs16
FROM python:3.11-alpine

ADD requirements.txt /requirements.txt
ADD main.py /main.py
ADD loc.py /loc.py
ADD make_bar_graph.py /make_bar_graph.py
ADD colors.json /colors.json
ADD translation.json /translation.json
ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1

ENV PATH "$PATH:/home/root/.npm-global/bin"
RUN mkdir -p /waka-readme-stats/assets

RUN python -m pip install --upgrade pip wheel setuptools
RUN pip install -r requirements.txt
RUN npm -g config set user root
RUN npm i -g npm@latest
RUN npm i -g vega vega-lite vega-cli canvas
ADD requirements.txt /waka-readme-stats/requirements.txt
RUN apk add --no-cache g++ jpeg-dev zlib-dev libjpeg make git && pip3 install -r /waka-readme-stats/requirements.txt

ENTRYPOINT ["python", "/main.py"]
RUN git config --global user.name "readme-bot"
RUN git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"

ADD sources/* /waka-readme-stats/
ENTRYPOINT cd /waka-readme-stats/ && python3 main.py
Loading

0 comments on commit d103915

Please sign in to comment.