Skip to content

Commit

Permalink
Initial commit to qiskit-addon-dice-solver public repo.
Browse files Browse the repository at this point in the history
Co-authored-by: Javier Robledo Moreno <[email protected]>
  • Loading branch information
caleb-johnson and jrm874 committed Sep 8, 2024
1 parent fecb9a9 commit 4cf4b83
Show file tree
Hide file tree
Showing 28 changed files with 3,417 additions and 1 deletion.
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-dice-solver 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"
33 changes: 33 additions & 0 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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`.

## 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
57 changes: 57 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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:
name: Build 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: Upload docs artifact
if: always()
uses: actions/upload-pages-artifact@v3
with:
path: docs/_build/html

deploy:
name: Deploy docs
if: ${{ github.ref == 'refs/heads/stable/0.1' }}
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
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
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.egg-info/
.ipynb_checkpoints/
dice_solver/bin/
*__pycache__
external/boost_1_85_0/b2
external/boost_1_85_0/bin.v2/
external/boost_1_85_0/project-config.jam*
external/boost_1_85_0/stage/*
external/boost_1_85_0/tools/build/src/engine/b2
external/Dice/bin
build/
envs/
test/dice_solver_logfile.log
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Developer guide

Development of the `qiskit-addon-dice-solver` package takes place [on GitHub](https://github.com/Qiskit/qiskit-addon-dice-solver).
The [Contributing to Qiskit](https://github.com/Qiskit/qiskit/blob/main/CONTRIBUTING.md) guide may serve as a
useful starting point, as this package builds on [Qiskit].

This package is written in [Python] and uses [tox] as a testing framework. A description of the available
`tox` test environments is located at [`test/README.md`](test/README.md). These environments are used in the
CI workflows, which are described at [`.github/workflows/README.md`](.github/workflows/README.md).

Project configuration, including information about dependencies, is stored in [`setup.py`](setup.py).

We use [Sphinx] for documentation and [reno] for release notes.
We use [Google style docstrings](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html),
except we omit the type of each argument, as type information is redundant with Python
[type hints](https://docs.python.org/3/library/typing.html).

[Qiskit]: https://www.ibm.com/quantum/qiskit
[Python]: https://www.python.org/
[tox]: https://github.com/tox-dev/tox
[Sphinx]: https://www.sphinx-doc.org/
[reno]: https://docs.openstack.org/reno/
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Use Ubuntu 24.04 as the base image
FROM ubuntu:24.04

# Install essential tools
RUN apt-get update && apt-get install -y \
git \
build-essential \
curl \
vim \
wget \
python3 \
python3-pip \
python3-venv \
libboost-all-dev \
libopenmpi-dev \
openmpi-bin \
libhdf5-openmpi-dev

# Set up a working directory
WORKDIR /workspace

# Create dice-solver dir
RUN mkdir -p /workspace/dice-solver

# Copy contents of repo into dice-solver
COPY . /workspace/dice-solver

# Run build script
WORKDIR /workspace/dice-solver
RUN ./build.sh

# Set the default command to start an interactive shell
CMD ["/bin/bash"]
Loading

0 comments on commit 4cf4b83

Please sign in to comment.