-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: Add cypress-process-clean-up typescript action
- Loading branch information
1 parent
1e30908
commit c83a566
Showing
14 changed files
with
176 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,6 @@ out | |
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fund=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: Clean Cypress Process | ||
description: '' | ||
|
||
runs: | ||
using: 'node20' | ||
main: '../dist/main/index.js' | ||
post: '../dist/post/index.js' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "module" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "module" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,27 @@ | |
"description": "Localazy GitHub release action", | ||
"author": "Localazy <[email protected]>", | ||
"license": "MIT", | ||
"type": "module", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"build": "npm run build:main && npm run build:post", | ||
"build:main": "npm run compile -- --out ./dist/main src/main.ts ", | ||
"build:post": "npm run compile -- --out ./dist/post src/post.ts", | ||
"compile": "ncc build --minify --no-cache --target es2022 --v8-cache" | ||
}, | ||
"dependencies": { | ||
"ps-list": "^8.1.1" | ||
}, | ||
"devDependencies": { | ||
"@localazy/conventional-changelog-preset": "github:localazy/conventional-changelog-preset", | ||
"@types/node": "^20.6.2", | ||
"@vercel/ncc": "^0.38.0", | ||
"conventional-changelog": "^5.1.0", | ||
"conventional-changelog-cli": "^4.1.0", | ||
"conventional-changelog-writer": "github:localazy/conventional-changelog-writer", | ||
"conventional-recommended-bump": "^9.0.0" | ||
"conventional-recommended-bump": "^9.0.0", | ||
"typescript": "^5.2.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import psList, { ProcessDescriptor } from 'ps-list'; | ||
|
||
const workspace: string = process.env.GITHUB_WORKSPACE || ''; | ||
|
||
export const terminateOrphans = async (): Promise<void> => { | ||
const processes: ProcessDescriptor[] = await psList(); | ||
|
||
const chromeProcesses: ProcessDescriptor[] = processes.filter( | ||
(p: ProcessDescriptor) => p.cmd?.includes('/chrome/chrome') | ||
); | ||
const cypressProcesses: ProcessDescriptor[] = processes.filter( | ||
(p: ProcessDescriptor) => p.cmd?.includes('/Cypress/Cypress') && p.cmd.includes('--run-project') | ||
); | ||
const cypressOrphans: ProcessDescriptor[] = cypressProcesses.filter( | ||
(p: ProcessDescriptor) => p.cmd?.includes(`--run-project ${workspace}`) | ||
); | ||
|
||
console.log('Chrome processes:', chromeProcesses.length); | ||
console.log('Cypress processes:', cypressProcesses.length); | ||
console.log('Cypress orphans:', cypressOrphans.length); | ||
|
||
cypressOrphans.forEach((cypressProcess: ProcessDescriptor): void => { | ||
chromeProcesses | ||
.filter((chromeProcess: ProcessDescriptor) => chromeProcess.cmd?.includes(`run-${cypressProcess.pid}`)) | ||
.forEach((chromeProcess: ProcessDescriptor): void => { | ||
console.log(`Killing Chrome process ${chromeProcess.pid} ${chromeProcess.cmd}\n`); | ||
process.kill(chromeProcess.pid, 'SIGKILL'); | ||
}); | ||
|
||
console.log(`Killing Cypress process ${cypressProcess.pid} ${cypressProcess.cmd}\n`); | ||
process.kill(cypressProcess.pid, 'SIGKILL'); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { terminateOrphans } from './clean-up.js'; | ||
|
||
terminateOrphans().then(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { terminateOrphans } from './clean-up.js'; | ||
|
||
terminateOrphans().then(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2022", | ||
"module": "Node16", | ||
"moduleResolution": "Node16", | ||
"forceConsistentCasingInFileNames": true, | ||
"noEmit": true, | ||
"strict": true, | ||
"types": [ | ||
"node" | ||
] | ||
}, | ||
"include": ["src"] | ||
} |