generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4a63b7
commit 94496a9
Showing
42 changed files
with
2,304 additions
and
933 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,4 +1,3 @@ | ||
dist/ | ||
lib/ | ||
node_modules/ | ||
jest.config.js |
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 +0,0 @@ | ||
dist/** -diff linguist-generated=true | ||
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
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 |
---|---|---|
|
@@ -21,7 +21,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set Node.js 16.x | ||
uses: actions/[email protected] | ||
|
@@ -34,20 +34,12 @@ jobs: | |
- name: Rebuild the dist/ directory | ||
run: | | ||
npm run build | ||
npm run package | ||
- name: Compare the expected and actual dist/ directories | ||
run: | | ||
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then | ||
if [ "$(git diff --ignore-space-at-eol lib/ | wc -l)" -gt "0" ]; then | ||
echo "Detected uncommitted changes after build. See status below:" | ||
git diff | ||
exit 1 | ||
fi | ||
id: diff | ||
|
||
# If index.js was different than expected, upload the expected version as an artifact | ||
- uses: actions/upload-artifact@v2 | ||
if: ${{ failure() && steps.diff.conclusion == 'failure' }} | ||
with: | ||
name: dist | ||
path: dist/ | ||
id: diff |
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
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,18 @@ | ||
name: 'build-test' | ||
on: # rebuild any PRs and main branch changes | ||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- 'releases/*' | ||
|
||
jobs: | ||
build: # make sure build/ci work properly | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v3 | ||
- run: | | ||
npm install | ||
- run: | | ||
npm run all | ||
test: # make sure the action works on a clean machine without building | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: ./ | ||
with: | ||
milliseconds: 1000 | ||
npm run all |
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 |
---|---|---|
|
@@ -97,5 +97,4 @@ typings/ | |
Thumbs.db | ||
|
||
# Ignore built ts files | ||
__tests__/runner/* | ||
lib/**/* | ||
__tests__/runner/* |
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,3 +1,2 @@ | ||
dist/ | ||
lib/ | ||
node_modules/ |
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
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,105 +1 @@ | ||
<p align="center"> | ||
<a href="https://github.com/actions/typescript-action/actions"><img alt="typescript-action status" src="https://github.com/actions/typescript-action/workflows/build-test/badge.svg"></a> | ||
</p> | ||
|
||
# Create a JavaScript Action using TypeScript | ||
|
||
Use this template to bootstrap the creation of a TypeScript action.:rocket: | ||
|
||
This template includes compilation support, tests, a validation workflow, publishing, and versioning guidance. | ||
|
||
If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action) | ||
|
||
## Create an action from this template | ||
|
||
Click the `Use this Template` and provide the new repo details for your action | ||
|
||
## Code in Main | ||
|
||
> First, you'll need to have a reasonably modern version of `node` handy. This won't work with versions older than 9, for instance. | ||
Install the dependencies | ||
```bash | ||
$ npm install | ||
``` | ||
|
||
Build the typescript and package it for distribution | ||
```bash | ||
$ npm run build && npm run package | ||
``` | ||
|
||
Run the tests :heavy_check_mark: | ||
```bash | ||
$ npm test | ||
|
||
PASS ./index.test.js | ||
✓ throws invalid number (3ms) | ||
✓ wait 500 ms (504ms) | ||
✓ test runs (95ms) | ||
|
||
... | ||
``` | ||
|
||
## Change action.yml | ||
|
||
The action.yml defines the inputs and output for your action. | ||
|
||
Update the action.yml with your name, description, inputs and outputs for your action. | ||
|
||
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions) | ||
|
||
## Change the Code | ||
|
||
Most toolkit and CI/CD operations involve async operations so the action is run in an async function. | ||
|
||
```javascript | ||
import * as core from '@actions/core'; | ||
... | ||
|
||
async function run() { | ||
try { | ||
... | ||
} | ||
catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
} | ||
|
||
run() | ||
``` | ||
|
||
See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages. | ||
|
||
## Publish to a distribution branch | ||
|
||
Actions are run from GitHub repos so we will checkin the packed dist folder. | ||
|
||
Then run [ncc](https://github.com/zeit/ncc) and push the results: | ||
```bash | ||
$ npm run package | ||
$ git add dist | ||
$ git commit -a -m "prod dependencies" | ||
$ git push origin releases/v1 | ||
``` | ||
|
||
Note: We recommend using the `--license` option for ncc, which will create a license file for all of the production node modules used in your project. | ||
|
||
Your action is now published! :rocket: | ||
|
||
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) | ||
|
||
## Validate | ||
|
||
You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml)) | ||
|
||
```yaml | ||
uses: ./ | ||
with: | ||
milliseconds: 1000 | ||
``` | ||
See the [actions tab](https://github.com/actions/typescript-action/actions) for runs of this action! :rocket: | ||
## Usage: | ||
After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action | ||
# anka-actions-common |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"status": "OK", | ||
"message": "", | ||
"body": [ | ||
{ | ||
"external_id": "0651d321-bf5a-4d8f-b926-1c2cf27744d5", | ||
"instance_id": "cd1937fd-68e7-4d5b-6b75-5ac3260b40f7", | ||
"name": null, | ||
"vm": { | ||
"instance_id": "cd1937fd-68e7-4d5b-6b75-5ac3260b40f7", | ||
"instance_state": "Started", | ||
"anka_registry": "https://18.198.188.108:8089", | ||
"vmid": "4c641deb-9822-4718-a757-5775799d9bc8", | ||
"tag": "latest", | ||
"vminfo": { | ||
"uuid": "bbfa4979-f748-4731-a6f4-4c8d85ec34de", | ||
"name": "mgmtManaged-monterey-1666889320540357000", | ||
"cpu_cores": 2, | ||
"ram": "8G", | ||
"status": "running", | ||
"node_id": "f9673afe-dc07-4683-b625-2bbf9f35f566", | ||
"host_ip": "192.168.1.28", | ||
"ip": "192.168.64.19", | ||
"vnc_port": 0, | ||
"vnc_connection_string": "vnc://:@192.168.1.28:0", | ||
"creation_date": "2022-10-11T10:12:05Z", | ||
"stop_date": "0001-01-01T00:00:00Z", | ||
"version": "" | ||
}, | ||
"node_id": "f9673afe-dc07-4683-b625-2bbf9f35f566", | ||
"inflight_reqid": "dc3b8af8-5d14-4ec8-5422-15ebe40ac568", | ||
"ts": "2022-10-27T16:49:35.435875889Z", | ||
"cr_time": "2022-10-27T16:48:39.879143718Z", | ||
"progress": 0, | ||
"external_id": "0651d321-bf5a-4d8f-b926-1c2cf27744d5", | ||
"arch": "arm64", | ||
"vlan": "", | ||
"startup_script": { | ||
"return_code": 0, | ||
"did_timeout": false, | ||
"stdout": "\n--------------------------------------------------------------------------------\n| ____ _ _ _ _ _ _ _ _ |\n| / ___(_) |_| | | |_ _| |__ / \\ ___| |_(_) ___ _ __ ___ |\n| | | _| | __| |_| | | | | '_ \\ / _ \\ / __| __| |/ _ \\| '_ \\/ __| |\n| | |_| | | |_| _ | |_| | |_) | / ___ \\ (__| |_| | (_) | | | \\__ \\ |\n| \\____|_|\\__|_| |_|\\__,_|_.__/ /_/ \\_\\___|\\__|_|\\___/|_| |_|___/ |\n| |\n| Self-hosted runner registration |\n| |\n--------------------------------------------------------------------------------\n\n# Authentication\n\n\n√ Connected to GitHub\n\n# Runner Registration\n\n\n\n\n√ Runner successfully added\n√ Runner connection is good\n\n# Runner settings\n\n\n√ Settings Saved.\n\nCreating launch runner in /Users/anka/Library/LaunchAgents/actions.runner.veertuinc-anka-actions-demo.0651d321-bf5a-4d8f-b926-1c2cf27744d5.plist\nCreating /Users/anka/Library/Logs/actions.runner.veertuinc-anka-actions-demo.0651d321-bf5a-4d8f-b926-1c2cf27744d5\nCreating /Users/anka/Library/LaunchAgents/actions.runner.veertuinc-anka-actions-demo.0651d321-bf5a-4d8f-b926-1c2cf27744d5.plist\nCreating runsvc.sh\nCreating .service\nsvc install complete\nstarting actions.runner.veertuinc-anka-actions-demo.0651d321-bf5a-4d8f-b926-1c2cf27744d5\nstatus actions.runner.veertuinc-anka-actions-demo.0651d321-bf5a-4d8f-b926-1c2cf27744d5:\n\n/Users/anka/Library/LaunchAgents/actions.runner.veertuinc-anka-actions-demo.0651d321-bf5a-4d8f-b926-1c2cf27744d5.plist\n\nStarted:\n592 0 actions.runner.veertuinc-anka-actions-demo.0651d321-bf5a-4d8f-b926-1c2cf27744d5\n\n", | ||
"stderr": "" | ||
} | ||
} | ||
} | ||
] | ||
} |
41 changes: 41 additions & 0 deletions
41
__tests__/fixtures/list-vm-single-startup-script-error.json
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"status": "OK", | ||
"message": "", | ||
"body": { | ||
"instance_id": "7b3421d9-764c-481c-5e74-8cbd741d3930", | ||
"instance_state": "Error", | ||
"message": "startup script exit code 127", | ||
"anka_registry": "https://19.188.188.108:8089", | ||
"vmid": "4c641deb-9822-4718-a757-5775799d9bc8", | ||
"tag": "latest", | ||
"vminfo": { | ||
"uuid": "2971ce7d-4c76-49eb-8e58-0c75dddd8af3", | ||
"name": "mgmtManaged-monterey-1666774975892452000", | ||
"cpu_cores": 2, | ||
"ram": "8G", | ||
"status": "running", | ||
"node_id": "f9673afe-dc07-4683-b625-2bbf9f35f566", | ||
"host_ip": "192.168.1.28", | ||
"ip": "192.168.64.3", | ||
"vnc_port": 0, | ||
"vnc_connection_string": "vnc://:@192.168.1.28:0", | ||
"creation_date": "2022-10-11T10:12:05Z", | ||
"stop_date": "0001-01-01T00:00:00Z", | ||
"version": "" | ||
}, | ||
"node_id": "f9673afe-dc07-4683-b625-2bbf9f35f566", | ||
"inflight_reqid": "3b6435cb-37d1-4401-7dcd-b78cf181917d", | ||
"ts": "2022-10-26T09:03:24.141596234Z", | ||
"cr_time": "2022-10-26T09:02:44.646758236Z", | ||
"progress": 1, | ||
"external_id": "f3015250-99fb-415b-a8ee-5c16f3e58514", | ||
"arch": "arm64", | ||
"vlan": "", | ||
"startup_script": { | ||
"return_code": 127, | ||
"did_timeout": false, | ||
"stdout": "", | ||
"stderr": "sh: line 1: asdadfasdflakdsmnflaksdnfaklsdnf!@#$: command not found\n" | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"status": "OK", | ||
"message": "", | ||
"body": { | ||
"instance_id": "7b3421d9-764c-481c-5e74-8cbd741d3930", | ||
"instance_state": "Scheduling", | ||
"anka_registry": "https://19.188.188.108:8089", | ||
"vmid": "4c641deb-9822-4718-a757-5775799d9bc8", | ||
"tag": "latest", | ||
"inflight_reqid": "3b6435cb-37d1-4401-7dcd-b78cf181917d", | ||
"ts": "2022-10-26T09:02:44.646756913Z", | ||
"cr_time": "2022-10-26T09:02:44.646758236Z", | ||
"progress": 0, | ||
"external_id": "f3015250-99fb-415b-a8ee-5c16f3e58514", | ||
"arch": "arm64", | ||
"vlan": "" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"status": "FAIL", | ||
"message": "VM not in the registry" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"status": "OK", | ||
"message": "", | ||
"body": [ | ||
"b7fed205-ceab-4938-60cd-1369a3cc0d4f" | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"status": "OK", | ||
"message": "" | ||
} |
Oops, something went wrong.