From a6cddbbe39d16e6fd5f4bbc924e984aaef0ec070 Mon Sep 17 00:00:00 2001 From: Deepak Dahiya <59823596+t-dedah@users.noreply.github.com> Date: Thu, 9 Sep 2021 22:57:43 +0000 Subject: [PATCH 1/2] Resolved multiple issues --- .github/workflows/ci-workflow.yml | 6 +++--- README.md | 13 ++++++------- {test => src/test}/main.test.ts | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) rename {test => src/test}/main.test.ts (92%) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 464f0664..b3f035b5 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -29,7 +29,7 @@ jobs: az account show az storage -h EXPECTED_TO: pass - run: ts-node test/main.test.ts + run: ts-node src/test/main.test.ts - name: Azure CLI Version Test - Negative env: @@ -38,14 +38,14 @@ jobs: az account show az storage -h EXPECTED_TO: fail - run: ts-node test/main.test.ts + run: ts-node src/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 + run: ts-node src/test/main.test.ts - name: Post to slack on failure if: failure() diff --git a/README.md b/README.md index 8afc5646..30c769f3 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,15 @@ Azure CLI GitHub Action is supported for the Azure public cloud as well as Azure The definition of this GitHub Action is in [action.yml](https://github.com/Azure/CLI/blob/master/action.yml). The action status is determined by the exit code returned by the script rather than StandardError stream. +## Note +Please note that the action executes Az CLI script in a docker container. This means that the action is subjected to potential restrictions which arise from containerized execution. For example: + 1. If script sets up an environment variable, it will not take effect in host and hence subsequent actions shouldn't rely on such environment variable. + 2. There is some restriction on how cross action file read/write is done. GITHUB_WORKSPACE directory in host is mapped to working directory inside container. So, if the action wants to create a file, which will be read by subsequent actions, it should do so within current working directory tree. + ## Sample workflow ### Dependencies on other GitHub Actions -* [Azure Login](https://github.com/Azure/login) – **Required** Login with your Azure credentials +* [Azure Login](https://github.com/Azure/login) – **Optional** Login with your Azure credentials, required only for authentication via azure credentials. Authentication via connection strings or keys do not require this step. * [Checkout](https://github.com/actions/checkout) – **Optional** To execute the scripts present in your repository ### Workflow to execute an AZ CLI script of a specific CLI version ``` @@ -106,12 +111,6 @@ Follow the steps to configure the secret: ``` * Now in the workflow file in your branch: `.github/workflows/workflow.yml` replace the secret in Azure login action with your secret (Refer to the example above) - -## Note -Please note that the action executes Az CLI script in a docker container. This means that the action is subjected to potential restrictions which arise from containerized execution. For example: - 1. If script sets up an environment variable, it will not take effect in host and hence subsequent actions shouldn't rely on such environment variable. - 2. There is some restriction on how cross action file read/write is done. GITHUB_WORKSPACE directory in host is mapped to working directory inside container. So, if the action wants to create a file, which will be read by subsequent actions, it should do so within current working directory tree. - ## Azure CLI Action metadata file ``` diff --git a/test/main.test.ts b/src/test/main.test.ts similarity index 92% rename from test/main.test.ts rename to src/test/main.test.ts index 3a51408e..339f2f21 100644 --- a/test/main.test.ts +++ b/src/test/main.test.ts @@ -1,4 +1,4 @@ -import { run } from "../src/main"; +import { run } from "../main"; import * as core from '@actions/core'; run() From e4bba2be5281755737709fcdfe5ffa3e0ab41f00 Mon Sep 17 00:00:00 2001 From: Deepak Dahiya <59823596+t-dedah@users.noreply.github.com> Date: Thu, 9 Sep 2021 23:01:47 +0000 Subject: [PATCH 2/2] revert --- .github/workflows/ci-workflow.yml | 6 +++--- {src/test => test}/main.test.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) rename {src/test => test}/main.test.ts (92%) diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index b3f035b5..464f0664 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -29,7 +29,7 @@ jobs: az account show az storage -h EXPECTED_TO: pass - run: ts-node src/test/main.test.ts + run: ts-node test/main.test.ts - name: Azure CLI Version Test - Negative env: @@ -38,14 +38,14 @@ jobs: az account show az storage -h EXPECTED_TO: fail - run: ts-node src/test/main.test.ts + 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 src/test/main.test.ts + run: ts-node test/main.test.ts - name: Post to slack on failure if: failure() diff --git a/src/test/main.test.ts b/test/main.test.ts similarity index 92% rename from src/test/main.test.ts rename to test/main.test.ts index 339f2f21..3a51408e 100644 --- a/src/test/main.test.ts +++ b/test/main.test.ts @@ -1,4 +1,4 @@ -import { run } from "../main"; +import { run } from "../src/main"; import * as core from '@actions/core'; run()