Skip to content

Commit ed2702c

Browse files
authored
PTFE-1257 add warning when uploading an empty directory (#397)
1 parent 0577529 commit ed2702c

File tree

7 files changed

+45696
-46668
lines changed

7 files changed

+45696
-46668
lines changed

.github/workflows/test-upload.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,18 @@ jobs:
105105
- name: Compate files2
106106
run: cmp --silent upload_action.yaml ./action.yaml
107107

108+
test-empty-folder:
109+
runs-on: ubuntu-latest
110+
environment: ${{ inputs.environment || 'production' }}
111+
name: A job that try to push an empty folder
112+
steps:
113+
- uses: actions/checkout@v3
114+
- run: mkdir -p artifacts
115+
- name: Push all files
116+
uses: ./
117+
with:
118+
url: ${{ vars.ARTIFACTS_URL }}
119+
user: ${{ secrets.ARTIFACTS_USER }}
120+
password: ${{ secrets.ARTIFACTS_PASSWORD }}
121+
source: ./artifacts
122+
method: upload

__tests__/main.test.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as process from 'process'
22
import * as cp from 'child_process'
33
import * as path from 'path'
4-
import {afterEach, beforeEach, test} from '@jest/globals'
4+
import {afterEach, beforeEach, test, expect} from '@jest/globals'
55
import fs from 'fs'
66
import os from 'os'
77

@@ -55,7 +55,10 @@ test('test runs upload', () => {
5555
const options: cp.ExecFileSyncOptions = {
5656
env: process.env
5757
}
58-
console.log(cp.execFileSync(np, [ip], options).toString())
58+
const output: string = cp.execFileSync(np, [ip], options).toString()
59+
console.log(output)
60+
// output should not contain the warning mentioning that the file is not found
61+
expect(output).not.toContain('No files found for the provided path')
5962
})
6063

6164
test('test runs upload absolute path', () => {
@@ -102,3 +105,22 @@ test('test runs get method', () => {
102105
}
103106
console.log(cp.execFileSync(np, [ip], options).toString())
104107
})
108+
109+
test('test runs upload with no file in folder', () => {
110+
const workspace: string = process.env['GITHUB_WORKSPACE'] || ''
111+
const source: string = 'artifacts'
112+
process.env['INPUT_METHOD'] = 'upload'
113+
114+
fs.mkdirSync(path.join(workspace, source))
115+
116+
process.env['INPUT_SOURCE'] = source
117+
118+
const np = process.execPath
119+
const ip = path.join(__dirname, '..', 'lib', 'main.js')
120+
const options: cp.ExecFileSyncOptions = {
121+
env: process.env
122+
}
123+
const output: string = cp.execFileSync(np, [ip], options).toString()
124+
console.log(output)
125+
expect(output).toContain('No files found for the provided path')
126+
})

0 commit comments

Comments
 (0)