Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added the config file for the release #3

Merged
merged 8 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/NIGHTLY_CANARY_DIED.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: "Tests fail on latest Nargo nightly release"
assignees: TomAFrench, kashbrti, jtriley-eth
---

The tests on this Noir project have started failing when using the latest nightly release of the Noir compiler. This likely means that there have been breaking changes for which this project needs to be updated to take into account.

Check the [{{env.WORKFLOW_NAME}}]({{env.WORKFLOW_URL}}) workflow for details.
48 changes: 48 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Benchmarks

on:
push:
branches:
- master
pull_request:

jobs:
test:
name: Benchmark library
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install Nargo
uses: noir-lang/noirup@v0.1.3
with:
toolchain: 0.36.0

- name: Install bb
run: |
npm install -g bbup
bbup -nv 0.36.0

- name: Build Noir benchmark programs
run: nargo export

- name: Generate gates report
run: ./scripts/build-gates-report.sh
env:
BACKEND: /home/runner/.bb/bb

- name: Compare gates reports
id: gates_diff
uses: noir-lang/noir-gates-diff@1931aaaa848a1a009363d6115293f7b7fc72bb87
with:
report: gates_report.json
summaryQuantile: 0.9 # only display the 10% most significant circuit size diffs in the summary (defaults to 20%)

- name: Add gates diff to sticky comment
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: marocchino/sticky-pull-request-comment@v2
with:
# delete the comment in case changes no longer impact circuit sizes
delete: ${{ !steps.gates_diff.outputs.markdown }}
message: ${{ steps.gates_diff.outputs.markdown }}
40 changes: 40 additions & 0 deletions .github/workflows/nightly-canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Noir Nightly Canary

on:
schedule:
# Run a check at 9 AM UTC
- cron: "0 9 * * *"

env:
CARGO_TERM_COLOR: always

permissions:
issues: write

jobs:
test:
name: Test on Nargo ${{matrix.toolchain}}
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install Nargo
uses: noir-lang/noirup@v0.1.3
with:
toolchain: nightly

- name: Run Noir tests
run: nargo test

- name: Alert on dead links
uses: JasonEtco/create-an-issue@v2
if: ${{ failure() }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
WORKFLOW_NAME: ${{ github.workflow }}
WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
with:
update_existing: true
filename: .github/NIGHTLY_CANARY_DIED.md

30 changes: 30 additions & 0 deletions .github/workflows/pull-request-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Pull Request

on:
merge_group:
pull_request_target:
types:
- opened
- reopened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
conventional-title:
name: Validate PR title is Conventional Commit
runs-on: ubuntu-latest
steps:
- name: Check title
if: github.event_name == 'pull_request_target'
uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types: |
fix
feat
chore

21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release

on:
push:
branches:
- master

jobs:
release-please:
name: Create Release
outputs:
release-pr: ${{ steps.release.outputs.pr }}
tag-name: ${{ steps.release.outputs.tag_name }}
runs-on: ubuntu-latest
steps:
- name: Run release-please
id: release
uses: google-github-actions/release-please-action@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
command: manifest
88 changes: 88 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Noir tests

on:
push:
branches:
- master
pull_request:

env:
CARGO_TERM_COLOR: always
MINIMUM_NOIR_VERSION: v0.36.0

jobs:
noir-version-list:
name: Query supported Noir versions
runs-on: ubuntu-latest
outputs:
noir_versions: ${{ steps.get_versions.outputs.versions }}

steps:
- name: Checkout sources
id: get_versions
run: |
# gh returns the Noir releases in reverse chronological order so we keep all releases published after the minimum supported version.
VERSIONS=$(gh release list -R noir-lang/noir --exclude-pre-releases --json tagName -q 'map(.tagName) | index(env.MINIMUM_NOIR_VERSION) as $index | if $index then .[0:$index+1] else [env.MINIMUM_NOIR_VERSION] end')
echo "versions=$VERSIONS"
echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}

test:
needs: [noir-version-list]
name: Test on Nargo ${{matrix.toolchain}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain: ${{ fromJson( needs.noir-version-list.outputs.noir_versions )}}
include:
- toolchain: nightly
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install Nargo
uses: noir-lang/noirup@v0.1.3
with:
toolchain: ${{ matrix.toolchain }}

- name: Run Noir tests
run: nargo test

format:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install Nargo
uses: noir-lang/noirup@v0.1.3
with:
toolchain: ${{ env.MINIMUM_NOIR_VERSION }}

- name: Run formatter
run: nargo fmt --check

# This is a job which depends on all test jobs and reports the overall status.
# This allows us to add/remove test jobs without having to update the required workflows.
tests-end:
name: Noir End
runs-on: ubuntu-latest
# We want this job to always run (even if the dependant jobs fail) as we want this job to fail rather than skipping.
if: ${{ always() }}
needs:
- test
- format

steps:
- name: Report overall success
run: |
if [[ $FAIL == true ]]; then
exit 1
else
exit 0
fi
env:
# We treat any cancelled, skipped or failing jobs as a failure for the workflow as a whole.
FAIL: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }}
1 change: 1 addition & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{".": "0.0.0"}
16 changes: 16 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"release-type": "simple",
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true,
"pull-request-title-pattern": "chore: Release ${version}",
"group-pull-request-title-pattern": "chore: Release ${version}",
"packages": {
".": {
"release-type": "simple",
"include-component-in-tag": false
}
},
"plugins": [
"sentence-case"
]
}
35 changes: 35 additions & 0 deletions scripts/build-gates-report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -e

BACKEND=${BACKEND:-bb}

cd $(dirname "$0")/../

artifacts_path="./export"
artifacts=$(ls $artifacts_path)

echo "{\"programs\": [" > gates_report.json

# Bound for checking where to place last parentheses
NUM_ARTIFACTS=$(ls -1q "$artifacts_path" | wc -l)

ITER="1"
for artifact in $artifacts; do
ARTIFACT_NAME=$(basename "$artifact")

GATES_INFO=$($BACKEND gates -b "$artifacts_path/$artifact")
MAIN_FUNCTION_INFO=$(echo $GATES_INFO | jq -r '.functions[0] | .name = "main"')
echo "{\"package_name\": \"$ARTIFACT_NAME\", \"functions\": [$MAIN_FUNCTION_INFO]" >> gates_report.json

if (($ITER == $NUM_ARTIFACTS)); then
echo "}" >> gates_report.json
else
echo "}, " >> gates_report.json
fi

ITER=$(( $ITER + 1 ))
done

echo "]}" >> gates_report.json


45 changes: 31 additions & 14 deletions src/lib.nr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
unconstrained fn __get_shuffle_indices<T, let N: u32>(
lhs: [T; N],
rhs: [T; N]
) -> [Field; N] where T: std::cmp::Eq {
let mut shuffle_indices: [Field;N ] = [0; N];
unconstrained fn __get_shuffle_indices<T, let N: u32>(lhs: [T; N], rhs: [T; N]) -> [Field; N]
where
T: std::cmp::Eq,
{
let mut shuffle_indices: [Field; N] = [0; N];

let mut shuffle_mask: [bool; N] = [false; N];
for i in 0..N {
Expand Down Expand Up @@ -36,25 +36,35 @@ unconstrained fn __get_index<let N: u32>(indices: [Field; N], idx: Field) -> Fie
result
}

pub fn check_shuffle<T, let N: u32>(lhs: [T; N], rhs: [T; N]) where T: std::cmp::Eq {
let shuffle_indices = __get_shuffle_indices(lhs, rhs);
pub fn check_shuffle<T, let N: u32>(lhs: [T; N], rhs: [T; N])
where
T: std::cmp::Eq,
{
//@Safety: check the comments below
let shuffle_indices = unsafe { __get_shuffle_indices(lhs, rhs) };

for i in 0..N {
let idx = __get_index(shuffle_indices, i as Field);
let idx = unsafe { __get_index(shuffle_indices, i as Field) };
// checks the relation between shuffle_indices and output of __get_index
assert_eq(shuffle_indices[idx], i as Field);
}
for i in 0..N {
let idx = shuffle_indices[i];
let expected = rhs[idx];
let result = lhs[i];
// checks the relation between shuffle_indices and the lhs, rhs inputs
assert_eq(expected, result);
}
}

pub fn get_shuffle_indices<T, let N: u32>(lhs: [T; N], rhs: [T; N]) -> [Field; N] where T: std::cmp::Eq {
let shuffle_indices = __get_shuffle_indices(lhs, rhs);
pub fn get_shuffle_indices<T, let N: u32>(lhs: [T; N], rhs: [T; N]) -> [Field; N]
where
T: std::cmp::Eq,
{
//@Safety: as explained in check_shuffle function
let shuffle_indices = unsafe { __get_shuffle_indices(lhs, rhs) };
for i in 0..N {
let idx = __get_index(shuffle_indices, i as Field);
let idx = unsafe { __get_index(shuffle_indices, i as Field) };
assert_eq(shuffle_indices[idx], i as Field);
}
for i in 0..N {
Expand All @@ -70,7 +80,7 @@ mod test {
struct CompoundStruct {
a: bool,
b: Field,
c: u64
c: u64,
}
impl std::cmp::Eq for CompoundStruct {
fn eq(self, other: Self) -> bool {
Expand Down Expand Up @@ -114,15 +124,22 @@ mod test {
CompoundStruct { a: false, b: -100, c: 54321 },
CompoundStruct { a: true, b: 5, c: 0xffffffffffffffff },
CompoundStruct { a: true, b: 9814, c: 0xeeffee0011001133 },
CompoundStruct { a: false, b: 0x155, c: 0 }
CompoundStruct { a: false, b: 0x155, c: 0 },
];
let rhs: [CompoundStruct; 5] = [
CompoundStruct { a: false, b: 0x155, c: 0 },
CompoundStruct { a: false, b: 0, c: 12345 },
CompoundStruct { a: false, b: -100, c: 54321 },
CompoundStruct { a: true, b: 9814, c: 0xeeffee0011001133 },
CompoundStruct { a: true, b: 5, c: 0xffffffffffffffff }
CompoundStruct { a: true, b: 5, c: 0xffffffffffffffff },
];
check_shuffle(lhs, rhs);
}
}

#[export]
fn bench_test() {
let lhs: [Field; 5] = [0, 1, 2, 3, 4];
let rhs: [Field; 5] = [2, 0, 3, 1, 4];
check_shuffle(lhs, rhs);
}
Loading