Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/numeric-tys
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-koch committed Jun 19, 2024
2 parents 999f121 + b2901d8 commit 13154dd
Show file tree
Hide file tree
Showing 44 changed files with 456 additions and 187 deletions.
69 changes: 0 additions & 69 deletions .github/workflows/issue.yml

This file was deleted.

95 changes: 93 additions & 2 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
types: [checks_requested]

permissions:
pull-requests: read
pull-requests: write

jobs:
main:
Expand All @@ -23,8 +23,15 @@ jobs:
# The action does not support running on merge_group events,
# but if the check succeeds in the PR there is no need to check it again.
if: github.event_name == 'pull_request_target'
outputs:
# Whether the PR title indicates a breaking change.
breaking: ${{ steps.breaking.outputs.breaking }}
# Whether the PR body contains a "BREAKING CHANGE:" footer describing the breaking change.
has_breaking_footer: ${{ steps.breaking.outputs.has_breaking_footer }}
steps:
- uses: amannn/action-semantic-pull-request@v5
- name: Validate the PR title format
uses: amannn/action-semantic-pull-request@v5
id: lint_pr_title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down Expand Up @@ -70,3 +77,87 @@ jobs:
# event triggers in your workflow.
ignoreLabels: |
ignore-semantic-pull-request
# `action-semantic-pull-request` does not parse the title, so it cannot
# detect if it is marked as a breaking change.
#
# Since at this point we know the PR title is a valid conventional commit,
# we can use a simple regex that looks for a '!:' sequence. It could be
# more complex, but we don't care about false positives.
- name: Check for breaking change flag
id: breaking
run: |
if [[ "${PR_TITLE}" =~ ^.*\!:.*$ ]]; then
echo "breaking=true" >> $GITHUB_OUTPUT
else
echo "breaking=false" >> $GITHUB_OUTPUT
fi
# Check if the PR comment has a "BREAKING CHANGE:" footer describing
# the breaking change.
if [[ "${PR_BODY}" != *"BREAKING CHANGE:"* ]]; then
echo "has_breaking_footer=false" >> $GITHUB_OUTPUT
else
echo "has_breaking_footer=true" >> $GITHUB_OUTPUT
fi
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }}

# Post a help comment if the PR title indicates a breaking change but does
# not contain a "BREAKING CHANGE:" footer.
- name: Require "BREAKING CHANGE:" footer for breaking changes
id: breaking-comment
if: ${{ steps.breaking.outputs.breaking == 'true' && steps.breaking.outputs.has_breaking_footer == 'false' }}
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-title-lint-error
message: |
Hey there and thank you for opening this pull request! 👋🏼
It looks like your proposed title indicates a breaking change. If that's the case,
please make sure to include a "BREAKING CHANGE:" footer in the body of the pull request
describing the breaking change and any migration instructions.
GITHUB_TOKEN: ${{ secrets.HUGRBOT_PAT }}
- name: Fail if the footer is required but missing
if: ${{ steps.breaking.outputs.breaking == 'true' && steps.breaking.outputs.has_breaking_footer == 'false' }}
run: exit 1

- name: Post a comment if the PR badly formatted
uses: marocchino/sticky-pull-request-comment@v2
# When the previous steps fails, the workflow would stop. By adding this
# condition you can continue the execution with the populated error message.
if: always() && (steps.lint_pr_title.outputs.error_message != null)
with:
header: pr-title-lint-error
message: |
Hey there and thank you for opening this pull request! 👋🏼
We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/)
and it looks like your proposed title needs to be adjusted.
Your title should look like this. The scope field is optional.
```
<type>(<scope>): <description>
```
If the PR includes a breaking change, mark it with an exclamation mark:
```
<type>!: <description>
```
and include a "BREAKING CHANGE:" footer in the body of the pull request.
Details:
```
${{ steps.lint_pr_title.outputs.error_message }}
```
GITHUB_TOKEN: ${{ secrets.HUGRBOT_PAT }}

# Delete previous comments when the issues have been resolved
# This step doesn't run if any of the previous checks fails.
- name: Delete previous comments
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-title-lint-error
delete: true
GITHUB_TOKEN: ${{ secrets.HUGRBOT_PAT }}
33 changes: 26 additions & 7 deletions .github/workflows/python-wheels.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
name: Build and publish python wheels
# Builds and publishes the wheels on pypi.
#
# When running on a push-to-main event, or as a workflow dispatch on a branch,
# this workflow will do a dry-run publish to test-pypi.
#
# When running on a release event or as a workflow dispatch for a tag,
# and if the tag matches `hugr-py-v*`,
# this workflow will publish the wheels to pypi.
# If the version is already published, pypi just ignores it.

on:
workflow_dispatch:
push:
branches:
- main
tags:
- 'v**'
release:
types:
- published

jobs:
build-publish:
Expand All @@ -26,7 +36,7 @@ jobs:
cache: "poetry"

- name: Build sdist and wheels
run: poetry build
run: poetry build -o dist

- name: Upload the built packages as artifacts
uses: actions/upload-artifact@v4
Expand All @@ -37,14 +47,23 @@ jobs:
dist/*.whl
- name: Publish to test instance of PyPI (dry-run)
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref_type == 'branch' ) }}
if: |
${{ github.event_name == 'push' && github.ref_type == 'branch' }} ||
${{ github.event_name == 'workflow_dispatch' && github.ref_type == 'branch'}}
run: |
echo "Doing a dry-run publish to test-pypi..."
echo "Based on the following workflow variables, this is not a hugr-py version tag push:"
echo " - event_name: ${{ github.event_name }}"
echo " - ref_type: ${{ github.ref_type }}"
echo " - ref: ${{ github.ref }}"
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry config pypi-token.test-pypi ${{ secrets.PYPI_TEST_PUBLISH }}
poetry publish -r test-pypi --skip-existing --dry-run
poetry publish -r test-pypi --dist-dir dist --skip-existing --dry-run
- name: Publish to PyPI
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
if: |
${{ (github.event_name == 'release' && github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v'))}} ||
${{ (github.event_name == 'workflow_dispatch' && github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v'))}} ||
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_PUBLISH }}
poetry publish --skip-existing
poetry publish --dist-dir dist --skip-existing
14 changes: 9 additions & 5 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Automatic changelog and version bumping with release-please for python projects
name: Release-please 🐍

on:
workflow_dispatch: {}
push:
branches:
- main
Expand All @@ -7,13 +11,13 @@ permissions:
contents: write
pull-requests: write

name: release-please

jobs:
release-please:
name: Create release PR
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v4
- uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
config-file: release-please-config.json
# Using a personal access token so releases created by this workflow can trigger the deployment workflow
token: ${{ secrets.HUGRBOT_PAT }}
config-file: release-please-config.json
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,4 @@ devenv.local.nix

# pre-commit
.pre-commit-config.yaml
/.envrc
9 changes: 5 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 # Use the ref you want to point at
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -20,24 +20,25 @@ repos:
- id: debug-statements

- repo: https://github.com/crate-ci/typos
rev: v1.19.0
rev: v1.21.0
hooks:
- id: typos

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.5
rev: v0.4.6
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.8.0"
rev: "v1.10.0"
hooks:
- id: mypy
pass_filenames: false
args: [--package=guppylang]
additional_dependencies: [
hugr,
graphviz,
networkx,
ormsgpack,
Expand Down
4 changes: 2 additions & 2 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.3.0"
}
".": "0.5.2"
}
3 changes: 2 additions & 1 deletion .typos.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[default.extend-words]
inot = "inot"
fle = "fle"
ine = "ine"
inot = "inot"
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Changelog

## [0.5.2](https://github.com/CQCL/guppylang/compare/v0.5.1...v0.5.2) (2024-06-13)


### Bug Fixes

* Don't reorder inputs of entry BB ([#243](https://github.com/CQCL/guppylang/issues/243)) ([ad56b99](https://github.com/CQCL/guppylang/commit/ad56b991c03e1bc52690e41450521e7fe9100268))

## [0.5.1](https://github.com/CQCL/guppylang/compare/v0.5.0...v0.5.1) (2024-06-12)


### Bug Fixes

* Serialisation of bool values ([#239](https://github.com/CQCL/guppylang/issues/239)) ([16a77db](https://github.com/CQCL/guppylang/commit/16a77dbd4c5905eff6c4ddabe66b5ef1b8a7e15b))

## [0.5.0](https://github.com/CQCL/guppylang/compare/v0.4.0...v0.5.0) (2024-06-10)


### Features

* Add extern symbols ([#236](https://github.com/CQCL/guppylang/issues/236)) ([977ccd8](https://github.com/CQCL/guppylang/commit/977ccd831a3df1bdf49582309bce065a865d3e31))

## [0.4.0](https://github.com/CQCL/guppylang/compare/v0.3.0...v0.4.0) (2024-05-30)


### Features

* Export py function ([6dca95d](https://github.com/CQCL/guppylang/commit/6dca95deda3cc5bd103df104e33991c9adce2be2))

## [0.3.0](https://github.com/CQCL/guppylang/compare/v0.2.0...v0.3.0) (2024-05-22)


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[codecov]: https://img.shields.io/codecov/c/gh/CQCL/guppylang?logo=codecov
[py-version]: https://img.shields.io/pypi/pyversions/guppylang
[pypi]: https://img.shields.io/pypi/v/guppylang
[pypi]: https://img.shields.io/pypi/v/guppylang

Guppy is a quantum programming language that is fully embedded into Python.
It allows you to write high-level hybrid quantum programs with classical control flow and mid-circuit measurements using Pythonic syntax:
Expand Down
Loading

0 comments on commit 13154dd

Please sign in to comment.