Skip to content

Commit

Permalink
fix: use nx caching
Browse files Browse the repository at this point in the history
  • Loading branch information
marufrasully committed Dec 3, 2023
1 parent 58af025 commit ce0a6fd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI/CD Pipeline

on:
push:
branches: [main]
branches: [feat/playwright-cpe]
pull_request:
branches: [main]
branches: [feat/playwright-cpe]

jobs:
build:
Expand Down Expand Up @@ -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/<package-name>/**'
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: |
Expand Down
12 changes: 12 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"build",
"lint",
"test",
"test:integration",
"build:extension",
"build:storybook",
"build:storybook:bundle"
Expand Down Expand Up @@ -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"
Expand Down
8 changes: 5 additions & 3 deletions packages/preview-middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -65,4 +67,4 @@
"pnpm": ">=6.26.1 < 7.0.0 || >=7.1.0",
"node": ">=18.x"
}
}
}

0 comments on commit ce0a6fd

Please sign in to comment.