Unverified Commit 50769540 authored by Josh Gross's avatar Josh Gross Committed by GitHub
Browse files

Merge pull request #598 from actions/joshmgross/exclude-hidden-files

Exclude hidden files by default
parents 834a144e d52396ac
Loading
Loading
Loading
Loading

File changed.

Preview suppressed by a .gitattributes entry or the file's encoding is unsupported.

+7
Changes for README.md: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ There is also a new sub-action, `actions/upload-artifact/merge`. For more info,
    Due to how Artifacts are created in this new version, it is no longer possible to upload to the same named Artifact multiple times. You must either split the uploads into multiple Artifacts with different names, or only upload once. Otherwise you _will_ encounter an error.

3. Limit of Artifacts for an individual job. Each job in a workflow run now has a limit of 500 artifacts.
4. With `v4.4` and later, hidden files are excluded by default.

For assistance with breaking changes, see [MIGRATION.md](docs/MIGRATION.md).

@@ -107,6 +108,12 @@ For assistance with breaking changes, see [MIGRATION.md](docs/MIGRATION.md).
    # Does not fail if the artifact does not exist.
    # Optional. Default is 'false'
    overwrite:

    # Whether to include hidden files in the provided path in the artifact
    # The file contents of any hidden files in the path should be validated before
    # enabled this to avoid uploading sensitive information.
    # Optional. Default is 'false'
    include-hidden-files:
```

### Outputs
+52
Changes for __tests__/search.test.ts: 52 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -61,6 +61,20 @@ const lonelyFilePath = path.join(
  'lonely-file.txt'
)

const hiddenFile = path.join(root, '.hidden-file.txt')
const fileInHiddenFolderPath = path.join(
  root,
  '.hidden-folder',
  'folder-in-hidden-folder',
  'file.txt'
)
const fileInHiddenFolderInFolderA = path.join(
  root,
  'folder-a',
  '.hidden-folder-in-folder-a',
  'file.txt'
)

describe('Search', () => {
  beforeAll(async () => {
    // mock all output so that there is less noise when running tests
@@ -93,6 +107,14 @@ describe('Search', () => {
      recursive: true
    })

    await fs.mkdir(
      path.join(root, '.hidden-folder', 'folder-in-hidden-folder'),
      {recursive: true}
    )
    await fs.mkdir(path.join(root, 'folder-a', '.hidden-folder-in-folder-a'), {
      recursive: true
    })

    await fs.writeFile(searchItem1Path, 'search item1 file')
    await fs.writeFile(searchItem2Path, 'search item2 file')
    await fs.writeFile(searchItem3Path, 'search item3 file')
@@ -110,10 +132,19 @@ describe('Search', () => {
    await fs.writeFile(amazingFileInFolderHPath, 'amazing file')

    await fs.writeFile(lonelyFilePath, 'all by itself')

    await fs.writeFile(hiddenFile, 'hidden file')
    await fs.writeFile(fileInHiddenFolderPath, 'file in hidden directory')
    await fs.writeFile(fileInHiddenFolderInFolderA, 'file in hidden directory')
    /*
      Directory structure of files that get created:
      root/
          .hidden-folder/
              folder-in-hidden-folder/
                  file.txt
          folder-a/
              .hidden-folder-in-folder-a/
                  file.txt
              folder-b/
                  folder-c/
                      search-item1.txt
@@ -136,6 +167,7 @@ describe('Search', () => {
              folder-j/
                  folder-k/
                      lonely-file.txt
          .hidden-file.txt
          search-item5.txt
    */
  })
@@ -352,4 +384,24 @@ describe('Search', () => {
    )
    expect(searchResult.filesToUpload.includes(lonelyFilePath)).toEqual(true)
  })

  it('Hidden files ignored by default', async () => {
    const searchPath = path.join(root, '**/*')
    const searchResult = await findFilesToUpload(searchPath)

    expect(searchResult.filesToUpload).not.toContain(hiddenFile)
    expect(searchResult.filesToUpload).not.toContain(fileInHiddenFolderPath)
    expect(searchResult.filesToUpload).not.toContain(
      fileInHiddenFolderInFolderA
    )
  })

  it('Hidden files included', async () => {
    const searchPath = path.join(root, '**/*')
    const searchResult = await findFilesToUpload(searchPath, true)

    expect(searchResult.filesToUpload).toContain(hiddenFile)
    expect(searchResult.filesToUpload).toContain(fileInHiddenFolderPath)
    expect(searchResult.filesToUpload).toContain(fileInHiddenFolderInFolderA)
  })
})
+5
Changes for action.yml: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -40,6 +40,11 @@ inputs:
      If false, the action will fail if an artifact for the given name already exists.
      Does not fail if the artifact does not exist.
    default: 'false'
  include-hidden-files:
    description: >
      If true, hidden files will be included in the artifact.
      If false, hidden files will be excluded from the artifact.
    default: 'false'

outputs:
  artifact-id:
+103 −54

File changed.

Preview size limit exceeded, changes collapsed.

Loading