diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/1-baseline.json b/cli/integration_tests/edit_turbo_json/fixture-configs/1-baseline.json new file mode 100644 index 00000000000000..bd301c8c5ae151 --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/1-baseline.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo.txt"], + "globalEnv": ["SOME_ENV_VAR"], + "pipeline": { + "build": { + "env": ["NODE_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["banana.txt", "apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/2-update-pipeline.json b/cli/integration_tests/edit_turbo_json/fixture-configs/2-update-pipeline.json new file mode 100644 index 00000000000000..64ea6bc8443c05 --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/2-update-pipeline.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo.txt"], + "globalEnv": ["SOME_ENV_VAR"], + "pipeline": { + "build": { + "env": ["NODE_ENV", "NEW_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["banana.txt", "apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/3-update-global-env.json b/cli/integration_tests/edit_turbo_json/fixture-configs/3-update-global-env.json new file mode 100644 index 00000000000000..25b22ced860fb1 --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/3-update-global-env.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo.txt"], + "globalEnv": ["SOME_ENV_VAR", "NEW_ENV"], + "pipeline": { + "build": { + "env": ["NODE_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["banana.txt", "apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/4-update-global-deps.json b/cli/integration_tests/edit_turbo_json/fixture-configs/4-update-global-deps.json new file mode 100644 index 00000000000000..7d3890d08051b2 --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/4-update-global-deps.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo*.txt"], + "globalEnv": ["SOME_ENV_VAR"], + "pipeline": { + "build": { + "env": ["NODE_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["banana.txt", "apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/5-update-global-deps-materially.json b/cli/integration_tests/edit_turbo_json/fixture-configs/5-update-global-deps-materially.json new file mode 100644 index 00000000000000..228e5cdb61fe80 --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/5-update-global-deps-materially.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo.txt", "bar.txt"], + "globalEnv": ["SOME_ENV_VAR"], + "pipeline": { + "build": { + "env": ["NODE_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["banana.txt", "apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/6-update-passthrough-env.json b/cli/integration_tests/edit_turbo_json/fixture-configs/6-update-passthrough-env.json new file mode 100644 index 00000000000000..b2f7149a254aaa --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/6-update-passthrough-env.json @@ -0,0 +1,20 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo.txt"], + "globalEnv": ["SOME_ENV_VAR"], + "experimentalGlobalPassThroughEnv": ["PASSTHROUGH"], + "pipeline": { + "build": { + "env": ["NODE_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["banana.txt", "apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/a-baseline.json b/cli/integration_tests/edit_turbo_json/fixture-configs/a-baseline.json new file mode 100644 index 00000000000000..bd301c8c5ae151 --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/a-baseline.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo.txt"], + "globalEnv": ["SOME_ENV_VAR"], + "pipeline": { + "build": { + "env": ["NODE_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["banana.txt", "apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/fixture-configs/b-change-only-my-app.json b/cli/integration_tests/edit_turbo_json/fixture-configs/b-change-only-my-app.json new file mode 100644 index 00000000000000..ec4a69bbffcff8 --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/fixture-configs/b-change-only-my-app.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": ["foo.txt"], + "globalEnv": ["SOME_ENV_VAR"], + "pipeline": { + "build": { + "env": ["NODE_ENV"], + "outputs": [] + }, + "my-app#build": { + "outputs": ["apple.json"] + }, + + "something": {}, + "//#something": {}, + + "maybefails": {} + } +} diff --git a/cli/integration_tests/edit_turbo_json/global.t b/cli/integration_tests/edit_turbo_json/global.t new file mode 100644 index 00000000000000..39fc736401eb97 --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/global.t @@ -0,0 +1,32 @@ +Setup + $ . ${TESTDIR}/../_helpers/setup.sh + $ . ${TESTDIR}/../_helpers/setup_monorepo.sh $(pwd) + +Baseline global hash + $ cp "$TESTDIR/fixture-configs/1-baseline.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ BASELINE=$(${TURBO} build -vv 2>&1 | "$TESTDIR/../_helpers/get-global-hash.sh") + +Update pipeline: global hash remains stable. + $ cp "$TESTDIR/fixture-configs/2-update-pipeline.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ UPDATE_PIPELINE=$(${TURBO} build -vv --experimental-env-mode=infer 2>&1 | "$TESTDIR/../_helpers/get-global-hash.sh") + $ test $BASELINE = $UPDATE_PIPELINE + +Update globalEnv: global hash changes. + $ cp "$TESTDIR/fixture-configs/3-update-global-env.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ NEW_GLOBAL_ENV=$(${TURBO} build -vv --experimental-env-mode=infer 2>&1 | "$TESTDIR/../_helpers/get-global-hash.sh") + $ test $BASELINE != $NEW_GLOBAL_ENV + +Update globalDeps in a non-material way: global hash remains stable. + $ cp "$TESTDIR/fixture-configs/4-update-global-deps.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ NEW_GLOBAL_DEPS=$(${TURBO} build -vv --experimental-env-mode=infer 2>&1 | "$TESTDIR/../_helpers/get-global-hash.sh") + $ test $BASELINE = $NEW_GLOBAL_DEPS + +Update globalDeps in a material way: global hash changes. + $ cp "$TESTDIR/fixture-configs/5-update-global-deps-materially.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ NEW_GLOBAL_DEPS=$(${TURBO} build -vv --experimental-env-mode=infer 2>&1 | "$TESTDIR/../_helpers/get-global-hash.sh") + $ test $BASELINE != $NEW_GLOBAL_DEPS + +Update passthroughEnv: global hash changes. + $ cp "$TESTDIR/fixture-configs/6-update-passthrough-env.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ NEW_GLOBAL_PASSTHROUGH=$(${TURBO} build -vv --experimental-env-mode=infer 2>&1 | "$TESTDIR/../_helpers/get-global-hash.sh") + $ test $BASELINE != $NEW_GLOBAL_PASSTHROUGH diff --git a/cli/integration_tests/edit_turbo_json/task.t b/cli/integration_tests/edit_turbo_json/task.t new file mode 100644 index 00000000000000..0a09c8b1ba06d8 --- /dev/null +++ b/cli/integration_tests/edit_turbo_json/task.t @@ -0,0 +1,35 @@ +Setup + $ . ${TESTDIR}/../_helpers/setup.sh + $ . ${TESTDIR}/../_helpers/setup_monorepo.sh $(pwd) + +Baseline task hashes + $ cp "$TESTDIR/fixture-configs/a-baseline.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ ${TURBO} build --dry=json | jq -r '.tasks | sort_by(.taskId)[] | {taskId, hash}' + { + "taskId": "another#build", + "hash": "4c4f0e076ebc3a2a" + } + { + "taskId": "my-app#build", + "hash": "9431e2a02286769a" + } + { + "taskId": "util#build", + "hash": "e6ceb7aa9a6948f8" + } + +Change only my-app#build + $ cp "$TESTDIR/fixture-configs/b-change-only-my-app.json" "$(pwd)/turbo.json" && git commit -am "no comment" --quiet + $ ${TURBO} build --dry=json | jq -r '.tasks | sort_by(.taskId)[] | {taskId, hash}' + { + "taskId": "another#build", + "hash": "4c4f0e076ebc3a2a" + } + { + "taskId": "my-app#build", + "hash": "WAT" + } + { + "taskId": "util#build", + "hash": "e6ceb7aa9a6948f8" + }