Skip to content

Commit 89e4745

Browse files
committed
Remove tmp directory after finished workflow execution
1 parent b7e392e commit 89e4745

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

agent.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,21 @@ module.exports.exec = (program) => {
3939
q.push(services.githubCi.pullRequest(socket, 'tf.githubCi.pullRequest', req))
4040
})
4141

42+
socket.on('tf.githubCi.pullRequest.execution.finished', (req) => {
43+
if (!agent.authenticated) return
44+
q.push(services.githubCi.executionFinished(socket, 'tf.githubCi.pullRequest.execution.finished', req))
45+
})
46+
4247
socket.on('tf.githubCi.push', (req) => {
4348
if (!agent.authenticated) return
4449
q.push(services.githubCi.push(socket, 'tf.githubCi.push', req))
4550
})
4651

52+
socket.on('tf.githubCi.push.execution.finished', (req) => {
53+
if (!agent.authenticated) return
54+
q.push(services.githubCi.executionFinished(socket, 'tf.githubCi.push.execution.finished', req))
55+
})
56+
4757
socket.on('tf.githubCi.test_cmd', (req) => {
4858
if (!agent.authenticated) return
4959
q.push(services.githubCi.test_cmd(socket, 'tf.githubCi.test_cmd', req))

package-lock.json

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"colors": "^1.3.3",
3636
"commander": "^2.19.0",
3737
"cross-spawn": "^6.0.5",
38+
"fs-extra": "^8.1.0",
3839
"queue": "^6.0.0",
3940
"simple-git": "^1.124.0",
4041
"socket.io-client": "^2.2.0",

services/githubCi.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const git = require('simple-git/promise');
2-
const fs = require('fs')
2+
const fs = require('fs-extra')
33
const os = require('os')
44
const path = require('path')
55
const spawn = require('cross-spawn')
@@ -48,6 +48,12 @@ const push = async (socket, topic, req) => {
4848
module.exports.push = push
4949
module.exports.pullRequest = push
5050

51+
const executionFinished = async (socket, topic, req) => {
52+
const tmpPath = genTmpFolder(req.execution)
53+
fs.removeSync(tmpPath)
54+
}
55+
module.exports.executionFinished = executionFinished
56+
5157
const test_cmd = async (socket, topic, req) => {
5258
const commands = req.cmd.split('\n')
5359
const webhook = req.webhook

0 commit comments

Comments
 (0)