From c889140a1b5509489577f01165fe1cf09e93dae3 Mon Sep 17 00:00:00 2001 From: mr25mr <100434800+mr25mr@users.noreply.github.com> Date: Sun, 3 Dec 2023 15:24:25 +0100 Subject: [PATCH] fix: use nx caching --- .github/workflows/pipeline.yml | 22 +++++++++++----------- nx.json | 12 ++++++++++++ packages/preview-middleware/package.json | 8 +++++--- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 4cefe55fda..737d9339cd 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -42,24 +42,24 @@ jobs: run: pnpm run build - name: Run unit tests run: pnpm run test - - name: Check for changes - uses: dorny/paths-filter@v2 - id: check_changes + - name: Cache playwright browsers + id: cache-playwright-browsers + uses: actions/cache@v3 with: - filters: | - src: - - 'packages/preview-middleware/**' - # To include changes for other packages, simply add this - 'packages//**' + path: | + ${{ runner.os == 'Windows' }}: + C:\Users\runneradmin\AppData\Local\ms-playwright + ${{ runner.os != 'Windows' }}: + ~/.cache/ms-playwright + key: playwright-browsers-${{ matrix.os }}-${{ matrix.node-version }} - name: Install playwright browsers - if: always() && steps.check_changes.outputs.src == 'true' + if: steps.cache-playwright-browsers.outputs.cache-hit != 'true' run: npx playwright install --with-deps - name: Run integration tests - # Run only if preview-middleware was changed - if: always() && steps.check_changes.outputs.src == 'true' run: pnpm run test:integration - name: Upload playwright reports + if: failure() uses: actions/upload-artifact@v3 - if: always() && steps.check_changes.outputs.src == 'true' with: name: playwright-reports-os-${{ matrix.os }}-node-version-${{ matrix.node-version }} path: | diff --git a/nx.json b/nx.json index 116d87b4aa..261386dcbb 100644 --- a/nx.json +++ b/nx.json @@ -7,6 +7,7 @@ "build", "lint", "test", + "test:integration", "build:extension", "build:storybook", "build:storybook:bundle" @@ -50,6 +51,17 @@ "{projectRoot}/coverage" ] }, + "test:integration": { + "inputs": [ + "default", + "^prod", + "{workspaceRoot}/jest.base.js", + "{projectRoot}/jest.config.js" + ], + "outputs": [ + "{projectRoot}/playwright-report" + ] + }, "build:extension": { "outputs": [ "{projectRoot}/*.vsix" diff --git a/packages/preview-middleware/package.json b/packages/preview-middleware/package.json index c6870c5460..dc8789ebdc 100644 --- a/packages/preview-middleware/package.json +++ b/packages/preview-middleware/package.json @@ -19,13 +19,15 @@ "build:middleware": "tsc --build", "build:client": "pnpm -C ../preview-middleware-client run build && copyfiles --exclude **/*-dbg.js --up 4 \"./node_modules/@private/preview-middleware-client/dist/**/*\" \"./dist/client\"", "watch": "tsc --watch", - "clean": "rimraf --glob dist test/test-output coverage *.tsbuildinfo", + "clean": "rimraf --glob dist test/test-output coverage *.tsbuildinfo playwright-report", "format": "prettier --write '**/*.{js,json,ts,yaml,yml}' --ignore-path ../../.prettierignore", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "test": "jest --ci --forceExit --detectOpenHandles --colors", "test-u": "jest --ci --forceExit --detectOpenHandles --colors -u", - "test:integration": "playwright test", + "test:integration:clean": "rimraf --glob playwright-report", + "test:integration:run": "playwright test", + "test:integration": "npm-run-all -l -s test:integration:clean test:integration:run", "link": "pnpm link --global", "unlink": "pnpm unlink --global" }, @@ -65,4 +67,4 @@ "pnpm": ">=6.26.1 < 7.0.0 || >=7.1.0", "node": ">=18.x" } -} +} \ No newline at end of file