Skip to content

Commit

Permalink
Initial commit to SQD public repository.
Browse files Browse the repository at this point in the history
Co-authored-by: Javier Robledo Moreno <[email protected]>
Co-authored-by: Iskandar Sitdikov <[email protected]>
Co-authored-by: Paul Schweigert <[email protected]>
Co-authored-by: Abdullah Ash Saki <[email protected]>
Co-authored-by: Stefano Barison <[email protected]>
  • Loading branch information
6 people committed Sep 7, 2024
0 parents commit 89e947c
Show file tree
Hide file tree
Showing 55 changed files with 7,790 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: 🐛 Bug report
description: Create a report to help us improve 🤔.
labels: ["bug"]

body:
- type: markdown
attributes:
value: Thank you for reporting a bug! Before you do so, please ensure that you have tested on the latest released version of the code. If it does, please also use the search to see if there are any other related issues or pull requests.

- type: textarea
attributes:
label: Environment
description: Please give the actual version number (_e.g._ 0.1.0) if you are using a release version, or the first 7-8 characters of the commit hash if you have installed from `git`. If anything else is relevant, you can add it to the list.
# The trailing spaces on the following lines are to make filling the form
# in easier. The type is 'textarea' rather than three separate 'input's
# to make the resulting issue body less noisy with headings.
value: |
- **qiskit-addon-sqd version**:
- **Python version**:
- **Operating system**:
validations:
required: true

- type: textarea
attributes:
label: What is happening and why is it wrong?
description: A short description of what is going wrong, in words.
validations:
required: true

- type: textarea
attributes:
label: How can we reproduce the issue?
description: Give some steps that show the bug. A [minimal working example](https://stackoverflow.com/help/minimal-reproducible-example) of code with output is best. If you are copying in code, please remember to enclose it in triple backticks (` ``` [multiline code goes here] ``` `) so that it [displays correctly](https://docs.github.com/en/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax).
validations:
required: true

- type: textarea
attributes:
label: Traceback
description: If your code provided an error traceback, please paste it below, enclosed in triple backticks (` ``` [multiline code goes here] ``` `) so that it [displays correctly](https://docs.github.com/en/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax).
validations:
required: false

- type: textarea
attributes:
label: Any suggestions?
description: Not required, but if you have suggestions for how a contributor should fix this, or any problems we should be aware of, let us know.
validations:
required: false
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: 🚀 Feature request
description: Suggest an idea for this project 💡!
labels: ["type: feature request"]

body:
- type: markdown
attributes:
value: Please make sure to browse the opened and closed issues to make sure that this idea has not previously been discussed.

- type: textarea
attributes:
label: What should we add?
validations:
required: true
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
labels: ["dependencies"]
schedule:
interval: "weekly"
- package-ecosystem: "pip"
directory: "/"
labels: ["dependencies"]
versioning-strategy: increase
schedule:
interval: "monthly"
37 changes: 37 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# GitHub Actions workflows

This directory contains a number of workflows for use with [GitHub Actions](https://docs.github.com/actions). They specify what standards should be expected for development of this software, including pull requests. These workflows are designed to work out of the box for any research software prototype, especially those based on [Qiskit](https://qiskit.org/).

## Lint check (`lint.yml`)

This workflow checks that the code is formatted properly and follows the style guide by installing tox and running the [lint environment](/tests/#lint-environment) (`tox -e lint`).

## Latest version tests (`test_latest_versions.yml`)

This workflow installs the latest version of tox and runs [the current repository's tests](/tests/#test-py-environments) under each supported Python version on Linux and under a single Python version on macOS and Windows. This is the primary testing workflow. It runs for all code changes and additionally once per day, to ensure tests continue to pass as new versions of dependencies are released.

## Development version tests (`test_development_versions.yml`)

This workflow installs tox and modifies `pyproject.toml` to use the _development_ versions of certain Qiskit packages, using [extremal-python-dependencies](https://github.com/IBM/extremal-python-dependencies). For all other packages, the latest version is installed. This workflow runs on two versions of Python: the minimum supported version and the maximum supported version. Its purpose is to identify as soon as possible (i.e., before a Qiskit release) when changes in Qiskit will break the current repository. This workflow runs for all code changes, as well as on a timer once per day.

## Minimum version tests (`test_minimum_versions.yml`)

This workflow first installs the minimum supported tox version (the `minversion` specified in [`tox.ini`](/tox.ini)) and then installs the _minimum_ compatible version of each package listed in `pyproject.toml`, using [extremal-python-dependencies](https://github.com/IBM/extremal-python-dependencies). The purpose of this workflow is to make sure the minimum version specifiers in these files are accurate, i.e., that the tests actually pass with these versions. This workflow uses a single Python version, typically the oldest supported version, as the minimum supported versions of each package may not be compatible with the most recent Python release.

Under the hood, this workflow uses a regular expression to change each `>=` and `~=` specifier in the dependencies to instead be `==`, as pip [does not support](https://github.com/pypa/pip/issues/8085) resolving the minimum versions of packages directly. Unfortunately, this means that the workflow will only install the minimum version of a package if it is _explicitly_ listed in one of the requirements files with a minimum version. For instance, if the only listed dependency is `qiskit>=1.0`, this workflow will install `qiskit==1.0` along with the latest version of each transitive dependency, such as `rustworkx`.

## Code coverage (`coverage.yml`)

This workflow tests the [coverage environment](/tests/#coverage-environment) on a single version of Python by installing tox and running `tox -e coverage`.

## Documentation (`docs.yml`)

This workflow ensures that the [Sphinx](https://www.sphinx-doc.org/) documentation builds successfully. It also publishes the resulting build to [GitHub Pages](https://pages.github.com/) if it is from the appropriate branch (e.g., `main`).

## Citation preview (`citation.yml`)

This workflow is only triggered when the `CITATION.bib` file is changed. It ensures that the file contains only ASCII characters ([escaped codes](https://en.wikibooks.org/wiki/LaTeX/Special_Characters#Escaped_codes) are preferred, as then the `bib` file will work even when `inputenc` is not used). It also compiles a sample LaTeX document which includes the citation in its bibliography and uploads the resulting PDF as an artifact so it can be previewed (e.g., before merging a pull request).

## Release (`release.yml`)

This workflow is triggered by a maintainer pushing a tag that represents a release. It publishes the release to github.com and to [PyPI](https://pypi.org/).
68 changes: 68 additions & 0 deletions .github/workflows/citation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Citation preview

on:
push:
branches: [ main ]
paths: ['CITATION.bib', '.github/workflows/citation.yml']
pull_request:
branches: [ main ]
paths: ['CITATION.bib', '.github/workflows/citation.yml']

jobs:
build-preview:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Check for non-ASCII characters
run: |
# Fail immediately if there are any non-ASCII characters in
# the BibTeX source. We prefer "escaped codes" rather than
# UTF-8 characters in order to ensure the bibliography will
# display correctly even in documents that do not contain
# \usepackage[utf8]{inputenc}.
if [ -f "CITATION.bib" ]; then
python3 -c 'open("CITATION.bib", encoding="ascii").read()'
fi
- name: Install LaTeX
run: |
if [ -f "CITATION.bib" ]; then
sudo apt-get update
sudo apt-get install -y texlive-latex-base texlive-publishers
fi
- name: Run LaTeX
run: |
if [ -f "CITATION.bib" ]; then
arr=(${GITHUB_REPOSITORY//\// })
export REPO=${arr[1]}
cat <<- EOF > citation-preview.tex
\documentclass[preprint,aps,physrev,notitlepage]{revtex4-2}
\usepackage{hyperref}
\begin{document}
\title{\texttt{$REPO} BibTeX test}
\maketitle
\noindent
\texttt{$REPO}
\cite{$REPO}
\bibliography{CITATION}
\end{document}
EOF
pdflatex citation-preview
fi
- name: Run BibTeX
run: |
if [ -f "CITATION.bib" ]; then
bibtex citation-preview
fi
- name: Re-run LaTeX
run: |
if [ -f "CITATION.bib" ]; then
pdflatex citation-preview
pdflatex citation-preview
fi
- name: Upload PDF
if: always()
uses: actions/upload-artifact@v4
with:
name: citation-preview.pdf
path: citation-preview.pdf
54 changes: 54 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build Sphinx docs

on:
workflow_dispatch:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+*"
branches:
- main
- 'stable/**'
pull_request:
branches:
- main
- 'stable/**'

jobs:
build_and_deploy_docs:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
sudo apt-get update
sudo apt-get install -y pandoc
- name: Build docs
shell: bash
run: |
tox -edocs
- name: Prepare docs artifact
if: always()
shell: bash
run: |
mkdir artifact
cp -a docs/_build/html artifact/addon_sqd_html_docs
- name: Upload docs artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: addon_sqd_html_docs
path: ./artifact
- name: Deploy docs
if: ${{ github.ref == 'refs/heads/stable/0.3' }}
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html/
32 changes: 32 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint check

on:
push:
branches:
- main
- 'stable/**'
pull_request:
branches:
- main
- 'stable/**'

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install tox
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run lint check
shell: bash
run: |
tox -elint
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Publish release

on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+*"

jobs:

github:
name: github
runs-on: ubuntu-latest
steps:
- name: Checkout tag
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Publish release
uses: ghalactic/github-release-from-tag@v5
if: github.ref_type == 'tag'
with:
token: ${{ secrets.GITHUB_TOKEN }}
generateReleaseNotes: "true"

pypi:
name: pypi
runs-on: ubuntu-latest
needs: github
environment:
name: pypi
url: https://pypi.org/p/qiskit-addon-sqd
permissions:
id-token: write
steps:
- name: Checkout tag
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Install `build` tool
run: |
python -m pip install --upgrade pip
pip install build
- name: Build distribution
run: |
python -m build
- name: Publish release to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
43 changes: 43 additions & 0 deletions .github/workflows/test_development_versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Development version tests

on:
push:
branches:
- main
- 'stable/**'
pull_request:
branches:
- main
- 'stable/**'
schedule:
- cron: '0 1 * * *'

jobs:
tests:
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
max-parallel: 4
matrix:
python-version: '3.10'
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies (development versions)
shell: bash
run: |
python -m pip install --upgrade pip tox
python -m pip install extremal-python-dependencies==0.0.3
extremal-python-dependencies pin-dependencies \
"qiskit @ git+https://github.com/Qiskit/qiskit.git" \
"pyscf @ git+https://github.com/pyscf/pyscf.git" \
--inplace
- name: Test using tox environment
shell: bash
run: |
toxpyversion=$(echo ${{ matrix.python-version }} | sed -E 's/^([0-9]+)\.([0-9]+).*$/\1\2/')
tox -epy${toxpyversion}
tox -epy${toxpyversion}-notebook
Loading

0 comments on commit 89e947c

Please sign in to comment.