Skip to content

feat: automation with github action #102

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

Merged
merged 2 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: build

on:
pull_request:
branches:
- "3.7"
- "3.8"
- "3.9"

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install Dependencies
run: sudo apt-get install gettext

- name: Build
run: VERSION=${{ github.event.pull_request.base.ref }} make
26 changes: 26 additions & 0 deletions .github/workflows/deploy-gh-page.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: deploy-gh-page

on:
push:
branches:
- "3.9"

jobs:
cd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install Dependencies
run: sudo apt-get install gettext

- name: Build
run: make

- name: Deploy to gh page
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: ../cpython/Doc/build/html
CLEAN: true
52 changes: 52 additions & 0 deletions .github/workflows/py39-sync-cpython.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: python-3.9-sync-with-cpython

on:
push:
branches:
- "3.9"
schedule:
- cron: "0 0 * * *"

jobs:
sync:
runs-on: ubuntu-latest
env:
VERSION: "3.9"
steps:
- uses: actions/checkout@v2
with:
ref: ${{ env.VERSION }}

- name: Set env
run: echo "LATEST_COMMIT_ID=$(git ls-remote https://github.com/python/CPython.git $VERSION | head -c 8)" >> $GITHUB_ENV

- name: Install Dependencies
run: sudo apt-get install gettext

- name: Sync with CPython
run: make clone && make merge && make rm_cpython

- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
with:
commit-message: sync with cpython ${{ env.LATEST_COMMIT_ID }}
committer: GitHub <noreply@github.com>
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
base: ${{ env.VERSION }}
branch: cron/sync/${{ env.VERSION }}
delete-branch: true
title: 'Sync with CPython ${{ env.VERSION }}'
body: |
Sync with CPython ${{ env.VERSION }}
labels: |
sync-cpython
automation
team-reviewers: |
owners
maintainers

- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ LC_MESSAGES := $(CPYTHON_CLONE)/Doc/locales/$(LANGUAGE)/LC_MESSAGES
VENV := ~/.venvs/python-docs-i18n/
PYTHON := $(shell which python3)
MODE := autobuild-dev-html
BRANCH = $(shell git describe --contains --all HEAD)
BRANCH := $(or $(VERSION), $(shell git describe --contains --all HEAD))
Copy link
Collaborator Author

@mattwang44 mattwang44 Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this change, make commands would fail if run on branches other than 3.7, 3.8, 3.9 etc. It allows users to run Makefile commands on branches with customized name by inserting an argument named VERSION.

VERSION=3.9 make

JOBS = 1


.PHONY: all
all: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb $(SPHINX_CONF)
all: $(VENV)/bin/sphinx-build $(VENV)/bin/blurb clone
mkdir -p $(LC_MESSAGES)
for dirname in $$(find . -name '*.po' | xargs -n1 dirname | sort -u | grep -v '^\.$$'); do mkdir -p $(LC_MESSAGES)/$$dirname; done
for file in *.po */*.po; do ln -f $$file $(LC_MESSAGES)/$$file; done
. $(VENV)/bin/activate; $(MAKE) -C $(CPYTHON_CLONE)/Doc/ SPHINXOPTS='-j$(JOBS) -D locale_dirs=locales -D language=$(LANGUAGE) -D gettext_compact=0' $(MODE)


$(SPHINX_CONF):
git clone --depth 1 --no-single-branch https://github.com/python/cpython.git $(CPYTHON_CLONE)
clone:
git clone --depth 1 --no-single-branch https://github.com/python/cpython.git $(CPYTHON_CLONE) || echo "cpython exists"
cd $(CPYTHON_CLONE) && git checkout $(BRANCH)


Expand Down Expand Up @@ -104,3 +104,7 @@ update_txconfig:
.PHONY: fuzzy
fuzzy:
for file in *.po */*.po; do echo $$(msgattrib --only-fuzzy --no-obsolete "$$file" | grep -c '#, fuzzy') $$file; done | grep -v ^0 | sort -gr

.PHONY: rm_cpython
rm_cpython:
rm -rf $(CPYTHON_CLONE)