From 30076e6fd544b2f1f2784366add9149d837cdd2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nedim=20Salki=C4=87?= Date: Thu, 28 Sep 2023 14:24:20 +0200 Subject: [PATCH] build: move forc builds to `pretest` and add `build:packages` (#1235) --- .changeset/perfect-apes-sniff.md | 2 ++ .github/workflows/test.yaml | 4 ++++ apps/demo-nodejs-esm/package.json | 1 - apps/demo-typegen/package.json | 2 +- apps/docs-snippets/package.json | 3 ++- package.json | 3 ++- packages/abi-typegen/package.json | 3 ++- packages/fuel-gauge/package.json | 4 ++-- packages/providers/package.json | 6 +++--- packages/script/package.json | 4 ++-- packages/script/scripts/build-call-test-script.sh | 12 ------------ packages/script/scripts/build-forc-projects.sh | 5 ----- packages/script/src/script.test.ts | 4 ++-- .../script/{src => test}/call-test-script/Forc.toml | 0 .../{src => test}/call-test-script/src/main.sw | 0 packages/utils/package.json | 3 ++- 16 files changed, 24 insertions(+), 32 deletions(-) create mode 100644 .changeset/perfect-apes-sniff.md delete mode 100755 packages/script/scripts/build-call-test-script.sh delete mode 100755 packages/script/scripts/build-forc-projects.sh rename packages/script/{src => test}/call-test-script/Forc.toml (100%) rename packages/script/{src => test}/call-test-script/src/main.sw (100%) diff --git a/.changeset/perfect-apes-sniff.md b/.changeset/perfect-apes-sniff.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/perfect-apes-sniff.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8d4529028ca..ea6b68749b6 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -31,6 +31,10 @@ jobs: - name: Build run: pnpm build + # linting of some tests depends on pretest being run so that it generates the necessary files + - name: Pretest + run: pnpm pretest + - name: Lint run: pnpm lint diff --git a/apps/demo-nodejs-esm/package.json b/apps/demo-nodejs-esm/package.json index 78f8a225a53..9fce7002a29 100644 --- a/apps/demo-nodejs-esm/package.json +++ b/apps/demo-nodejs-esm/package.json @@ -6,7 +6,6 @@ "type": "module", "license": "Apache-2.0", "scripts": { - "build": "pnpm test", "test": "node ./index.mjs" }, "dependencies": { diff --git a/apps/demo-typegen/package.json b/apps/demo-typegen/package.json index b6d93b06559..84e0f907255 100644 --- a/apps/demo-typegen/package.json +++ b/apps/demo-typegen/package.json @@ -4,7 +4,7 @@ "description": "Simple demo using Typegen generated types", "author": "Fuel Labs (https://fuel.network/)", "scripts": { - "build": "run-s build:forc build:types", + "pretest": "run-s build:forc build:types", "build:forc": "pnpm fuels-forc build -p contract", "build:types": "pnpm fuels typegen -i contract/out/debug/demo-contract-abi.json -o src/generated-types" }, diff --git a/apps/docs-snippets/package.json b/apps/docs-snippets/package.json index da27b3b62f9..bbff2f00f55 100644 --- a/apps/docs-snippets/package.json +++ b/apps/docs-snippets/package.json @@ -4,7 +4,8 @@ "description": "", "private": true, "scripts": { - "build": "pnpm fuels-forc build -p projects" + "pretest": "pnpm build:forc", + "build:forc": "pnpm fuels-forc build -p projects" }, "devDependencies": { "fuels": "workspace:*", diff --git a/package.json b/package.json index 78073f4b3e4..7226a358968 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,9 @@ }, "packageManager": "pnpm@8.6.1", "scripts": { - "dev": "nodemon --config nodemon.config.json -x 'turbo run build --filter=!fuel-gauge'", + "dev": "nodemon --config nodemon.config.json -x 'pnpm build:packages'", "build": "turbo run build", + "build:packages": "turbo run build --filter=!docs", "ci:test": "./scripts/ci-test.sh", "pretest": "turbo run pretest", "test": "jest --no-cache --runInBand --coverage", diff --git a/packages/abi-typegen/package.json b/packages/abi-typegen/package.json index f1d709782c9..1f96c7306e0 100644 --- a/packages/abi-typegen/package.json +++ b/packages/abi-typegen/package.json @@ -40,8 +40,9 @@ "dist" ], "scripts": { - "pretest": "pnpm fuels-forc build -p test/fixtures/forc-projects", + "pretest": "pnpm build:forc", "build": "tsup", + "build:forc": "pnpm fuels-forc build -p test/fixtures/forc-projects", "postbuild": "tsx ../../scripts/postbuild.ts" }, "license": "Apache-2.0", diff --git a/packages/fuel-gauge/package.json b/packages/fuel-gauge/package.json index 2a5028694f5..b295c62c8f2 100644 --- a/packages/fuel-gauge/package.json +++ b/packages/fuel-gauge/package.json @@ -5,8 +5,8 @@ "description": "", "author": "Fuel Labs (https://fuel.network/)", "scripts": { - "build": "run-s build:forc-projects build:process-predicates", - "build:forc-projects": "pnpm fuels-forc build -p fixtures/forc-projects", + "pretest": "run-s build:forc build:process-predicates", + "build:forc": "pnpm fuels-forc build -p fixtures/forc-projects", "build:process-predicates": "tsx ./scripts/process-predicates.ts" }, "license": "Apache-2.0", diff --git a/packages/providers/package.json b/packages/providers/package.json index 3784aad9841..c67df9256fc 100644 --- a/packages/providers/package.json +++ b/packages/providers/package.json @@ -17,10 +17,10 @@ "dist" ], "scripts": { - "update-schema": "get-graphql-schema http://localhost:4000/graphql > fuel-core-schema.graphql && prettier --write fuel-core-schema.graphql", - "build-operations": "pnpm graphql-codegen", - "prebuild": "pnpm build-operations", + "prebuild": "pnpm build:operations", "build": "tsup", + "build:schema": "get-graphql-schema http://localhost:4000/graphql > fuel-core-schema.graphql && prettier --write fuel-core-schema.graphql", + "build:operations": "pnpm graphql-codegen", "postbuild": "tsx ../../scripts/postbuild.ts" }, "license": "Apache-2.0", diff --git a/packages/script/package.json b/packages/script/package.json index 681f3c23b98..2f264f6e9a3 100644 --- a/packages/script/package.json +++ b/packages/script/package.json @@ -17,9 +17,9 @@ "dist" ], "scripts": { - "prebuild": "pnpm build-forc-projects", + "pretest": "pnpm build:forc", "build": "tsup", - "build-forc-projects": "./scripts/build-forc-projects.sh", + "build:forc": "pnpm fuels-forc build -p ./test/call-test-script", "postbuild": "tsx ../../scripts/postbuild.ts" }, "license": "Apache-2.0", diff --git a/packages/script/scripts/build-call-test-script.sh b/packages/script/scripts/build-call-test-script.sh deleted file mode 100755 index 5a64fb7c4e3..00000000000 --- a/packages/script/scripts/build-call-test-script.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -FUELS_DEBUG=${FUELS_DEBUG:-} -SCRIPT_DIR="src/call-test-script" -BIN_DIR="$SCRIPT_DIR/out/debug" - -pnpm fuels-forc build -p $SCRIPT_DIR --finalized-asm -if [[ -n "$FUELS_DEBUG" ]]; then - pnpm forc parse-bytecode "$BIN_DIR/call-test-script.bin" > "$BIN_DIR/call-test-script.txt" -fi diff --git a/packages/script/scripts/build-forc-projects.sh b/packages/script/scripts/build-forc-projects.sh deleted file mode 100755 index b1c0fd0d652..00000000000 --- a/packages/script/scripts/build-forc-projects.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -scripts/build-call-test-script.sh diff --git a/packages/script/src/script.test.ts b/packages/script/src/script.test.ts index cf1d3f95a27..9bf175da71e 100644 --- a/packages/script/src/script.test.ts +++ b/packages/script/src/script.test.ts @@ -18,10 +18,10 @@ import { join } from 'path'; import { jsonAbiMock, jsonAbiFragmentMock } from '../test/fixtures/mocks'; -import { Script } from './script'; +import { Script } from './index'; const scriptBin = readFileSync( - join(__dirname, './call-test-script/out/debug/call-test-script.bin') + join(__dirname, '../test/call-test-script/out/debug/call-test-script.bin') ); const setup = async () => { diff --git a/packages/script/src/call-test-script/Forc.toml b/packages/script/test/call-test-script/Forc.toml similarity index 100% rename from packages/script/src/call-test-script/Forc.toml rename to packages/script/test/call-test-script/Forc.toml diff --git a/packages/script/src/call-test-script/src/main.sw b/packages/script/test/call-test-script/src/main.sw similarity index 100% rename from packages/script/src/call-test-script/src/main.sw rename to packages/script/test/call-test-script/src/main.sw diff --git a/packages/utils/package.json b/packages/utils/package.json index 82771fd30f4..bca4f2e7390 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -29,8 +29,9 @@ "dist" ], "scripts": { - "pretest": "pnpm fuels-forc build -p test/forc-projects/simple", + "pretest": "pnpm build:forc", "build": "tsup", + "build:forc": "pnpm fuels-forc build -p test/forc-projects/simple", "postbuild": "tsx ../../scripts/postbuild.ts" }, "license": "Apache-2.0",