Skip to content

Commit

Permalink
Merge pull request #126 from lucky9-cyou/ylin/pre-commit
Browse files Browse the repository at this point in the history
feat: format code, add pre-commit and clang format
  • Loading branch information
Zhaoyilunnn authored Dec 21, 2023
2 parents 6387c70 + 643c4eb commit ca9e491
Show file tree
Hide file tree
Showing 115 changed files with 5,176 additions and 4,621 deletions.
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DerivePointerAlignment: false
PointerAlignment: Left
10 changes: 5 additions & 5 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Lint Commit Messages
on: [push, pull_request]

jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: wagoid/commitlint-github-action@v5
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: wagoid/commitlint-github-action@v5
16 changes: 16 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: pre-commit

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: '3.10'
- uses: pre-commit/[email protected]
40 changes: 20 additions & 20 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
name: Unit test
on:
push:
pull_request:
branches: ['master']
push:
pull_request:
branches: [master]
jobs:
unnittest:
name: Unit test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.10'
unnittest:
name: Unit test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.10'

- name: Install dependency
run: python -m pip install -r requirements.txt && python -m pip install pytest
- name: Install dependency
run: python -m pip install -r requirements.txt && python -m pip install pytest

# TODO(zhaoyilun): Build seperate package for pyquafu-torch
- name: Install torch
run: python -m pip install torch torchvision torchaudio
- name: Install torch
run: python -m pip install torch torchvision torchaudio

- name: Install pyquafu
run: python -m pip install .
- name: Install pyquafu
run: python -m pip install .

- name: Run unit tests
run: pytest tests/
- name: Run unit tests
run: pytest tests/
100 changes: 50 additions & 50 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
name: Build

on:
push:
branches:
- "master"
tags:
- "v*"
pull_request:
pull_request_review:
types: [submitted, edited]
workflow_dispatch:
push:
branches:
- master
tags:
- v*
pull_request:
pull_request_review:
types: [submitted, edited]
workflow_dispatch:



jobs:
build_wheels:
name: Build python wheels
strategy:
matrix:
os-arch: ["manylinux_x86_64", "win_amd64", "macosx_x86_64", "macosx_arm64"]
python-version: ["3.10"]
cibw-python: ["cp38", "cp39", "cp310","cp311"]
include:
- os-arch: "manylinux_x86_64"
os: "ubuntu-20.04"
- os-arch: "win_amd64"
os: "windows-2019"
- os-arch: "macosx_x86_64"
os: "macos-11"
- os-arch: "macosx_arm64"
os: "macos-11"
runs-on: ${{ matrix.os }}

env:
CIBW_BUILD: ${{ matrix.cibw-python }}-${{ matrix.os-arch }}
PYTHON: ${{ matrix.python-version }}
TWINE_USERNAME: "__token__"

steps:
- uses: actions/checkout@v3
build_wheels:
name: Build python wheels
strategy:
matrix:
os-arch: [manylinux_x86_64, win_amd64, macosx_x86_64, macosx_arm64]
python-version: ['3.10']
cibw-python: [cp38, cp39, cp310, cp311]
include:
- os-arch: manylinux_x86_64
os: ubuntu-20.04
- os-arch: win_amd64
os: windows-2019
- os-arch: macosx_x86_64
os: macos-11
- os-arch: macosx_arm64
os: macos-11
runs-on: ${{ matrix.os }}

# Used to host cibuildwheel
- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependence
run: python -m pip install pybind11 cibuildwheel scikit-build twine pytest

- name: Build wheels
run: python -m cibuildwheel --output-dir dist

- name: Publish package
run: python -m twine upload dist/*.whl
if: ${{ contains(github.ref, '/tags/') }}
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
CIBW_BUILD: ${{ matrix.cibw-python }}-${{ matrix.os-arch }}
PYTHON: ${{ matrix.python-version }}
TWINE_USERNAME: __token__

steps:
- uses: actions/checkout@v3

# Used to host cibuildwheel
- uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependence
run: python -m pip install pybind11 cibuildwheel scikit-build twine pytest

- name: Build wheels
run: python -m cibuildwheel --output-dir dist

- name: Publish package
run: python -m twine upload dist/*.whl
if: ${{ contains(github.ref, '/tags/') }}
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
53 changes: 53 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
repos:
- repo: https://github.com/Lucas-C/pre-commit-hooks.git
rev: v1.5.4
hooks:
- id: remove-crlf
files: (?!.*third_party)^.*$ | (?!.*book)^.*$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
args:
- --maxkb=20480
- id: check-merge-conflict
- id: check-symlinks
- id: detect-private-key
files: (?!.*third_party)^.*$ | (?!.*book)^.*$
- id: end-of-file-fixer
- id: trailing-whitespace
- id: requirements-txt-fixer
- id: sort-simple-yaml
- repo: https://github.com/pylint-dev/pylint
rev: v3.0.0a6
hooks:
- id: pylint
args:
- --disable=all
- --load-plugins=docstring_checker
- --enable=doc-string-one-line,doc-string-end-with,doc-string-with-all-args,doc-string-triple-quotes,doc-string-missing,doc-string-indent-error,doc-string-with-returns,doc-string-with-raises
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks.git
rev: v2.10.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '4']
- repo: https://github.com/hadialqattan/pycln
rev: v2.2.2
hooks:
- id: pycln
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v15.0.7
hooks:
- id: clang-format
args: [-style=file]
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
args: [--profile, black, --filter-files]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
Loading

0 comments on commit ca9e491

Please sign in to comment.