Skip to content
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

Add pre-commit and bunch of autofixes support #2034

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# A clang-format style that approximates Python's PEP 7
# Useful for IDE integration
BasedOnStyle: Google
AlwaysBreakAfterReturnType: All
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It found a duplicate entry!

AllowShortIfStatementsOnASingleLine: false
AlignAfterOpenBracket: Align
BreakBeforeBraces: Stroustrup
Expand Down
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
root = true

[*]
# TODO: Activate and run in a different PR. Lots of files affected
# trim_trailing_whitespace = true
# insert_final_newline = true
# end_of_line = crlf
indent_style = space
indent_size = 4
max_line_length = 120 # Same as .clang-format

[*.py]
max_line_length = 88 # Same as Black

[*.md]
trim_trailing_whitespace = false

[*.{yaml,yml}]
indent_size = 2
70 changes: 35 additions & 35 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,68 @@ on:
create:
tags:
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- b[0-9][0-9][0-9]
- publish-docs*
- b[0-9][0-9][0-9]
- publish-docs*
push:
branches:
- main
- main

jobs:
decompile:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install latest release
run: pip install --user --upgrade pywin32
- name: Install latest release
run: pip install --user --upgrade pywin32

- name: Set Python user site directory
run: python -c "import os,site;open(os.environ['GITHUB_ENV'], 'a').write(f'USER_DIR={site.USER_SITE}\n')"
- name: Set Python user site directory
run: python -c "import os,site;open(os.environ['GITHUB_ENV'], 'a').write(f'USER_DIR={site.USER_SITE}\n')"

- name: Decompile shipped help file
run: hh -decompile site ${env:USER_DIR}\PyWin32.chm
- name: Decompile shipped help file
run: hh -decompile site ${env:USER_DIR}\PyWin32.chm

- name: Rename root HTML file
run: mv site\PyWin32.HTML site\index.html
- name: Rename root HTML file
run: mv site\PyWin32.HTML site\index.html

# Compress first to avoid slowly uploading thousands of individual files
- name: Create archive
run: python -m zipfile -c site.zip site
- name: Create archive
run: python -m zipfile -c site.zip site

- uses: actions/upload-artifact@v3
with:
name: documentation
path: site.zip
- uses: actions/upload-artifact@v3
with:
name: documentation
path: site.zip

publish:
runs-on: ubuntu-latest
needs:
- decompile
- decompile

# Only publish tags
if: github.event_name == 'create' && github.event.ref_type == 'tag'

steps:
- uses: actions/download-artifact@v3
with:
name: documentation
- uses: actions/download-artifact@v3
with:
name: documentation

- name: Unpack archive
run: python -m zipfile -e site.zip .
- name: Unpack archive
run: python -m zipfile -e site.zip .

- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: site
commit_message: ${{ github.event.head_commit.message }}
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: site
commit_message: ${{ github.event.head_commit.message }}
# Write .nojekyll at the root, see:
# https://help.github.com/en/github/working-with-github-pages/about-github-pages#static-site-generators
enable_jekyll: false
enable_jekyll: false
# Only deploy if there were changes
allow_empty_commit: false
allow_empty_commit: false
128 changes: 64 additions & 64 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
pull_request:
branches:
- main
- main

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -21,40 +21,40 @@ jobs:
architecture: ['x64', 'x86']

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}

- name: Setup environment
run: |
python --version
pip --version
pip install --upgrade setuptools wheel

- name: Build and install
run: |
python setup.py --skip-verstamp install --user

- name: Run tests
# Run the tests directly from the source dir so support files (eg, .wav files etc)
# can be found - they aren't installed into the Python tree.
run: python pywin32_testall.py -v -skip-adodbapi

- name: Build wheels
run: |
python setup.py bdist_wheel --skip-build

- uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: artifacts
path: |
dist/*.whl
dist/*.exe
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}

- name: Setup environment
run: |
python --version
pip --version
pip install --upgrade setuptools wheel

- name: Build and install
run: |
python setup.py --skip-verstamp install --user

- name: Run tests
# Run the tests directly from the source dir so support files (eg, .wav files etc)
# can be found - they aren't installed into the Python tree.
run: python pywin32_testall.py -v -skip-adodbapi

- name: Build wheels
run: |
python setup.py bdist_wheel --skip-build

- uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: artifacts
path: |
dist/*.whl
dist/*.exe

# We cannot build and test on ARM64, so we cross-compile.
# Later, when available, we can add tests using this wheel on ARM64 VMs
Expand All @@ -67,35 +67,35 @@ jobs:
python-version: ['3.10', '3.11', '3.12-dev']

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'

- name: Setup Environment
run: |
python --version
pip --version
pip install --upgrade setuptools wheel

- name: Obtain ARM64 library files
run: |
python .github\workflows\download-arm64-libs.py .\arm64libs

- name: Build wheels
run: python setup.py --skip-verstamp build_ext -L .\arm64libs --plat-name win-arm64 build --plat-name win-arm64 bdist_wheel --plat-name win-arm64

- uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: artifacts
path: |
dist/*.whl

# This job can be run locally with the `format_all.bat` script
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'

- name: Setup Environment
run: |
python --version
pip --version
pip install --upgrade setuptools wheel

- name: Obtain ARM64 library files
run: |
python .github\workflows\download-arm64-libs.py .\arm64libs

- name: Build wheels
run: python setup.py --skip-verstamp build_ext -L .\arm64libs --plat-name win-arm64 build --plat-name win-arm64 bdist_wheel --plat-name win-arm64

- uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: artifacts
path: |-
dist/*.whl

# This job can be run locally by running `pre-commit run`
checkers:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[isort]
py_version=37
py_version = 37
profile = black
combine_as_imports = true
skip = setup.py
Expand Down
41 changes: 41 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# You can run this locally with `pre-commit run [--all-files]`
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
# TODO: Activate and run in a different PR. Lots of files affected
# - id: trailing-whitespace
# args: [--markdown-linebreak-ext=md]
# - id: end-of-file-fixer
- id: mixed-line-ending
args: [--fix=crlf]
- id: check-case-conflict
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.12.0
hooks:
- id: pretty-format-toml
args: [--autofix, --trailing-commas]
- id: pretty-format-yaml
args: [--autofix, --indent, "2", --offset, "2", --preserve-quotes]
- id: pretty-format-ini
args: [--autofix]
- repo: https://github.com/hadialqattan/pycln
rev: v2.4.0
hooks:
- id: pycln
args: [--config=pycln.toml]
verbose: true
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
verbose: true
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.2.0
hooks:
- id: black
verbose: true

ci:
autoupdate_schedule: quarterly
Loading
Loading