Skip to content

Commit

Permalink
PTFE-1257 add warning when uploading an empty directory (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarmet authored Dec 22, 2023
1 parent 0577529 commit ed2702c
Show file tree
Hide file tree
Showing 7 changed files with 45,696 additions and 46,668 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/test-upload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,18 @@ jobs:
- name: Compate files2
run: cmp --silent upload_action.yaml ./action.yaml

test-empty-folder:
runs-on: ubuntu-latest
environment: ${{ inputs.environment || 'production' }}
name: A job that try to push an empty folder
steps:
- uses: actions/checkout@v3
- run: mkdir -p artifacts
- name: Push all files
uses: ./
with:
url: ${{ vars.ARTIFACTS_URL }}
user: ${{ secrets.ARTIFACTS_USER }}
password: ${{ secrets.ARTIFACTS_PASSWORD }}
source: ./artifacts
method: upload
26 changes: 24 additions & 2 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as process from 'process'
import * as cp from 'child_process'
import * as path from 'path'
import {afterEach, beforeEach, test} from '@jest/globals'
import {afterEach, beforeEach, test, expect} from '@jest/globals'
import fs from 'fs'
import os from 'os'

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

test('test runs upload absolute path', () => {
Expand Down Expand Up @@ -102,3 +105,22 @@ test('test runs get method', () => {
}
console.log(cp.execFileSync(np, [ip], options).toString())
})

test('test runs upload with no file in folder', () => {
const workspace: string = process.env['GITHUB_WORKSPACE'] || ''
const source: string = 'artifacts'
process.env['INPUT_METHOD'] = 'upload'

fs.mkdirSync(path.join(workspace, source))

process.env['INPUT_SOURCE'] = source

const np = process.execPath
const ip = path.join(__dirname, '..', 'lib', 'main.js')
const options: cp.ExecFileSyncOptions = {
env: process.env
}
const output: string = cp.execFileSync(np, [ip], options).toString()
console.log(output)
expect(output).toContain('No files found for the provided path')
})
Loading

0 comments on commit ed2702c

Please sign in to comment.