From 0e74e822a2836d8df84166c19bd76865db7bdc95 Mon Sep 17 00:00:00 2001 From: Lucas Vieira Date: Mon, 23 Dec 2024 15:42:43 -0300 Subject: [PATCH] feat(nx-python): enable caching in UV and Poetry project generators --- .../__snapshots__/generator.spec.ts.snap | 45 +++++++++++++++++++ .../generators/poetry-project/generator.ts | 4 ++ .../__snapshots__/generator.spec.ts.snap | 44 ++++++++++++++++++ .../src/generators/uv-project/generator.ts | 4 ++ 4 files changed, 97 insertions(+) diff --git a/packages/nx-python/src/generators/poetry-project/__snapshots__/generator.spec.ts.snap b/packages/nx-python/src/generators/poetry-project/__snapshots__/generator.spec.ts.snap index 24125b8..5215f73 100644 --- a/packages/nx-python/src/generators/poetry-project/__snapshots__/generator.spec.ts.snap +++ b/packages/nx-python/src/generators/poetry-project/__snapshots__/generator.spec.ts.snap @@ -19,6 +19,7 @@ exports[`application generator > as-provided > should run successfully minimal c "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -121,6 +122,7 @@ exports[`application generator > as-provided > should run successfully minimal c "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -223,6 +225,7 @@ exports[`application generator > custom template dir > should run successfully w "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -307,6 +310,7 @@ exports[`application generator > individual package > should run successfully mi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -409,6 +413,7 @@ exports[`application generator > individual package > should run successfully mi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -511,6 +516,7 @@ exports[`application generator > individual package > should run successfully mi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -616,6 +622,7 @@ exports[`application generator > individual package > should run successfully mi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -718,6 +725,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -740,6 +748,7 @@ exports[`application generator > individual package > should run successfully wi }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -848,6 +857,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -870,6 +880,7 @@ exports[`application generator > individual package > should run successfully wi }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -890,6 +901,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "poetry run pytest tests/", @@ -1016,6 +1028,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -1038,6 +1051,7 @@ exports[`application generator > individual package > should run successfully wi }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -1058,6 +1072,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "poetry run pytest tests/", @@ -1184,6 +1199,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -1206,6 +1222,7 @@ exports[`application generator > individual package > should run successfully wi }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -1226,6 +1243,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "poetry run pytest tests/", @@ -1352,6 +1370,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -1374,6 +1393,7 @@ exports[`application generator > individual package > should run successfully wi }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -1394,6 +1414,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "poetry run pytest tests/", @@ -1520,6 +1541,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -1542,6 +1564,7 @@ exports[`application generator > individual package > should run successfully wi }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -1562,6 +1585,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "poetry run pytest tests/", @@ -1688,6 +1712,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -1710,6 +1735,7 @@ exports[`application generator > individual package > should run successfully wi }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -1730,6 +1756,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "poetry run pytest tests/", @@ -1843,6 +1870,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -1865,6 +1893,7 @@ exports[`application generator > individual package > should run successfully wi }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -1885,6 +1914,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "poetry run pytest tests/", @@ -2056,6 +2086,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -2078,6 +2109,7 @@ exports[`application generator > individual package > should run successfully wi }, }, "lint": { + "cache": true, "executor": "@nxlv/python:ruff-check", "options": { "lintFilePatterns": [ @@ -2099,6 +2131,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "poetry run pytest tests/", @@ -2291,6 +2324,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -2313,6 +2347,7 @@ exports[`application generator > individual package > should run successfully wi }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -2333,6 +2368,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "poetry run pytest tests/", @@ -2505,6 +2541,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -2527,6 +2564,7 @@ exports[`application generator > individual package > should run successfully wi }, }, "lint": { + "cache": true, "executor": "@nxlv/python:ruff-check", "options": { "lintFilePatterns": [ @@ -2648,6 +2686,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -2670,6 +2709,7 @@ exports[`application generator > individual package > should run successfully wi }, }, "lint": { + "cache": true, "executor": "@nxlv/python:ruff-check", "options": { "lintFilePatterns": [ @@ -2691,6 +2731,7 @@ exports[`application generator > individual package > should run successfully wi "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "poetry run pytest tests/", @@ -2821,6 +2862,7 @@ exports[`application generator > shared virtual environment > should run success "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -2943,6 +2985,7 @@ exports[`application generator > shared virtual environment > should run success "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -3065,6 +3108,7 @@ exports[`application generator > shared virtual environment > should run success "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -3188,6 +3232,7 @@ exports[`application generator > shared virtual environment > should run success "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, diff --git a/packages/nx-python/src/generators/poetry-project/generator.ts b/packages/nx-python/src/generators/poetry-project/generator.ts index 23e2fc4..2aede53 100644 --- a/packages/nx-python/src/generators/poetry-project/generator.ts +++ b/packages/nx-python/src/generators/poetry-project/generator.ts @@ -293,6 +293,7 @@ export default async function ( lockedVersions: normalizedOptions.buildLockedVersions, bundleLocalDependencies: normalizedOptions.buildBundleLocalDependencies, }, + cache: true, }, install: { executor: '@nxlv/python:install', @@ -315,6 +316,7 @@ export default async function ( options: { outputFile: `reports/${normalizedOptions.projectRoot}/pylint.txt`, }, + cache: true, }; } @@ -327,6 +329,7 @@ export default async function ( options.unitTestRunner === 'pytest' ? ['tests'] : [], ), }, + cache: true, }; } @@ -341,6 +344,7 @@ export default async function ( command: `poetry run pytest tests/`, cwd: normalizedOptions.projectRoot, }, + cache: true, }; } diff --git a/packages/nx-python/src/generators/uv-project/__snapshots__/generator.spec.ts.snap b/packages/nx-python/src/generators/uv-project/__snapshots__/generator.spec.ts.snap index d47767a..6eabbca 100644 --- a/packages/nx-python/src/generators/uv-project/__snapshots__/generator.spec.ts.snap +++ b/packages/nx-python/src/generators/uv-project/__snapshots__/generator.spec.ts.snap @@ -19,6 +19,7 @@ exports[`application generator > as-provided > should run successfully minimal c "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -125,6 +126,7 @@ exports[`application generator > as-provided > should run successfully minimal c "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -231,6 +233,7 @@ exports[`application generator > custom template dir > should run successfully w "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -312,6 +315,7 @@ exports[`application generator > project > should run successfully minimal confi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -420,6 +424,7 @@ exports[`application generator > project > should run successfully minimal confi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -531,6 +536,7 @@ exports[`application generator > project > should run successfully minimal confi "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -639,6 +645,7 @@ exports[`application generator > project > should run successfully with flake8 l "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -660,6 +667,7 @@ exports[`application generator > project > should run successfully with flake8 l }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -772,6 +780,7 @@ exports[`application generator > project > should run successfully with flake8 l "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -793,6 +802,7 @@ exports[`application generator > project > should run successfully with flake8 l }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -813,6 +823,7 @@ exports[`application generator > project > should run successfully with flake8 l "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "uv run pytest tests/", @@ -943,6 +954,7 @@ exports[`application generator > project > should run successfully with flake8 l "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -964,6 +976,7 @@ exports[`application generator > project > should run successfully with flake8 l }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -984,6 +997,7 @@ exports[`application generator > project > should run successfully with flake8 l "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "uv run pytest tests/", @@ -1114,6 +1128,7 @@ exports[`application generator > project > should run successfully with flake8 l "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -1135,6 +1150,7 @@ exports[`application generator > project > should run successfully with flake8 l }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -1155,6 +1171,7 @@ exports[`application generator > project > should run successfully with flake8 l "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "uv run pytest tests/", @@ -1285,6 +1302,7 @@ exports[`application generator > project > should run successfully with flake8 l "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -1306,6 +1324,7 @@ exports[`application generator > project > should run successfully with flake8 l }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -1326,6 +1345,7 @@ exports[`application generator > project > should run successfully with flake8 l "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "uv run pytest tests/", @@ -1456,6 +1476,7 @@ exports[`application generator > project > should run successfully with flake8 l "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -1477,6 +1498,7 @@ exports[`application generator > project > should run successfully with flake8 l }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -1497,6 +1519,7 @@ exports[`application generator > project > should run successfully with flake8 l "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "uv run pytest tests/", @@ -1627,6 +1650,7 @@ exports[`application generator > project > should run successfully with flake8 l "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -1648,6 +1672,7 @@ exports[`application generator > project > should run successfully with flake8 l }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -1668,6 +1693,7 @@ exports[`application generator > project > should run successfully with flake8 l "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "uv run pytest tests/", @@ -1785,6 +1811,7 @@ exports[`application generator > project > should run successfully with linting "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -1806,6 +1833,7 @@ exports[`application generator > project > should run successfully with linting }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -1826,6 +1854,7 @@ exports[`application generator > project > should run successfully with linting "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "uv run pytest tests/", @@ -2007,6 +2036,7 @@ exports[`application generator > project > should run successfully with linting "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -2028,6 +2058,7 @@ exports[`application generator > project > should run successfully with linting }, }, "lint": { + "cache": true, "executor": "@nxlv/python:ruff-check", "options": { "lintFilePatterns": [ @@ -2049,6 +2080,7 @@ exports[`application generator > project > should run successfully with linting "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "uv run pytest tests/", @@ -2289,6 +2321,7 @@ exports[`application generator > project > should run successfully with linting "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -2310,6 +2343,7 @@ exports[`application generator > project > should run successfully with linting }, }, "lint": { + "cache": true, "executor": "@nxlv/python:flake8", "options": { "outputFile": "reports/apps/test/pylint.txt", @@ -2330,6 +2364,7 @@ exports[`application generator > project > should run successfully with linting "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "uv run pytest tests/", @@ -2510,6 +2545,7 @@ exports[`application generator > project > should run successfully with ruff lin "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -2531,6 +2567,7 @@ exports[`application generator > project > should run successfully with ruff lin }, }, "lint": { + "cache": true, "executor": "@nxlv/python:ruff-check", "options": { "lintFilePatterns": [ @@ -2660,6 +2697,7 @@ exports[`application generator > project > should run successfully with ruff lin "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -2681,6 +2719,7 @@ exports[`application generator > project > should run successfully with ruff lin }, }, "lint": { + "cache": true, "executor": "@nxlv/python:ruff-check", "options": { "lintFilePatterns": [ @@ -2702,6 +2741,7 @@ exports[`application generator > project > should run successfully with ruff lin "options": {}, }, "test": { + "cache": true, "executor": "@nxlv/python:run-commands", "options": { "command": "uv run pytest tests/", @@ -2836,6 +2876,7 @@ exports[`application generator > should run successfully with minimal options 1` "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -2944,6 +2985,7 @@ exports[`application generator > workspace > should run successfully with minima "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -3062,6 +3104,7 @@ exports[`application generator > workspace > should run successfully with minima "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, @@ -3180,6 +3223,7 @@ exports[`application generator > workspace > should run successfully with minima "options": {}, }, "build": { + "cache": true, "executor": "@nxlv/python:build", "options": { "bundleLocalDependencies": false, diff --git a/packages/nx-python/src/generators/uv-project/generator.ts b/packages/nx-python/src/generators/uv-project/generator.ts index 56449b9..1284692 100644 --- a/packages/nx-python/src/generators/uv-project/generator.ts +++ b/packages/nx-python/src/generators/uv-project/generator.ts @@ -310,6 +310,7 @@ export default async function ( lockedVersions: normalizedOptions.buildLockedVersions, bundleLocalDependencies: normalizedOptions.buildBundleLocalDependencies, }, + cache: true, }, install: { executor: '@nxlv/python:install', @@ -331,6 +332,7 @@ export default async function ( options: { outputFile: `reports/${normalizedOptions.projectRoot}/pylint.txt`, }, + cache: true, }; } @@ -343,6 +345,7 @@ export default async function ( options.unitTestRunner === 'pytest' ? ['tests'] : [], ), }, + cache: true, }; } @@ -357,6 +360,7 @@ export default async function ( command: `uv run pytest tests/`, cwd: normalizedOptions.projectRoot, }, + cache: true, }; }