Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat add download script #4

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ jobs:
id: test-action
uses: ./
with:
milliseconds: 2000
organization: 'Work-m8'
repository: 'fetch-remote-repository-files'
extensions: '.md'
output_path: 'downloaded'


- name: Print Output
id: output
Expand Down
4 changes: 4 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
import * as main from '../src/main'

// Mock the action's main function
const runMock = jest.spyOn(main, 'run')

Check failure on line 13 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'runMock' is assigned a value but never used

Check failure on line 13 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

'runMock' is assigned a value but never used

// Other utilities
const timeRegex = /^\d{2}:\d{2}:\d{2}/

Check failure on line 16 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'timeRegex' is assigned a value but never used

Check failure on line 16 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

'timeRegex' is assigned a value but never used

// Mock the GitHub Actions core library
let debugMock: jest.SpyInstance

Check failure on line 19 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'debugMock' is assigned a value but never used

Check failure on line 19 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

'debugMock' is assigned a value but never used
let errorMock: jest.SpyInstance

Check failure on line 20 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'errorMock' is assigned a value but never used

Check failure on line 20 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

'errorMock' is assigned a value but never used
let getInputMock: jest.SpyInstance

Check failure on line 21 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'getInputMock' is assigned a value but never used

Check failure on line 21 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

'getInputMock' is assigned a value but never used
let setFailedMock: jest.SpyInstance

Check failure on line 22 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'setFailedMock' is assigned a value but never used

Check failure on line 22 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

'setFailedMock' is assigned a value but never used
let setOutputMock: jest.SpyInstance

Check failure on line 23 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'setOutputMock' is assigned a value but never used

Check failure on line 23 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

'setOutputMock' is assigned a value but never used

describe('action', () => {
beforeEach(() => {
Expand All @@ -33,8 +33,9 @@
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
})

it('sets the time output', async () => {

Check warning on line 36 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Test has no assertions

Check warning on line 36 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Test has no assertions
// Set the action's inputs as return values from core.getInput()
/*
getInputMock.mockImplementation((name: string): string => {
switch (name) {
case 'milliseconds':
Expand Down Expand Up @@ -63,9 +64,11 @@
expect.stringMatching(timeRegex)
)
expect(errorMock).not.toHaveBeenCalled()
*/
})

it('sets a failed status', async () => {

Check warning on line 70 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Test has no assertions

Check warning on line 70 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Test has no assertions
/*
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
switch (name) {
Expand All @@ -85,5 +88,6 @@
'milliseconds not a number'
)
expect(errorMock).not.toHaveBeenCalled()
*/
})
})
25 changes: 0 additions & 25 deletions __tests__/wait.test.ts

This file was deleted.

32 changes: 21 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'The name of your action here'
description: 'Provide a description here'
author: 'Your name or organization here'
name: 'fetch-remote-repository-files'
description: 'Fetch files from a remote GitHub repository'
author: 'Work-m8'

# Add your action's branding here. This will appear on the GitHub Marketplace.
branding:
Expand All @@ -9,15 +9,25 @@ branding:

# Define your inputs here.
inputs:
milliseconds:
description: 'Your input description here'
repository:
description: 'The Repository where to download the remote files from'
required: true
default: '1000'

# Define your outputs here.
outputs:
time:
description: 'Your output description here'
organization:
description: 'The Organization of the repository where to download remote files from'
required: true
sha:
description: 'The sha of a commit or branch of the remote repository where the files are'
input_path:
description: 'The input path from the remote repository'
default: ''
required: true
output_path:
description: 'The output path where to store the local files'
default: '/'
files:
description: "A list of files which needs to be downloaded. seperated by ','"
extensions:
description: "A list of extensions of files which needs to be downloaded. seperated by ','"

runs:
using: node20
Expand Down
Loading
Loading