Skip to content

New CI #64

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 30 commits into from
Dec 5, 2022
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
85 changes: 60 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,75 @@
name: Build
name: Tests

on:
push:
branches:
- "**"
- '*.*'
pull_request:

env:
CPYTHON_BRANCH: "3.10"
LANGUAGE: "tr"
branches:
- '*.*'

jobs:
test:
name: Build
checks:
strategy:
matrix:
tool:
- name: sphinx-lint
package: sphinx-lint
command: 'sphinx-lint --enable default-role --ignore .git'
- name: Line length
command: 'awk ''{if (length($0) > 80 && length(gensub(/[^ ]/, "", "g")) > 1) {print FILENAME ":" FNR, "line too long:", $0; ERRORS+=1}} END {if (ERRORS>0) {exit 1}}'' $CHANGED_PO_FILES'

name: ${{ matrix.tool.name }} (${{ matrix.tool.package }})
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set Up Python ${{ env.CPYTHON_BRANCH }}
uses: actions/setup-python@v4
- uses: lots0logs/gh-action-get-changed-files@2.1.4
id: changed_files
with:
python-version: "${{ env.CPYTHON_BRANCH }}"
- name: Get CPython
run: |
git clone https://github.com/python/cpython.git ../cpython --branch=${{ env.CPYTHON_BRANCH }}

- name: Install dependencies
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install ${{ matrix.tool.package }}
run: |
sudo apt update
sudo apt install -y gettext
python -m pip install -r requirements.txt
python -m pip install -r ../cpython/Doc/requirements.txt

- name: Sphinx lint
if [ -n "${{ matrix.tool.apt_dependencies }}" ]; then
sudo apt-get update && sudo apt-get install -y ${{ matrix.tool.apt_dependencies }}
fi
if [ -n "${{ matrix.tool.package }}" ]; then
python -m pip install --upgrade pip setuptools wheel
python -m pip install ${{ matrix.tool.package }}
fi
- name: Run ${{ matrix.tool.package }}
env:
ADDED_FILES: ${{ join(fromJSON(steps.changed_files.outputs.added), ' ') }}
MODIFIED_FILES: ${{ join(fromJSON(steps.changed_files.outputs.modified), ' ') }}
run: |
sphinx-lint *.po */*.po
CHANGED_PO_FILES=$(printf "%s %s\n" "$ADDED_FILES" "$MODIFIED_FILES" | tr ' ' '\n' | grep '.po$'; true)
pwd
tree -L 2
if [ -n "$CHANGED_PO_FILES" ]
then
echo "Running on:" $CHANGED_PO_FILES
${{ matrix.tool.command }}
else
echo "No changed po files, nothing to check."
fi

- name: Build docs
sphinx:
name: 'Generate docs (sphinx)'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Prepare environment
run: |
make
pwd
tree -L 2
git clone https://github.com/python/cpython.git venv/cpython/
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements.txt -r venv/cpython/Doc/requirements.txt
- name: Make
run: make
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ __pycache__/
*.pot
*.po.bak
locales/
venv/
.idea/
.DS_Store
.pospell/
.potodo/
.venv/
157 changes: 64 additions & 93 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Makefile for tr Python Documentation
# Makefile for Turkish Python Documentation
#
# Here is what you can do:
#
# - make # Automatically build an HTML local version
# - make todo # To list remaining tasks
# - make todo # To list remaining tasks and show current progression
# - make verifs # To check for correctness: wrapping, spelling
# - make wrap # To check for wrapping
# - make wrap # To rewrap modified files
# - make spell # To check for spelling
# - make merge # To merge pot from upstream
# - make clean # To remove build artifacts
# - make fuzzy # To find fuzzy strings
# - make progress # To compute current progression
#
# Modes are: autobuild-stable, autobuild-dev, and autobuild-html,
# documented in gen/src/3.6/Doc/Makefile as we're only delegating the
Expand All @@ -21,14 +20,42 @@
# from which we generated our po files. We use it here so when we
# test build, we're building with the .rst files that generated our
# .po files.
CPYTHON_CURRENT_COMMIT := b027dd78bbdb66f2995bb898af304e66e5508bf6

CPYTHON_PATH := ../cpython/

CPYTHON_CURRENT_COMMIT := e699e5c20fc495952905597edfa82de0c1848f8c
LANGUAGE := tr
BRANCH := 3.10

EXCLUDED := whatsnew/ c-api/
EXCLUDED := \
whatsnew/2.?.po \
whatsnew/3.[0-8].po \
c-api/ \
distutils/ \
install/ \
library/2to3.po \
library/distutils.po \
library/imp.po \
library/tkinter.tix.po \
library/test.po \
library/aifc.po \
library/asynchat.po \
library/asyncore.po \
library/audioop.po \
library/cgi.po \
library/cgitb.po \
library/chunk.po \
library/crypt.po \
library/imghdr.po \
library/msilib.po \
library/nntplib.po \
library/nis.po \
library/ossaudiodev.po \
library/pipes.po \
library/smtpd.po \
library/sndhdr.po \
library/spwd.po \
library/sunau.po \
library/telnetlib.po \
library/uu.po \
library/xdrlib.po

# Internal variables

Expand All @@ -38,6 +65,7 @@ PYTHON := $(shell which python3)
MODE := html
POSPELL_TMP_DIR := .pospell/
JOBS := auto
SERVE_PORT :=

# Detect OS

Expand All @@ -58,89 +86,54 @@ endif

.PHONY: all
all: ensure_prerequisites
git -C $(CPYTHON_PATH) checkout $(CPYTHON_CURRENT_COMMIT)
git -C venv/cpython checkout $(CPYTHON_CURRENT_COMMIT) || (git -C venv/cpython fetch && git -C venv/cpython checkout $(CPYTHON_CURRENT_COMMIT))
mkdir -p locales/$(LANGUAGE)/LC_MESSAGES/
$(CP_CMD) -u --parents *.po */*.po locales/$(LANGUAGE)/LC_MESSAGES/
$(MAKE) -C $(CPYTHON_PATH)/Doc/ \
SPHINXOPTS='-qW -j$(JOBS) \
$(MAKE) -C venv/cpython/Doc/ \
SPHINXOPTS='-j$(JOBS) \
-D locale_dirs=$(abspath locales) \
-D language=$(LANGUAGE) \
-D gettext_compact=0 \
-D gettext_compact=0 \
-D latex_engine=xelatex \
-D latex_elements.inputenc= \
-D latex_elements.fontenc=' \
$(MODE)
git -C $(CPYTHON_PATH) checkout -
@echo "Build success, open file://$(abspath $(CPYTHON_PATH))/Doc/build/html/index.html or run 'make serve' to see them."
@echo "Build success, open file://$(abspath venv/cpython/)/Doc/build/html/index.html or run 'make serve' to see them."


# We clone cpython/ inside venv/ because venv/ is the only directory
# excluded by cpython' Sphinx configuration.
venv/cpython/.git/HEAD:
git clone https://github.com/python/cpython venv/cpython


.PHONY: ensure_prerequisites
ensure_prerequisites:
@if [ -z $(CPYTHON_PATH) ]; then \
echo "Your CPYTHON_PATH is empty, please provide one."; \
exit 1; \
fi
@if ! [ -d $(CPYTHON_PATH) ]; then \
echo "Building the translation requires a cpython clone."; \
echo "Please provide the path to a clone using the CPYTHON_PATH variable."; \
echo "(Currently CPYTHON_PATH is $(CPYTHON_PATH)."; \
echo "So you may want to run:"; \
echo ""; \
echo " git clone $(UPSTREAM) $(CPYTHON_PATH)"; \
exit 1; \
fi
@if [ -n "$$(git -C $(CPYTHON_PATH) status --porcelain)" ]; then \
echo "Your cpython clone at $(CPYTHON_PATH) is not clean."; \
echo "In order to avoid breaking things, please clean it first."; \
exit 1; \
fi
ensure_prerequisites: venv/cpython/.git/HEAD
@if ! (blurb help >/dev/null 2>&1 && sphinx-build --version >/dev/null 2>&1); then \
git -C $(CPYTHON_PATH) checkout $(BRANCH); \
echo "You're missing dependencies, please enable a venv and install:"; \
git -C venv/cpython/ checkout $(BRANCH); \
echo "You're missing dependencies please install:"; \
echo ""; \
echo " python -m pip install -r requirements.txt -r $(CPYTHON_PATH)/Doc/requirements.txt"; \
echo " python -m pip install -r requirements.txt -r venv/cpython/Doc/requirements.txt"; \
exit 1; \
fi


.PHONY: serve
serve:
$(MAKE) -C $(CPYTHON_PATH)/Doc/ serve


.PHONY: progress
progress:
ifeq ($(file),)
@echo "No file specified, showing total progress"; \
$(PYTHON) -c 'import sys; print("{:.1%}".format(int(sys.argv[1]) / int(sys.argv[2])))' \
$(shell msgcat *.po */*.po | msgattrib --translated | grep -c '^msgid') \
$(shell msgcat *.po */*.po | grep -c '^msgid')

ifdef SERVE_PORT
$(MAKE) -C venv/cpython/Doc/ serve SERVE_PORT=$(SERVE_PORT)
else
@$(PYTHON) -c 'import sys; print("{:.1%}".format(int(sys.argv[1]) / int(sys.argv[2])))' \
$(shell msgcat $(file) | msgattrib --translated | grep -c '^msgid') \
$(shell msgcat $(file) | grep -c '^msgid')
$(MAKE) -C venv/cpython/Doc/ serve
endif


.PHONY: todo
todo: ensure_prerequisites
potodo --exclude venv .venv $(EXCLUDED)

.PHONY: wrap
wrap: ensure_prerequisites
ifeq ($(fix),)
@echo "Verify wrapping"
powrap --check --quiet *.po **/*.po

else
ifeq ($(file),)
@echo "Checking and fixing wrapping"
powrap *.po **/*.po
else
@echo "Fixing wrapping in $(file)"
powrap $(file)
endif
endif
@echo "Re wrapping modified files"
powrap -m

SRCS = $(shell git diff --name-only $(BRANCH) | grep '.po$$')
# foo/bar.po => $(POSPELL_TMP_DIR)/foo/bar.po.out
Expand All @@ -152,41 +145,19 @@ spell: ensure_prerequisites $(DESTS)
$(POSPELL_TMP_DIR)/%.po.out: %.po dict
@echo "Pospell checking $<..."
mkdir -p $(@D)
pospell -p dict -l fr_FR $< && touch $@
pospell -p dict -l tr_TR $< && touch $@

.PHONY: fuzzy
fuzzy: ensure_prerequisites
potodo -f --exclude venv .venv $(EXCLUDED)

.PHONY: verifs
verifs: wrap spell

.PHONY: merge
merge: ensure_prerequisites
@echo "Merge from $(UPSTREAM)"
git -C $(CPYTHON_PATH) checkout $(BRANCH)
git -C $(CPYTHON_PATH) pull --ff-only
(cd $(CPYTHON_PATH)/Doc; sphinx-build -Q -b gettext -D gettext_compact=0 . ../pot)
find $(CPYTHON_PATH)/pot/ -name '*.pot' |\
while read -r POT; \
do \
PO="./$$(echo "$$POT" | sed "s#$(CPYTHON_PATH)/pot/##; s#\.pot\$$#.po#")"; \
mkdir -p "$$(dirname "$$PO")"; \
if [ -f "$$PO" ]; \
then \
msgmerge --backup=off --force-po -U "$$PO" "$$POT"; \
else \
msgcat -o "$$PO" "$$POT"; \
fi \
done
rm -fr $(CPYTHON_PATH)/pot/
sed -i 's|^#: .*Doc/|#: |' *.po */*.po
powrap -m
@printf "\n%s %s\n" "Replace CPYTHON_CURRENT_COMMIT in Makefile by: " $(shell git -C $(CPYTHON_PATH) rev-parse HEAD)
@printf 'To add, you can use:\n git status -s | grep "^ M .*\.po" | cut -d" " -f3 | while read -r file; do if [ $$(git diff "$$file" | wc -l) -gt 13 ]; then git add "$$file"; fi ; done\n'
verifs: spell

.PHONY: clean
clean:
@echo "Cleaning *.mo and $(POSPELL_TMP_DIR)"
rm -fr $(POSPELL_TMP_DIR)
rm -rf $(POSPELL_TMP_DIR)
find -name '*.mo' -delete
@echo "Cleaning build directory"
$(MAKE) -C venv/cpython/Doc/ clean
4 changes: 2 additions & 2 deletions about.po
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Python Documentation Turkish Translation
# Copyright (C) 2001-2022, Python Software Foundation
# This file is distributed under the same license as the Python package.
#
#
msgid ""
msgstr ""
"Project-Id-Version: Python 3.10\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-12-02 04:25-0500\n"
"POT-Creation-Date: 2022-12-05 18:31+0300\n"
"PO-Revision-Date: 2021-12-17 21:04+0300\n"
"Last-Translator: \n"
"Language-Team: TURKISH <python.docs.tr@gmail.com>\n"
Expand Down
4 changes: 2 additions & 2 deletions bugs.po
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Python Documentation Turkish Translation
# Copyright (C) 2001-2022, Python Software Foundation
# This file is distributed under the same license as the Python package.
#
#
msgid ""
msgstr ""
"Project-Id-Version: Python 3.10\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-12-02 04:25-0500\n"
"POT-Creation-Date: 2022-12-05 18:31+0300\n"
"PO-Revision-Date: 2021-12-17 22:58+0300\n"
"Last-Translator: \n"
"Language-Team: TURKISH <python.docs.tr@gmail.com>\n"
Expand Down
4 changes: 2 additions & 2 deletions c-api/abstract.po
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Python Documentation Turkish Translation
# Copyright (C) 2001-2022, Python Software Foundation
# This file is distributed under the same license as the Python package.
#
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.10\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-12-17 23:20+0300\n"
"POT-Creation-Date: 2022-12-05 18:31+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: \n"
"Language-Team: TURKISH <python.docs.tr@gmail.com>\n"
Expand Down
Loading