Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 933c15c

Browse files
authored
Merge branch 'master' into feat-translation-fr-people
2 parents bed1301 + 5da5ae5 commit 933c15c

229 files changed

Lines changed: 18200 additions & 1719 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
blank_issues_enabled: false

.github/actions/get-artifact/Dockerfile renamed to .github/actions/comment-docs-preview-in-pr/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM python:3.7
22

3-
RUN pip install httpx "pydantic==1.5.1"
3+
RUN pip install httpx "pydantic==1.5.1" pygithub
44

55
COPY ./app /app
66

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Comment Docs Preview in PR
2+
description: Comment with the docs URL preview in the PR
3+
author: Sebastián Ramírez <[email protected]>
4+
inputs:
5+
token:
6+
description: Token for the repo. Can be passed in using {{ secrets.GITHUB_TOKEN }}
7+
required: true
8+
deploy_url:
9+
description: The deployment URL to comment in the PR
10+
required: true
11+
runs:
12+
using: docker
13+
image: Dockerfile
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import logging
2+
import sys
3+
from pathlib import Path
4+
from typing import Optional
5+
6+
import httpx
7+
from github import Github
8+
from github.PullRequest import PullRequest
9+
from pydantic import BaseModel, BaseSettings, SecretStr, ValidationError
10+
11+
github_api = "https://api.github.com"
12+
13+
14+
class Settings(BaseSettings):
15+
github_repository: str
16+
github_event_path: Path
17+
github_event_name: Optional[str] = None
18+
input_token: SecretStr
19+
input_deploy_url: str
20+
21+
22+
class PartialGithubEventHeadCommit(BaseModel):
23+
id: str
24+
25+
26+
class PartialGithubEventWorkflowRun(BaseModel):
27+
head_commit: PartialGithubEventHeadCommit
28+
29+
30+
class PartialGithubEvent(BaseModel):
31+
workflow_run: PartialGithubEventWorkflowRun
32+
33+
34+
if __name__ == "__main__":
35+
logging.basicConfig(level=logging.INFO)
36+
settings = Settings()
37+
logging.info(f"Using config: {settings.json()}")
38+
g = Github(settings.input_token.get_secret_value())
39+
repo = g.get_repo(settings.github_repository)
40+
try:
41+
event = PartialGithubEvent.parse_file(settings.github_event_path)
42+
except ValidationError as e:
43+
logging.error(f"Error parsing event file: {e.errors()}")
44+
sys.exit(0)
45+
use_pr: Optional[PullRequest] = None
46+
for pr in repo.get_pulls():
47+
if pr.head.sha == event.workflow_run.head_commit.id:
48+
use_pr = pr
49+
break
50+
if not use_pr:
51+
logging.error(
52+
f"No PR found for hash: {event.workflow_run.head_commit.id}"
53+
)
54+
sys.exit(0)
55+
github_headers = {
56+
"Authorization": f"token {settings.input_token.get_secret_value()}"
57+
}
58+
url = f"{github_api}/repos/{settings.github_repository}/issues/{use_pr.number}/comments"
59+
logging.info(f"Using comments URL: {url}")
60+
response = httpx.post(
61+
url,
62+
headers=github_headers,
63+
json={
64+
"body": f"📝 Docs preview for commit {use_pr.head.sha} at: {settings.input_deploy_url}"
65+
},
66+
)
67+
if not (200 <= response.status_code <= 300):
68+
logging.error(f"Error posting comment: {response.text}")
69+
sys.exit(1)
70+
logging.info("Finished")

.github/actions/get-artifact/action.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/actions/get-artifact/app/main.py

Lines changed: 0 additions & 63 deletions
This file was deleted.

.github/actions/people/app/main.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import logging
22
import subprocess
33
import sys
4-
from collections import Counter
4+
from collections import Counter, defaultdict
55
from datetime import datetime, timedelta, timezone
66
from pathlib import Path
7-
from typing import Container, Dict, List, Optional, Set
7+
from typing import Container, DefaultDict, Dict, List, Optional, Set
88

99
import httpx
1010
import yaml
@@ -375,7 +375,7 @@ def get_contributors(settings: Settings):
375375
return contributors, commentors, reviewers, authors
376376

377377

378-
def get_sponsors(settings: Settings):
378+
def get_individual_sponsors(settings: Settings):
379379
nodes: List[SponsorshipAsMaintainerNode] = []
380380
edges = get_graphql_sponsor_edges(settings=settings)
381381

@@ -385,10 +385,12 @@ def get_sponsors(settings: Settings):
385385
last_edge = edges[-1]
386386
edges = get_graphql_sponsor_edges(settings=settings, after=last_edge.cursor)
387387

388-
entities: Dict[str, SponsorEntity] = {}
388+
tiers: DefaultDict[float, Dict[str, SponsorEntity]] = defaultdict(dict)
389389
for node in nodes:
390-
entities[node.sponsorEntity.login] = node.sponsorEntity
391-
return entities
390+
tiers[node.tier.monthlyPriceInDollars][
391+
node.sponsorEntity.login
392+
] = node.sponsorEntity
393+
return tiers
392394

393395

394396
def get_top_users(
@@ -473,19 +475,30 @@ def get_top_users(
473475
skip_users=skip_users,
474476
)
475477

476-
sponsors_by_login = get_sponsors(settings=settings)
477-
sponsors = []
478-
for login, sponsor in sponsors_by_login.items():
479-
sponsors.append(
478+
tiers = get_individual_sponsors(settings=settings)
479+
sponsors_50 = []
480+
for login, sponsor in tiers[50].items():
481+
sponsors_50.append(
480482
{"login": login, "avatarUrl": sponsor.avatarUrl, "url": sponsor.url}
481483
)
484+
keys = list(tiers.keys())
485+
keys.sort(reverse=True)
486+
sponsors = []
487+
for key in keys:
488+
if key >= 50:
489+
continue
490+
for login, sponsor in tiers[key].items():
491+
sponsors.append(
492+
{"login": login, "avatarUrl": sponsor.avatarUrl, "url": sponsor.url}
493+
)
482494

483495
people = {
484496
"maintainers": maintainers,
485497
"experts": experts,
486498
"last_month_active": last_month_active,
487499
"top_contributors": top_contributors,
488500
"top_reviewers": top_reviewers,
501+
"sponsors_50": sponsors_50,
489502
"sponsors": sponsors,
490503
}
491504
people_path = Path("./docs/en/data/people.yml")

.github/workflows/build-docs.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ jobs:
2020
run: python3.7 -m pip install flit
2121
- name: Install docs extras
2222
run: python3.7 -m flit install --extras doc
23+
- name: Install Material for MkDocs Insiders
24+
if: github.event.pull_request.head.repo.fork == false
25+
run: pip install git+https://${{ secrets.ACTIONS_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git
2326
- name: Build Docs
2427
run: python3.7 ./scripts/docs.py build-all
2528
- name: Zip docs
26-
if: github.event_name == 'pull_request'
2729
run: bash ./scripts/zip-docs.sh
2830
- uses: actions/upload-artifact@v2
29-
if: github.event_name == 'pull_request'
3031
with:
31-
name: docs-zip-${{ github.event.pull_request.head.sha }}
32+
name: docs-zip
3233
path: ./docs.zip
3334
- name: Deploy to Netlify
3435
uses: nwtgck/[email protected]

.github/workflows/preview-docs.yml

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
name: Preview Docs
22
on:
3-
workflow_dispatch:
4-
inputs:
5-
pr:
6-
description: Pull Request number
7-
required: true
8-
name:
9-
description: Artifact name for zip file with docs
10-
required: true
11-
commit:
12-
description: Commit SHA hash
13-
required: true
3+
workflow_run:
4+
workflows:
5+
- Build Docs
6+
types:
7+
- completed
148

159
jobs:
1610
deploy:
17-
runs-on: ubuntu-18.04
11+
runs-on: ubuntu-latest
1812
steps:
1913
- uses: actions/checkout@v2
20-
- uses: ./.github/actions/get-artifact
14+
- name: Download Artifact Docs
15+
uses: dawidd6/[email protected]
2116
with:
22-
token: ${{ secrets.GITHUB_TOKEN }}
23-
name: ${{ github.event.inputs.name }}
24-
path: ./archive.zip
17+
github_token: ${{ secrets.GITHUB_TOKEN }}
18+
workflow: build-docs.yml
19+
run_id: ${{ github.event.workflow_run.id }}
20+
name: docs-zip
2521
- name: Unzip docs
26-
run: bash ./scripts/unzip-docs.sh
22+
run: |
23+
rm -rf ./site
24+
unzip docs.zip
25+
rm -f docs.zip
2726
- name: Deploy to Netlify
2827
id: netlify
2928
uses: nwtgck/[email protected]
@@ -36,9 +35,7 @@ jobs:
3635
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
3736
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
3837
- name: Comment Deploy
39-
env:
40-
PR: "${{ github.event.inputs.pr }}"
41-
DEPLOY_URL: "${{ steps.netlify.outputs.deploy-url }}"
42-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
43-
COMMIT: "${{ github.event.inputs.commit }}"
44-
run: bash ./scripts/docs-comment-deploy.sh
38+
uses: ./.github/actions/comment-docs-preview-in-pr
39+
with:
40+
token: ${{ secrets.GITHUB_TOKEN }}
41+
deploy_url: "${{ steps.netlify.outputs.deploy-url }}"

.github/workflows/watch-docs-previews.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)