Skip to content

Commit

Permalink
chore: introduce workspace for js packages (#2677)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
Co-authored-by: Tom French <tom@tomfren.ch>
  • Loading branch information
3 people authored Sep 14, 2023
1 parent 2103b2f commit f804579
Show file tree
Hide file tree
Showing 38 changed files with 3,215 additions and 12,309 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ runs:
- name: Install node
uses: actions/setup-node@v3
with:
node-version: 18.15
node-version: 18.17.1
- name: Cache
uses: actions/cache@v3
id: cache
Expand Down
60 changes: 14 additions & 46 deletions .github/workflows/abi_wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ jobs:
- name: Build noirc_abi_wasm
run: |
nix build -L .#noirc_abi_wasm
cp -r ./result/nodejs ./tooling/noirc_abi_wasm
cp -r ./result/web ./tooling/noirc_abi_wasm
- name: Export cache from nix store
if: ${{ steps.cache.outputs.cache-hit != 'true' && github.event_name != 'merge_group' }}
Expand All @@ -70,48 +72,13 @@ jobs:
path: ${{ env.UPLOAD_PATH }}
retention-days: 10

noirc-abi-wasm-test-node:
needs: [noirc-abi-wasm-build]
name: Node.js Tests
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: noirc_abi_wasm
path: ./result

- name: Set up test environment
uses: ./.github/actions/setup
with:
working-directory: ./tooling/noirc_abi_wasm
- name: Install workspace dependencies
run: |
yarn install --immutable
- name: Run node tests
working-directory: ./tooling/noirc_abi_wasm
run: yarn install && yarn test

noirc-abi-wasm-test-browser:
needs: [noirc-abi-wasm-build]
name: Browser Tests
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: noirc_abi_wasm
path: ./result

- name: Query playwright version
working-directory: ./tooling/noirc_abi_wasm
run: echo "PLAYWRIGHT_VERSION=$(yarn info @web/test-runner-playwright --json | jq .children.Version)" >> $GITHUB_ENV
run: |
yarn workspace @noir-lang/noirc_abi test
- name: Cache playwright binaries
uses: actions/cache@v3
Expand All @@ -121,18 +88,19 @@ jobs:
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}

- name: Set up test environment
uses: ./.github/actions/setup
with:
working-directory: ./tooling/noirc_abi_wasm
- name: Query playwright version
working-directory: ./tooling/noirc_abi_wasm
run: echo "PLAYWRIGHT_VERSION=$(yarn info @web/test-runner-playwright --json | jq .children.Version)" >> $GITHUB_ENV

- name: Install playwright deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
working-directory: ./tooling/noirc_abi_wasm
run: |
npx playwright install
npx playwright install-deps
- name: Run browser tests
working-directory: ./tooling/noirc_abi_wasm
run: yarn install && yarn test:browser
run: |
yarn workspace @noir-lang/noirc_abi test:browser
14 changes: 5 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,9 @@ jobs:
- name: Test built artifact
if: matrix.target == 'x86_64-apple-darwin'
run: |
cp ./target/${{ matrix.target }}/release/nargo ~/.cargo/bin/
cd release-tests
yarn install
yarn test
cp ./target/${{ matrix.target }}/release/nargo ~/.cargo/bin/
yarn install --immutable
yarn workspace release-tests test
- name: Upload binaries to release tag
uses: svenstaro/upload-release-action@v2
Expand Down Expand Up @@ -145,10 +143,8 @@ jobs:
if: startsWith(matrix.target, 'x86_64-unknown-linux')
run: |
cp ./target/${{ matrix.target }}/release/nargo ~/.cargo/bin/
cd release-tests
yarn install
yarn test
yarn install --immutable
yarn workspace release-tests test
- name: Upload binaries to release tag
uses: svenstaro/upload-release-action@v2
Expand Down
35 changes: 8 additions & 27 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ jobs:
- name: Build noir_wasm package
run: |
nix build -L .#wasm
mkdir -p ./.packages/noir_wasm
cp -r ./result/* ./.packages/noir_wasm/
echo "UPLOAD_PATH=$(readlink -f result)" >> $GITHUB_ENV
cp -r ./result/nodejs ./compiler/wasm
cp -r ./result/web ./compiler/wasm
- name: Upload `noir_wasm` artifact
uses: actions/upload-artifact@v3
Expand All @@ -66,9 +66,9 @@ jobs:
- name: Build noirc_abi_wasm package
run: |
nix build -L .#noirc_abi_wasm
mkdir -p ./.packages/noirc_abi_wasm
cp -r ./result/* ./.packages/noirc_abi_wasm/
echo "UPLOAD_PATH=$(readlink -f result)" >> $GITHUB_ENV
cp -r ./result/nodejs ./tooling/noirc_abi_wasm
cp -r ./result/web ./tooling/noirc_abi_wasm
- name: Upload `noirc_abi_wasm` artifact
uses: actions/upload-artifact@v3
Expand All @@ -77,31 +77,12 @@ jobs:
path: ${{ env.UPLOAD_PATH }}
retention-days: 3

- name: Build `acvm_js` package
working-directory: ./acvm
run: |
nix build -L .#
mkdir -p ../.packages/acvm_js
cp -r ./result/* ../.packages/acvm_js/
echo "UPLOAD_PATH=$(readlink -f result)" >> $GITHUB_ENV
- name: Upload `acvm_js` artifact
uses: actions/upload-artifact@v3
with:
name: acvm_js
path: ${{ env.UPLOAD_PATH }}
retention-days: 3

- name: Install `integration-tests` dependencies
working-directory: ./compiler/integration-tests
run: yarn install

- name: Run `integration-tests`
working-directory: ./compiler/integration-tests
run: |
yarn test:browser
- name: Alert on nightly test failure
yarn install --immutable
yarn test:integration
- name: Alert on nightly test failure
uses: JasonEtco/create-an-issue@v2
if: ${{ failure() && github.event_name == 'schedule' }}
env:
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/test-source-resolver.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ jobs:
uses: actions/checkout@v3

- name: Install dependencies
working-directory: ./compiler/source-resolver
run: npm install
run: yarn install --immutable

- name: Build noir-source-resolver
working-directory: ./compiler/source-resolver
run: npm run build
run: yarn workspace @noir-lang/noir-source-resolver build

- name: Run tests
working-directory: ./compiler/source-resolver
run: npm run test
run: yarn workspace @noir-lang/noir-source-resolver test
23 changes: 8 additions & 15 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
uses: actions/download-artifact@v3
with:
name: noir_wasm
path: ./compiler/wasm/result
path: ./compiler/wasm/downloaded

- name: Download nargo binary
uses: actions/download-artifact@v3
Expand All @@ -132,23 +132,16 @@ jobs:
chmod +x $nargo_binary
$nargo_binary compile
- name: Set up test environment
uses: ./.github/actions/setup
with:
working-directory: ./compiler/wasm

- name: Install dependencies
working-directory: ./compiler/wasm
run: yarn install

- name: Install playwright deps
working-directory: ./compiler/wasm
run: |
npx playwright install
npx playwright install-deps
cp -r ./compiler/wasm/downloaded/nodejs ./compiler/wasm
cp -r ./compiler/wasm/downloaded/web ./compiler/wasm
yarn install --immutable
yarn workspace @noir-lang/noir-source-resolver build
- name: Run tests
working-directory: ./compiler/wasm
run: |
yarn test:browser
yarn test:node
yarn workspace @noir-lang/noir_wasm test:browser
yarn workspace @noir-lang/noir_wasm test:node
17 changes: 16 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ examples/9
node_modules
pkg/

# Yarn
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Source resolver
compiler/source-resolver/node_modules
compiler/source-resolver/lib
Expand All @@ -27,7 +36,13 @@ result
**/target
!tooling/nargo_cli/tests/acir_artifacts/*/target
!tooling/nargo_cli/tests/acir_artifacts/*/target/witness.gz

!compiler/wasm/noir-script/target
# Github Actions scratch space
# This gives a location to download artifacts into the repository in CI without making git dirty.
libbarretenberg-wasm32

# Wasm build atifacts
compiler/wasm/nodejs
compiler/wasm/web
tooling/noirc_abi_wasm/nodejs
tooling/noirc_abi_wasm/web
9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-3.6.3.cjs
33 changes: 11 additions & 22 deletions compiler/integration-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
{
"name": "integration-tests",
"version": "1.0.0",
"description": "",
"license": "(MIT OR Apache-2.0)",
"main": "index.js",
"scripts": {
"test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha",
"build": "echo Integration Test build step",
"test": "yarn test:browser",
"test:browser": "web-test-runner",
"test:node": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha",
"test:integration:browser": "web-test-runner test//integration/browser/**/*.test.ts",
"test:integration:browser:watch": "web-test-runner test/integration/browser/**/*.test.ts --watch"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@esm-bundle/chai": "^4.3.4-fix.0",
"@web/dev-server-esbuild": "^0.3.6",
"@web/test-runner": "^0.15.3",
"@web/test-runner-webdriver": "^0.7.0",
"chai": "^4.3.7",
"fflate": "^0.8.0",
"mocha": "^10.2.0",
"smol-toml": "^1.1.2",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
},
"dependencies": {
"@aztec/bb.js": "^0.5.1",
"@noir-lang/acvm_js": "./../../.packages/acvm_js",
"@noir-lang/noir-source-resolver": "^1.1.4",
"@noir-lang/noir_wasm": "./../../.packages/noir_wasm",
"@noir-lang/noirc_abi": "./../../.packages/noirc_abi_wasm"
"@noir-lang/acvm_js": "^0.26.0",
"@noir-lang/noir-source-resolver": "workspace:*",
"@noir-lang/noir_wasm": "workspace:*",
"@noir-lang/noirc_abi": "workspace:*",
"@web/dev-server-esbuild": "^0.3.6",
"@web/test-runner": "^0.15.3",
"@web/test-runner-playwright": "^0.10.0",
"@web/test-runner-webdriver": "^0.7.0"
}
}
7 changes: 7 additions & 0 deletions compiler/integration-tests/web-test-runner.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { defaultReporter } from "@web/test-runner";
import { summaryReporter } from "@web/test-runner";
import { fileURLToPath } from "url";
import { esbuildPlugin } from "@web/dev-server-esbuild";
import { webdriverLauncher } from "@web/test-runner-webdriver";

// eslint-disable-next-line no-undef
const reporter = process.env.CI ? summaryReporter() : defaultReporter();

export default {
browsers: [
webdriverLauncher({
Expand All @@ -26,6 +31,8 @@ export default {
ui: "bdd",
},
},
// eslint-disable-next-line no-undef
rootDir: fileURLToPath(new URL("./../..", import.meta.url)),
testsFinishTimeout: 60 * 20e3, // 20 minutes
reporters: [reporter],
};
Loading

0 comments on commit f804579

Please sign in to comment.