Skip to content

Commit

Permalink
Added entrypoint.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
t-dedah committed Oct 26, 2022
1 parent 0b2143d commit 548c3ec
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- name: Compile files
run: |
ncc build -C -m src/main.ts
ncc build -C -m src/entrypoint.ts
- name: Commit Files
continue-on-error: true # commit will fail if the code wasn't changed. Prevent the build to fail in this case.
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ jobs:
EXPECTED_TO: pass
run: ts-node test/main.test.ts

# - name: Azure CLI Version Test - Negative
# env:
# INPUT_AZCLIVERSION: 0
# INPUT_INLINESCRIPT: |
# az account show
# az storage -h
# EXPECTED_TO: fail
# run: ts-node test/main.test.ts
- name: Azure CLI Version Test - Negative
env:
INPUT_AZCLIVERSION: 0
INPUT_INLINESCRIPT: |
az account show
az storage -h
EXPECTED_TO: fail
run: ts-node test/main.test.ts

# - name: Inline Script Test - Negative
# env:
# INPUT_AZCLIVERSION: 2.0.72
# INPUT_INLINESCRIPT: " "
# EXPECTED_TO: fail
# run: ts-node test/main.test.ts
- name: Inline Script Test - Negative
env:
INPUT_AZCLIVERSION: 2.0.72
INPUT_INLINESCRIPT: " "
EXPECTED_TO: fail
run: ts-node test/main.test.ts

- name: Post to slack on failure
if: failure()
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "cli",
"version": "1.0.6",
"version": "1.0.7",
"description": "Automate your GitHub workflows using Azure CLI scripts.",
"main": "lib/main.js",
"main": "src/main.js",
"scripts": {
"build": "tsc",
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
11 changes: 11 additions & 0 deletions src/entrypoint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { setFailed } from '@actions/core';
import { main } from './main';

main()
.then(() => {
process.exit(0)
})
.catch((err: Error) => {
setFailed(err.message);
process.exit(1);
});
2 changes: 0 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,3 @@ const executeDockerCommand = async (dockerCommand: string, continueOnError: bool
core.warning(errorStream)
}
}

main()
2 changes: 1 addition & 1 deletion test/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as core from '@actions/core';
// Unit Tests
export async function runTests() {
try {
let result = await main()
await main()
return 'pass'
} catch (e) {
core.error(JSON.stringify(e))
Expand Down

0 comments on commit 548c3ec

Please sign in to comment.