Skip to content

Commit

Permalink
Merge branch 'acl/const_fold2' into acl/const_fold3
Browse files Browse the repository at this point in the history
  • Loading branch information
acl-cqc committed Dec 4, 2024
2 parents 5b51434 + bb9600e commit 26466db
Show file tree
Hide file tree
Showing 291 changed files with 18,091 additions and 3,200 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/snapshots/*.snap -diff
4 changes: 4 additions & 0 deletions .github/change-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ python:
- "uv.lock"
- "specification/schema/**"
- ".github/workflows/ci-py.yml"


llvm:
- "hugr-llvm/**"
10 changes: 5 additions & 5 deletions .github/workflows/ci-py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
pull_request:
branches:
- main
- '*'
merge_group:
types: [checks_requested]
workflow_dispatch: {}
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
uses: mozilla-actions/[email protected]

- name: Set up uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v4
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v4
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
Expand Down Expand Up @@ -141,7 +141,7 @@ jobs:
- name: Upload python coverage to codecov.io
if: github.event_name != 'merge_group' && matrix.python-version.coverage
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
files: coverage.xml
name: python
Expand All @@ -160,7 +160,7 @@ jobs:
uses: mozilla-actions/[email protected]

- name: Set up uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v4
with:
version: ${{ env.UV_VERSION }}
enable-cache: true
Expand Down
79 changes: 56 additions & 23 deletions .github/workflows/ci-rs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
pull_request:
branches:
- main
- '*'
merge_group:
types: [checks_requested]
workflow_dispatch: {}
Expand All @@ -23,7 +23,7 @@ env:

jobs:
# Check if changes were made to the relevant files.
# Always returns true if running on the default branch, to ensure all changes are throughly checked.
# Always returns true if running on the default branch, to ensure all changes are thoroughly checked.
changes:
name: Check for changes
runs-on: ubuntu-latest
Expand All @@ -35,6 +35,7 @@ jobs:
outputs:
rust: ${{ steps.filter.outputs.rust == 'true' || steps.override.outputs.out == 'true' }}
python: ${{ steps.filter.outputs.python == 'true' || steps.override.outputs.out == 'true' }}
llvm: ${{ steps.filter.outputs.llvm == 'true' || steps.override.outputs.out == 'true' }}
steps:
- uses: actions/checkout@v4
- name: Override label
Expand Down Expand Up @@ -91,9 +92,9 @@ jobs:
- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Build benchmarks with no features
run: cargo bench --verbose --no-run --workspace --no-default-features
run: cargo bench --verbose --no-run --no-default-features
- name: Build benchmarks with all features
run: cargo bench --verbose --no-run --workspace --all-features
run: cargo bench --verbose --no-run --all-features

# Run tests on Rust stable
tests-stable-no-features:
Expand All @@ -110,12 +111,13 @@ jobs:
toolchain: "stable"
- name: Configure default rust toolchain
run: rustup override set ${{steps.toolchain.outputs.name}}

- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Build with no features
run: cargo test --verbose --workspace --no-default-features --no-run
run: cargo test --verbose --no-default-features --no-run
- name: Tests with no features
run: cargo test --verbose --workspace --no-default-features
run: cargo test --verbose --no-default-features

# Run tests on Rust stable
tests-stable-all-features:
Expand All @@ -132,12 +134,13 @@ jobs:
toolchain: "stable"
- name: Configure default rust toolchain
run: rustup override set ${{steps.toolchain.outputs.name}}

- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Build with all features
run: cargo test --verbose --workspace --all-features --no-run
run: cargo test --verbose --all-features --no-run
- name: Tests with all features
run: cargo test --verbose --workspace --all-features
run: cargo test --verbose --all-features
- name: Build HUGR binary
run: cargo build -p hugr-cli
- name: Upload the binary to the artifacts
Expand Down Expand Up @@ -170,13 +173,13 @@ jobs:
- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Build with no features
run: cargo test --verbose --workspace --no-default-features --no-run
run: cargo test --verbose --no-default-features --no-run
- name: Tests with no features
run: cargo test --verbose --workspace --no-default-features
run: cargo test --verbose --no-default-features
- name: Build with all features
run: cargo test --verbose --workspace --all-features --no-run
run: cargo test --verbose --all-features --no-run
- name: Tests with all features
run: cargo test --verbose --workspace --all-features
run: cargo test --verbose --all-features

# Ensure that serialized extensions match rust implementation
std-extensions:
Expand Down Expand Up @@ -220,31 +223,61 @@ jobs:
components: llvm-tools-preview
- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
with:
version: "14.0"
env: true
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Run tests with coverage instrumentation
run: |
cargo llvm-cov clean --workspace
cargo llvm-cov --no-report --workspace --no-default-features --doctests
cargo llvm-cov --no-report --workspace --all-features --doctests
cargo llvm-cov --no-report --no-default-features --doctests
cargo llvm-cov --no-report --all-features --doctests
cargo llvm-cov --no-report -p hugr-llvm --features llvm14-0 --doctests
- name: Generate coverage report
run: cargo llvm-cov --all-features report --codecov --output-path coverage.json
- name: Upload coverage to codecov.io
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
files: coverage.json
name: rust
flags: rust
token: ${{ secrets.CODECOV_TOKEN }}

rs-semver-checks:
needs: [changes, check]
if: ${{ needs.changes.outputs.rust == 'true' && github.event_name == 'pull_request' }}
uses: CQCL/hugrverse-actions/.github/workflows/rs-semver-checks.yml@main
with:
apt-dependencies: capnproto
secrets:
GITHUB_PAT: ${{ secrets.HUGRBOT_PAT }}
tests-stable-llvm:
needs: changes
if: ${{ ( needs.changes.outputs.llvm == 'true' && github.event_name == 'push' ) || needs.changes.outputs.override == 'true' }}
runs-on: ubuntu-latest
name: tests hugr-llvm
strategy:
matrix:
llvm-version:
# different strings for install action and feature name
# adapted from https://github.com/TheDan64/inkwell/blob/master/.github/workflows/test.yml
- ["14.0", "14-0"]

steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/[email protected]
- id: toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: "stable"
- name: Configure default rust toolchain
run: rustup override set ${{steps.toolchain.outputs.name}}
- name: Install CapnProto
run: sudo apt-get install -y capnproto
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v2
with:
version: ${{ matrix.llvm-version[0] }}
env: true
- name: Build
run: cargo test -p hugr-llvm --verbose --features llvm${{ matrix.llvm-version[1] }} --no-run
- name: Tests with no features
run: cargo test -p hugr-llvm --verbose --features llvm${{ matrix.llvm-version[1] }}

# This is a meta job to mark successful completion of the required checks,
# even if they are skipped due to no changes in the relevant files.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
fetch-tags: true

- name: Set up uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v4
with:
version: "0.4.18"
enable-cache: true
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/notify-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ jobs:
if: needs.coverage-trend.outputs.should_notify == 'true'
steps:
- name: Send notification
uses: slackapi/slack-github-action@v1.27.0
uses: slackapi/slack-github-action@v2.0.0
with:
channel-id: 'C04SHCL4FKP'
slack-message: ${{ needs.coverage-trend.outputs.msg }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: 'C05GGH4GP4N'
text: ${{ needs.coverage-trend.outputs.msg }}
2 changes: 1 addition & 1 deletion .github/workflows/python-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
uses: mozilla-actions/[email protected]

- name: Set up uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v4
with:
version: "0.4.18"
enable-cache: true
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/semver-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Rust Semver Checks
on:
pull_request_target:
branches:
- main

jobs:
# Check if changes were made to the relevant files.
# Always returns true if running on the default branch, to ensure all changes are throughly checked.
changes:
name: Check for changes
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from filter step
# These outputs are always true when running after a merge to main, or if the PR has a `run-ci-checks` label.
outputs:
rust: ${{ steps.filter.outputs.rust == 'true' || steps.override.outputs.out == 'true' }}
python: ${{ steps.filter.outputs.python == 'true' || steps.override.outputs.out == 'true' }}
steps:
- uses: actions/checkout@v4
- name: Override label
id: override
run: |
echo "Label contains run-ci-checks: $OVERRIDE_LABEL"
if [ "$OVERRIDE_LABEL" == "true" ]; then
echo "Overriding due to label 'run-ci-checks'"
echo "out=true" >> $GITHUB_OUTPUT
elif [ "$DEFAULT_BRANCH" == "true" ]; then
echo "Overriding due to running on the default branch"
echo "out=true" >> $GITHUB_OUTPUT
fi
env:
OVERRIDE_LABEL: ${{ github.event_name == 'pull_request' && contains( github.event.pull_request.labels.*.name, 'run-ci-checks') }}
DEFAULT_BRANCH: ${{ github.ref_name == github.event.repository.default_branch }}
- uses: dorny/paths-filter@v3
id: filter
with:
filters: .github/change-filters.yml

rs-semver-checks:
needs: [changes]
if: ${{ needs.changes.outputs.rust == 'true' }}
uses: CQCL/hugrverse-actions/.github/workflows/rs-semver-checks.yml@main
with:
apt-dependencies: capnproto
secrets:
GITHUB_PAT: ${{ secrets.HUGRBOT_PAT }}
28 changes: 13 additions & 15 deletions .github/workflows/unsoundness.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Unsoundness checks

on:
push:
branches:
- main
schedule:
# Weekly on Monday at 04:00 UTC
- cron: '0 4 * * 1'
workflow_dispatch: {}

concurrency:
Expand Down Expand Up @@ -40,19 +40,17 @@ jobs:
run: cargo miri test


notify-slack:
uses: CQCL/hugrverse-actions/.github/workflows/slack-notifier.yml@main
create-issue:
uses: CQCL/hugrverse-actions/.github/workflows/create-issue.yml@main
needs: miri
if: always() && needs.miri.result == 'failure' && github.event_name == 'push'
with:
channel-id: 'C04SHCL4FKP'
slack-message: |
💥 The unsoundness check for `CQCL/hugr` failed.
<https://github.com/CQCL/hugr/actions/runs/${{ github.run_id }}|Please investigate>.
# Rate-limit the message to once per day
timeout-minutes: 1440
# A repository variable used to store the last message timestamp.
timeout-variable: "UNSOUNDNESS_MSG_SENT"
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
GITHUB_PAT: ${{ secrets.HUGRBOT_PAT }}
with:
title: "💥 Unsoundness check failed on main"
body: |
The unsoundness check for `CQCL/hugr` failed.
[https://github.com/CQCL/hugr/actions/runs/${{ github.run_id }}](Please investigate).
unique-label: "unsoundness-checks"
other-labels: "bug"
14 changes: 11 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ lto = "thin"

[workspace]
resolver = "2"
members = ["hugr", "hugr-core", "hugr-passes", "hugr-cli", "hugr-model"]
members = [
"hugr",
"hugr-core",
"hugr-passes",
"hugr-cli",
"hugr-model",
"hugr-llvm",
]
default-members = ["hugr", "hugr-core", "hugr-passes", "hugr-cli", "hugr-model"]

[workspace.package]
rust-version = "1.75"
Expand All @@ -27,7 +35,6 @@ portgraph = { version = "0.12.2" }
insta = { version = "1.34.0" }
bitvec = "1.0.1"
cgmath = "0.18.0"
context-iterators = "0.2.0"
cool_asserts = "2.0.3"
criterion = "0.5.1"
delegate = "0.13.0"
Expand Down Expand Up @@ -58,13 +65,14 @@ urlencoding = "2.1.2"
webbrowser = "1.0.0"
clap = { version = "4.5.4" }
clio = "0.3.5"
clap-verbosity-flag = "2.2.0"
clap-verbosity-flag = "3.0.1"
assert_cmd = "2.0.14"
assert_fs = "1.1.1"
predicates = "3.1.0"
indexmap = "2.3.0"
fxhash = "0.2.1"
bumpalo = { version = "3.16.0" }
pathsearch = "0.2.0"

[profile.dev.package]
insta.opt-level = 3
Expand Down
3 changes: 3 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ To setup the environment manually you will need:
- Rust `>=1.75`: https://www.rust-lang.org/tools/install
- uv `>=0.3`: docs.astral.sh/uv/getting-started/installation
- capnproto `>=1.0`: https://capnproto.org/install.html
- Optional: llvm `== 14.0`. The "llvm" feature (backed by the sub-crate `hugr-llvm`)
requires LLVM installed. We use the rust bindings
[llvm-sys](https://crates.io/crates/llvm-sys) to [llvm](https://llvm.org/),

Once you have these installed, you can install the required python dependencies and setup pre-commit hooks with:

Expand Down
Loading

0 comments on commit 26466db

Please sign in to comment.