Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into update-for-openqasm3_…
Browse files Browse the repository at this point in the history
…parser-changes
  • Loading branch information
mtreinish committed May 3, 2024
2 parents 1ed2e61 + 849fa00 commit a0a4b90
Show file tree
Hide file tree
Showing 439 changed files with 54,744 additions and 5,742 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# Qiskit folders (also their corresponding tests)
providers/ @Qiskit/terra-core @jyu00
quantum_info/ @Qiskit/terra-core @ikkoham
quantum_info/ @Qiskit/terra-core
qpy/ @Qiskit/terra-core
pulse/ @Qiskit/terra-core @eggerdj @wshanks
synthesis/ @Qiskit/terra-core @alexanderivrii @ShellyGarion
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/docs_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,21 @@ jobs:
- name: Install dependencies
run: tools/install_ubuntu_docs_dependencies.sh

- name: Determine GitHub branch name
run: |
# Tags like 1.0.0 and 1.0.0rc1 should point to their stable branch. We do this
# to reduce the diff in the qiskit/documentation repository between generating
# the API docs from a tag release versus a workflow_dispatch.
if [[ $GITHUB_REF_NAME =~ ^([0-9]+\.[0-9]+) ]]; then
BRANCH_NAME="stable/${BASH_REMATCH[1]}"
else
BRANCH_NAME="$GITHUB_REF_NAME"
fi
echo "Using branch '${BRANCH_NAME}' for GitHub source code links"
echo "QISKIT_DOCS_GITHUB_BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Build documentation
run: tox run -e docs

- name: Store built documentation artifact
uses: actions/upload-artifact@v4
with:
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/miri.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Miri
on:
push:
pull_request:
concurrency:
group: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }}
# Only cancel in PR mode. In push mode, don't cancel so we don't see spurious test "failures",
# and we get coverage reports on Coveralls for every push.
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
miri:
if: github.repository_owner == 'Qiskit'
name: Miri
runs-on: ubuntu-latest
env:
RUSTUP_TOOLCHAIN: nightly

steps:
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: miri

- name: Prepare Miri
run: |
set -e
# Some of our dependencies aren't Miri-safe with their current release versions. These
# need overriding with known-good versions to run against until the Miri-safe versions are
# released and updated in our Cargo.lock.
cat >>Cargo.toml <<EOF
[patch.crates-io]
crossbeam-epoch = { git = "https://github.com/crossbeam-rs/crossbeam", rev = "9e859610" }
EOF
cargo miri setup
- name: Run Miri
run: cargo miri test
env:
# - `tree-borrows` is required for crossbeam components.
# - `symbolic-alignment-check` is extra checking.
# - `strict-provenance` is extra checking.
MIRIFLAGS: '-Zmiri-tree-borrows -Zmiri-symbolic-alignment-check -Zmiri-strict-provenance'
44 changes: 44 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Tests
on:
push:
branches: [ main, 'stable/*' ]
pull_request:
branches: [ main, 'stable/*' ]

concurrency:
group: ${{ github.repository }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
tests:
if: github.repository_owner == 'Qiskit'
name: macOS-arm64-tests-Python-${{ matrix.python-version }}
runs-on: macOS-14
strategy:
fail-fast: false
matrix:
# Normally we test min and max version but we can't run python 3.8 or
# 3.9 on arm64 until actions/setup-python#808 is resolved
python-version: ["3.10", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/[email protected]
if: matrix.python-version == '3.10'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: arm64
- name: 'Install dependencies'
run: |
python -m pip install -U -r requirements.txt -c constraints.txt
python -m pip install -U -r requirements-dev.txt -c constraints.txt
python -m pip install -c constraints.txt -e .
- name: 'Install optionals'
run: |
python -m pip install -r requirements-optional.txt -c constraints.txt
python tools/report_numpy_state.py
if: matrix.python-version == '3.10'
- name: 'Run tests'
run: stestr run
43 changes: 26 additions & 17 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,20 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-11, windows-latest]
os: [ubuntu-latest, macos-11, windows-latest, macos-14]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.10'
if: matrix.os != 'macos-14'
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.10'
architecture: arm64
if: matrix.os == 'macos-14'
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
Expand All @@ -34,13 +41,13 @@ jobs:
with:
path: ./wheelhouse/*.whl
name: wheels-${{ matrix.os }}
build_wheels_32bit:
name: Build wheels 32bit
build_wheels_macos_arm_py38:
name: Build wheels on macOS arm
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
os: [macos-11]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -53,45 +60,47 @@ jobs:
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_SKIP: 'pp* cp36-* cp37-* *musllinux* *amd64 *x86_64'
CIBW_BEFORE_ALL: rustup target add aarch64-apple-darwin
CIBW_BUILD: cp38-macosx_universal2 cp38-macosx_arm64
CIBW_ARCHS_MACOS: arm64 universal2
CIBW_ENVIRONMENT: >-
CARGO_BUILD_TARGET="aarch64-apple-darwin"
PYO3_CROSS_LIB_DIR="/Library/Frameworks/Python.framework/Versions/$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')/lib/python$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')"
- uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: wheels-${{ matrix.os }}-32
build_wheels_macos_arm:
name: Build wheels on macOS arm
name: wheels-${{ matrix.os }}-arm
build_wheels_32bit:
name: Build wheels 32bit
runs-on: ${{ matrix.os }}
environment: release
strategy:
fail-fast: false
matrix:
os: [macos-11]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.10'
- uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BEFORE_ALL: rustup target add aarch64-apple-darwin
CIBW_ARCHS_MACOS: arm64 universal2
CIBW_ENVIRONMENT: >-
CARGO_BUILD_TARGET="aarch64-apple-darwin"
PYO3_CROSS_LIB_DIR="/Library/Frameworks/Python.framework/Versions/$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')/lib/python$(python -c 'import sys; print(str(sys.version_info[0])+"."+str(sys.version_info[1]))')"
CIBW_SKIP: 'pp* cp36-* cp37-* *musllinux* *amd64 *x86_64'
- uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl
name: wheels-${{ matrix.os }}-arm
name: wheels-${{ matrix.os }}-32
upload_shared_wheels:
name: Upload shared build wheels
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
needs: ["build_wheels", "build_wheels_macos_arm", "build_wheels_32bit"]
needs: ["build_wheels", "build_wheels_32bit", "build_wheels_macos_arm_py38"]
steps:
- uses: actions/download-artifact@v4
with:
Expand Down
52 changes: 52 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,58 @@ you just need to update the reference images as follows:

Note: If you have run `test/ipynb/mpl_tester.ipynb` locally it is possible some file metadata has changed, **please do not commit and push changes to this file unless they were intentional**.


### Testing Rust components

Rust-accelerated functions are generally tested from Python space, but in cases
where there is Rust-specific internal details to be tested, `#[test]` functions
can be included inline. Typically it's most convenient to place these in a
separate inline module that is only conditionally compiled in, such as

```rust
#[cfg(test)]
mod tests {
#[test]
fn my_first_test() {
assert_eq!(2, 1 + 1);
}
}
```

To run the Rust-space tests, do

```bash
cargo test --no-default-features
```

Our Rust-space components are configured such that setting the
``-no-default-features`` flag will compile the test runner, but not attempt to
build a linked CPython extension module, which would cause linker failures.

### Unsafe code and Miri

Any `unsafe` code added to the Rust logic should be exercised by Rust-space
tests, in addition to the more complete Python test suite. In CI, we run the
Rust test suite under [Miri](https://github.com/rust-lang/miri) as an
undefined-behavior sanitizer.

Miri is currently only available on `nightly` Rust channels, so to run it
locally you will need to ensure you have that channel available, such as by
```bash
rustup install nightly --components miri
```

After this, you can run the Miri test suite with
```bash
MIRIFLAGS="<flags go here>" cargo +nightly miri test
```

For the current set of `MIRIFLAGS` used by Qiskit's CI, see the
[`miri.yml`](https://github.com/Qiskit/qiskit/blob/main/.github/workflows/miri.yml)
GitHub Action file. This same file may also include patches to dependencies to
make them compatible with Miri, which you would need to temporarily apply as
well.

## Style and lint

Qiskit uses three tools for verify code formatting and lint checking. The
Expand Down
Loading

0 comments on commit a0a4b90

Please sign in to comment.