From d154ce7b63f2ec44ce32e10c8c3d3d566fdc6053 Mon Sep 17 00:00:00 2001 From: egeakman Date: Thu, 1 Dec 2022 12:49:39 +0300 Subject: [PATCH 1/5] Test sphinx-lint --- .github/workflows/build.yml | 36 ++++++++++++ .github/workflows/get-changes.py | 16 ------ .github/workflows/wrap_branch.yml | 24 +++----- .github/workflows/wrap_pr.yml | 95 ------------------------------- .pre-commit-config.yaml | 9 +++ requirements.txt | 1 + 6 files changed, 55 insertions(+), 126 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/get-changes.py delete mode 100644 .github/workflows/wrap_pr.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..5095150e2 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,36 @@ +name: Build + +on: + push: + branches: + - 3.* + pull_request: + +jobs: + test: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set Up Python 3.10 + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Get CPython + run: | + git clone https://github.com/python/cpython.git ../cpython branch=3.10 + + - name: Instalar dependencias + 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 + run: | + sphinx-lint **/*.po + + - name: Build docs + run: | + PYTHONWARNINGS=ignore::FutureWarning,ignore::RuntimeWarning sphinx-build -j auto -W --keep-going -b html -d ../cpython/Doc/_build/doctree -D language=tr . ../cpython/Doc/_build/html \ No newline at end of file diff --git a/.github/workflows/get-changes.py b/.github/workflows/get-changes.py deleted file mode 100644 index 44c4b2b0c..000000000 --- a/.github/workflows/get-changes.py +++ /dev/null @@ -1,16 +0,0 @@ -import requests -import json -from argparse import ArgumentParser - -parser = ArgumentParser() -parser.add_argument("--pull", help="PR Number ${{ github.event.number }}") -args = parser.parse_args() - -response = requests.get( - f"https://api.github.com/repos/python-docs-tr/python-docs-tr/pulls/{args.pull}/files" -) - -response = json.loads(response.text) - -for number in range(len(response)): - print(response[number]["filename"]) diff --git a/.github/workflows/wrap_branch.yml b/.github/workflows/wrap_branch.yml index d0fe9a768..87af25d88 100644 --- a/.github/workflows/wrap_branch.yml +++ b/.github/workflows/wrap_branch.yml @@ -5,26 +5,16 @@ on: workflow_dispatch jobs: wrap: runs-on: ubuntu-latest - - strategy: - matrix: - # Run in all these versions of Python - python-version: ["3.10"] - steps: # Checkout the latest code from the repo - name: Checkout repo uses: actions/checkout@v3 # Setup which version of Python to use - - name: Set Up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + - name: Set Up Python 3.10 + uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python-version }} - - # Display the Python version being used - - name: Display Python version - run: python -c "import sys; print(sys.version)" + python-version: "3.10" # Update pip - name: Update pip @@ -36,11 +26,15 @@ jobs: # Install dependencies - name: Install dependencies - run: sudo apt install gettext + run: sudo apt install -y gettext # Wrap all po files - name: Wrap - run: powrap *.po **/*.po + run: powrap *.po */*.po + + - name: Sphinx lint + run: | + sphinx-lint **/*.po # Detect changed files - name: Detect changed files diff --git a/.github/workflows/wrap_pr.yml b/.github/workflows/wrap_pr.yml deleted file mode 100644 index 63096be78..000000000 --- a/.github/workflows/wrap_pr.yml +++ /dev/null @@ -1,95 +0,0 @@ -name: "Wrap changed files in pull requests" - -on: - pull_request: - branches: [ "**" ] - -jobs: - wrap: - # Check if the source branch is from a fork - if: github.event.pull_request.head.repo.full_name == github.repository - runs-on: ubuntu-latest - - strategy: - matrix: - # Run in all these versions of Python - python-version: ["3.10"] - - steps: - # Checkout the latest code from the repo - - name: Checkout repo - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.ref }} - - # Setup which version of Python to use - - name: Set Up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - # Display the Python version being used - - name: Display Python version - run: python -c "import sys; print(sys.version)" - - # Update pip - - name: Update pip - run: python -m pip install --upgrade pip - - # Install requirements. - - name: Install requirements - run: python -m pip install --upgrade -r requirements.txt - - # Install dependencies - - name: Install dependencies - run: sudo apt install gettext - - # Detect changed files - - name: Detect changed files - run: echo "CHANGED_FILES=$(python .github/workflows/get-changes.py --pull ${{ github.event.pull_request.number }} | tr '\n' ' ')" >> $GITHUB_ENV - - # Wrap changed files - - name: Wrap - run: | - array=($CHANGED_FILES) - len=${#array[@]} - if [[ $len -eq 0 ]]; then - echo "No files to wrap" - else - for file in ${CHANGED_FILES}; do - if [[ $file == *.po ]]; then - echo "Wrapping $file" - powrap $file - fi - done - fi - - # Detect changed files - - name: Detect changed files - run: echo "WRAPPED=$(git diff --name-only | tr '\n' ' ')" >> $GITHUB_ENV - - # Commit changes - - name: Commit changes - run: | - array=($WRAPPED) - len=${#array[@]} - if [[ $len -eq 0 ]]; then - echo "No files to commit" - echo "WRAPPED=False" >> $GITHUB_ENV - else - echo "Committing changes" - git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" - git add ${WRAPPED} - git commit -m "Wrap translations" - echo "WRAPPED=True" >> $GITHUB_ENV - fi - - # Push changes - - name: Push changes - if: env.WRAPPED == 'True' - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.event.pull_request.head.ref }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..74928844a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +repos: +- repo: local + hooks: + - id: lint + name: Run sphinx linting + entry: sphinx-lint + language: python + additional_dependencies: ['sphinx-lint==0.6.7'] + files: \.po$ \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index dc2d20df4..75db2f5d2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ sphinx==4.5.0 blurb sphinx-lint==0.6.7 python-docs-theme>=2022.1 +pre-commit From f1a6e6e9eaf89442fb42a0ee516e5abc7fe8de80 Mon Sep 17 00:00:00 2001 From: egeakman Date: Thu, 1 Dec 2022 17:59:49 +0300 Subject: [PATCH 2/5] Update CI --- .github/workflows/build.yml | 2 +- .github/workflows/wrap_branch.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5095150e2..980fca504 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build on: push: branches: - - 3.* + - "**" pull_request: jobs: diff --git a/.github/workflows/wrap_branch.yml b/.github/workflows/wrap_branch.yml index 87af25d88..eb66ec510 100644 --- a/.github/workflows/wrap_branch.yml +++ b/.github/workflows/wrap_branch.yml @@ -34,7 +34,7 @@ jobs: - name: Sphinx lint run: | - sphinx-lint **/*.po + sphinx-lint */*.po *.po # Detect changed files - name: Detect changed files From 5b6454bf3e995dd98969295bbc60c0879317c79b Mon Sep 17 00:00:00 2001 From: egeakman Date: Thu, 1 Dec 2022 18:01:02 +0300 Subject: [PATCH 3/5] Update CI --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 980fca504..0ad75d9ce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: python-version: "3.10" - name: Get CPython run: | - git clone https://github.com/python/cpython.git ../cpython branch=3.10 + git clone https://github.com/python/cpython.git ../cpython --branch=3.10 - name: Instalar dependencias run: | From 350ae68bbd2c91a0ab5531eff832d458513adfe5 Mon Sep 17 00:00:00 2001 From: egeakman Date: Thu, 1 Dec 2022 21:09:50 +0300 Subject: [PATCH 4/5] Update CI --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0ad75d9ce..6195a92fd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: run: | git clone https://github.com/python/cpython.git ../cpython --branch=3.10 - - name: Instalar dependencias + - name: Install dependencies run: | sudo apt update sudo apt install -y gettext From 0067b761fd79dcfe8060a062872855bed882c917 Mon Sep 17 00:00:00 2001 From: egeakman Date: Thu, 1 Dec 2022 21:57:10 +0300 Subject: [PATCH 5/5] Update CI --- .github/workflows/build.yml | 2 +- .github/workflows/wrap_branch.yml | 2 +- .gitignore | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6195a92fd..656b887b9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,7 @@ jobs: - name: Sphinx lint run: | - sphinx-lint **/*.po + sphinx-lint *.po */*.po - name: Build docs run: | diff --git a/.github/workflows/wrap_branch.yml b/.github/workflows/wrap_branch.yml index eb66ec510..d3cdcc3ae 100644 --- a/.github/workflows/wrap_branch.yml +++ b/.github/workflows/wrap_branch.yml @@ -34,7 +34,7 @@ jobs: - name: Sphinx lint run: | - sphinx-lint */*.po *.po + sphinx-lint *.po */*.po # Detect changed files - name: Detect changed files diff --git a/.gitignore b/.gitignore index 26a7db490..66a207851 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ __pycache__/ .DS_Store *.pot *.po.bak +locales/