generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First working version * Fix GH Actions workflow + tests
- Loading branch information
1 parent
c212841
commit de867ee
Showing
17 changed files
with
13,296 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,43 @@ | ||
name: 'build-test' | ||
on: # rebuild any PRs and main branch changes | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- 'releases/*' | ||
|
||
jobs: | ||
build: # make sure build/ci work properly | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: | | ||
npm install | ||
- run: | | ||
npm run all | ||
test: # make sure the action works on a clean machine without building | ||
runs-on: ubuntu-latest | ||
- run: npm install | ||
- run: npm run all | ||
|
||
test: | ||
needs: build | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: ./ | ||
- name: test with testFolder | ||
uses: ./ | ||
with: | ||
server: ${{ secrets.FTP_SERVER }} | ||
username: ${{ secrets.FTP_USER }} | ||
password: ${{ secrets.FTP_PASSWORD }} | ||
local_dir: dummydata/testFolder/ | ||
server_dir: ${{ matrix.os }} | ||
- name: test with testFolderRecursive | ||
uses: ./ | ||
with: | ||
milliseconds: 1000 | ||
server: ${{ secrets.FTP_SERVER }} | ||
username: ${{ secrets.FTP_USER }} | ||
password: ${{ secrets.FTP_PASSWORD }} | ||
local_dir: dummydata/testFolderRecursive/ | ||
server_dir: ${{ matrix.os }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,32 @@ | ||
import {wait} from '../src/wait' | ||
import * as process from 'process' | ||
import * as cp from 'child_process' | ||
import * as path from 'path' | ||
import {File, getFiles} from '../src/util' | ||
|
||
test('throws invalid number', async () => { | ||
const input = parseInt('foo', 10) | ||
await expect(wait(input)).rejects.toThrow('milliseconds not a number') | ||
}) | ||
test('returns folder contents', async () => { | ||
const fileArray = ['test1.txt', 'test2.txt'] | ||
|
||
test('wait 500 ms', async () => { | ||
const start = new Date() | ||
await wait(500) | ||
const end = new Date() | ||
var delta = Math.abs(end.getTime() - start.getTime()) | ||
expect(delta).toBeGreaterThan(450) | ||
for await (const fileObject of getFiles( | ||
path.join(__dirname, '..', 'dummydata', 'testFolder'), | ||
path.resolve(__dirname, '..', 'dummydata', 'testFolder') | ||
// eslint-disable-next-line no-undef | ||
) as AsyncIterable<File>) { | ||
expect(fileArray).toContain(fileObject.filename) | ||
} | ||
}) | ||
|
||
// shows how the runner will run a javascript action with env / stdout protocol | ||
test('test runs', () => { | ||
process.env['INPUT_MILLISECONDS'] = '500' | ||
const np = process.execPath | ||
const ip = path.join(__dirname, '..', 'lib', 'main.js') | ||
const options: cp.ExecFileSyncOptions = { | ||
env: process.env | ||
test('returns folder contents recursively', async () => { | ||
const fileArray = [ | ||
'/test.txt', | ||
'sub1/test.txt', | ||
'sub1/subsub1/test.txt', | ||
'sub2/test.txt' | ||
] | ||
|
||
for await (const fileObject of getFiles( | ||
path.join(__dirname, '..', 'dummydata', 'testFolderRecursive'), | ||
path.resolve(__dirname, '..', 'dummydata', 'testFolderRecursive') | ||
// eslint-disable-next-line no-undef | ||
) as AsyncIterable<File>) { | ||
expect(fileArray).toContain(`${fileObject.folder}/${fileObject.filename}`) | ||
} | ||
console.log(cp.execFileSync(np, [ip], options).toString()) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,28 @@ | ||
name: 'Your name here' | ||
description: 'Provide a description here' | ||
author: 'Your name or organization here' | ||
name: 'Simple FTP upload' | ||
description: 'Allows you to upload contents of a directory to an FTP server over FTP or FTPS' | ||
author: 'Dennis Ameling' | ||
inputs: | ||
milliseconds: # change this | ||
server: | ||
required: true | ||
description: 'input description here' | ||
default: 'default value if applicable' | ||
description: "FTP server" | ||
username: | ||
required: true | ||
description: "FTP username" | ||
password: | ||
required: true | ||
description: "FTP password" | ||
port: | ||
required: false | ||
description: "Server port to connect to (read your web hosts docs). Defaults to 21." | ||
secure: | ||
required: false | ||
description: "True uses FTPS, while false uses plain FTP. Defaults to true." | ||
local_dir: | ||
required: false | ||
description: "Folder to upload from, must end with trailing slash /" | ||
server_dir: | ||
required: false | ||
description: "Path to upload to on the server. Must end with trailing slash /" | ||
runs: | ||
using: 'node12' | ||
main: 'dist/index.js' |
Oops, something went wrong.