Skip to content

Commit

Permalink
Update CI setup (#422)
Browse files Browse the repository at this point in the history
* Fix compiler flags cleanup routine

* Update CHANGELOG

* Use clang for linking on Clang CI workflows

* Fix compiler_test(...) function in setup.py

* Fix CI failure when testing locally

* Remove LDSHARED for Clang build

* Fix linter warnings in setup.py

* Update CHANGELOG

* Update more workflow files for local actions

* Remove deprecated GitHub action for pre-commit

* Update CHANGELOG

* Update pre-commit hooks versions

* Refrain from updating pylint pre-commit hook for now

* Fix issue with running pre-commit on CI

* Add cache support for pre-commit on CI

* Fix name of caching step for pre-commit on CI

* Add Python 3.10 for testing on CI

* Add Python 3.10 in package metadata

* Fix gen_reqfile command if --include-extras is not provided

* Add setup option to avoid -march=native when building ProjectQ

* Add support for CIBuildWheel in pyproject.toml

* Tweak environment variables used during setup

* Avoid Linux Musl in CIBuildWheel config

* Update GitHub Workflow for publishing a release
  • Loading branch information
Takishima committed Jan 5, 2022
1 parent c26f70a commit a223425
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 49 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- 3.7
- 3.8
- 3.9
- '3.10'

name: "🐍 ${{ matrix.python }} • ${{ matrix.runs-on }} • x64 ${{ matrix.args }}"
runs-on: ${{ matrix.runs-on }}
Expand All @@ -28,6 +29,7 @@ jobs:
- uses: actions/checkout@v2

- name: Get history and tags for SCM versioning to work
if: ${{ !env.ACT }}
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
Expand Down Expand Up @@ -125,6 +127,7 @@ jobs:
- uses: actions/checkout@v2

- name: Get history and tags for SCM versioning to work
if: ${{ !env.ACT }}
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
Expand All @@ -134,6 +137,7 @@ jobs:
apt-get update && apt-get install -y python3-dev python3-pip python3-setuptools python3-wheel
python3-numpy python3-scipy python3-matplotlib python3-requests python3-networkx
python3-pytest python3-pytest-cov python3-flaky
libomp-dev
--no-install-recommends
- name: Prepare Python env
Expand Down Expand Up @@ -169,6 +173,7 @@ jobs:
- uses: actions/checkout@v2

- name: Get history and tags for SCM versioning to work
if: ${{ !env.ACT }}
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
Expand Down Expand Up @@ -236,6 +241,7 @@ jobs:
- uses: actions/checkout@v2

- name: Get history and tags for SCM versioning to work
if: ${{ !env.ACT }}
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
Expand Down Expand Up @@ -285,6 +291,7 @@ jobs:
restore-keys: ${{ runner.os }}-doc-pip-

- name: Get history and tags for SCM versioning to work
if: ${{ !env.ACT }}
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
Expand Down Expand Up @@ -318,6 +325,7 @@ jobs:
- uses: actions/checkout@v2

- name: Get history and tags for SCM versioning to work
if: ${{ !env.ACT }}
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,26 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Get history and tags for SCM versioning to work
if: ${{ !env.ACT }}
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- uses: actions/setup-python@v2
- uses: pre-commit/action@v2.0.3

- name: Install pre-commit
run: python3 -m pip install --upgrade pre-commit 'virtualenv!=20.11'

- name: Cache pre-commit hooks
uses: actions/cache@v2
with:
# Slow hooks are marked with manual - slow is okay here, run them too
extra_args: --hook-stage manual --all-files
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('**/.pre-commit-config.yaml') }}
restore-keys: pre-commit-

- name: Run pre-commit
run: |
# Slow hooks are marked with manual - slow is okay here, run them too
pre-commit run --hook-stage manual --all-files
clang-tidy:
name: Clang-Tidy
Expand Down
27 changes: 18 additions & 9 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
ref: 'master'

- name: Get history and tags for SCM versioning to work
if: ${{ !env.ACT }}
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
Expand Down Expand Up @@ -69,19 +70,24 @@ jobs:
# ========================================================================

- name: Build source distribution
- uses: actions/setup-python@v2

- name: Install Python packages
run: python3 -m pip install -U pip setuptools build wheel

- name: Build source distribution (Linux)
if: runner.os == 'Linux'
run: python3 setup.py sdist -d wheelhouse
run: python3 -m build --sdist

- name: Check metadata
run: |
python3 -m pip install twine --prefer-binary
python3 -m twine check wheelhouse/*
python3 -m twine check dist/*
- uses: actions/upload-artifact@v2
with:
name: packages
path: ./wheelhouse/*
name: pypy_wheels
path: ./dist/*


release:
Expand Down Expand Up @@ -134,8 +140,10 @@ jobs:
ref: 'master'

# ------------------------------------------------------------------------
# Downloads all to directories matching the artifact names

- uses: actions/download-artifact@v2
with:
name: pypy_wheels

# Code below inspired from this action:
# - uses: taiki-e/create-gh-release-action@v1
Expand All @@ -160,7 +168,7 @@ jobs:
if [[ "${tag}" =~ ^v?[0-9\.]+-[a-zA-Z_0-9\.-]+(\+[a-zA-Z_0-9\.-]+)?$ ]]; then
prerelease="--prerelease"
fi
gh release create "v${RELEASE_VERSION}" ${prerelease:-} --title "ProjectQ v${RELEASE_VERSION}" --notes "${notes:-}" packages/*
gh release create "v${RELEASE_VERSION}" ${prerelease:-} --title "ProjectQ v${RELEASE_VERSION}" --notes "${notes:-}" pypy_wheels/*
upload_to_pypi:
Expand All @@ -170,15 +178,16 @@ jobs:
steps:
- uses: actions/setup-python@v2

# Downloads all to directories matching the artifact names
- uses: actions/download-artifact@v2
with:
name: pypy_wheels

- name: Publish standard package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
packages_dir: packages/
packages_dir: pypy_wheels/

master_to_develop_pr:
name: Merge master back into develop
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.1.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -44,21 +44,21 @@ repos:
- id: remove-tabs

- repo: https://github.com/PyCQA/isort
rev: 5.9.1
rev: 5.10.1
hooks:
- id: isort
name: isort (python)

- repo: https://github.com/psf/black
rev: 21.5b1
rev: 21.12b0
hooks:
- id: black
language_version: python3
# This is a slow hook, so only run this if --hook-stage manual is passed
stages: [manual]

- repo: https://gitlab.com/PyCQA/flake8
rev: 3.9.2
rev: 4.0.1
hooks:
- id: flake8
name: flake8-strict
Expand All @@ -82,7 +82,7 @@ repos:
additional_dependencies: [pybind11>=2.6, numpy, requests, boto3, matplotlib, networkx, sympy]

- repo: https://github.com/mgedmin/check-manifest
rev: '0.46'
rev: '0.47'
hooks:
- id: check-manifest
additional_dependencies: ['setuptools-scm', 'pybind11>=2.6']
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added

- Added environment variable to avoid -march=native when building ProjectQ
- Added environment variable to force build failure if extensions do not compile on CI

### Changed
### Deprecated
### Fixed

- Fix compiler flags cleanup function for use on CI
- Fix workflow YAML to allow execution of GitHub Actions locally using `act`
- GitHub action using deprecated and vulnerable `pre-commit` version
- Fixed issue with `gen_reqfile` command if `--include-extras` is not provided

### Removed
### Repository

- Add configuration for CIBuildWheel in `pyproject.toml`
- Update `thomaseizinger/keep-a-changelog-new-release` GiHub action to v1.3.0
- Update `thomaseizinger/create-pull-request` GiHub action to v1.2.2
- Update pre-commit hook `pre-commit/pre-commit-hooks` to v4.1.0
- Update pre-commit hook `PyCQA/isort` to v5.10.1
- Update pre-commit hook `psf/black` to v21.12b0
- Update pre-commit hook `PyCQA/flake8` to v4.0.1
- Update pre-commit hook `mgedmin/check-manifest` to v0.47

## [0.7.0] - 2021-07-14

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ProjectQ comes with a high-performance quantum simulator written in C++. Please
.. note::
The setup will try to build a C++-Simulator, which is much faster than the Python implementation. If the C++ compilation were to fail, the setup will install a pure Python implementation of the simulator instead. The Python simulator should work fine for small examples (e.g., running Shor's algorithm for factoring 15 or 21).

If you want to skip the installation of the C++-Simulator altogether, you can define the ``DISABLE_PROJECTQ_CEXT`` environment variable to avoid any compilation steps.
If you want to skip the installation of the C++-Simulator altogether, you can define the ``PROJECTQ_DISABLE_CEXT`` environment variable to avoid any compilation steps.

.. note::
If building the C++-Simulator does not work out of the box, consider specifying a different compiler. For example:
Expand Down
27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,30 @@ local_scheme = 'no-local-version'
[tool.yapf]

column_limit = 120

[tool.cibuildwheel]

archs = ['auto64']
build-frontend = 'build'
build-verbosity = 1
skip = 'pp* *-musllinux*'
environment = { PROJECTQ_DISABLE_ARCH_NATIVE='1', PROJECTQ_CI_BUILD='1' }

before-test = [
'cd {package}',
'python setup.py gen_reqfile',
'python -m pip install -r requirements.txt --only-binary :all:',
]

test-command = 'python3 {package}/examples/grover.py'

# Normal options, etc.
manylinux-x86_64-image = 'manylinux2014'

[[tool.cibuildwheel.overrides]]
select = 'cp36-*'
manylinux-x86_64-image = 'manylinux1'

[[tool.cibuildwheel.overrides]]
select = 'cp3{7,8,9}-*'
manylinux-x86_64-image = 'manylinux2010'
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ classifier =
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10

[options]

Expand Down

0 comments on commit a223425

Please sign in to comment.