From 8564d9ae735c4d1364fd1ee8b1eca62a329e56d4 Mon Sep 17 00:00:00 2001 From: Youjung Kim Date: Mon, 10 Mar 2025 13:48:26 -0700 Subject: [PATCH 01/12] gha test 1 --- .github/workflows/cli-verify-json-pr.yml | 70 ++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/cli-verify-json-pr.yml diff --git a/.github/workflows/cli-verify-json-pr.yml b/.github/workflows/cli-verify-json-pr.yml new file mode 100644 index 000000000..aa36cb908 --- /dev/null +++ b/.github/workflows/cli-verify-json-pr.yml @@ -0,0 +1,70 @@ +name: Run Tests with Linode CLI and JSON Spec + +on: + push: + branches: + - development + pull_request: + branches: + - development + workflow_dispatch: + inputs: + sha: + description: 'Specify commit hash to test. This value is mandatory to ensure the tests run against a specific commit' + required: true + default: '' + pull_request_number: + description: 'Specify pull request number associated with the commit. Optional, but recommended when providing a commit hash (sha)' + required: false + test_suite: + description: "Specify test suite to run from the 'tests/integration' directory. Examples: 'cli', 'domains', 'events', etc. If not provided, all suites are executed" + required: false + run_long_tests: + description: "Select 'True' to include long-running tests (e.g., database provisioning, server rebuilds). Defaults to 'False'" + required: false + type: choice + options: + - "True" + - "False" + default: "False" + +jobs: + test-linode-cli: + runs-on: ubuntu-latest + if: github.event_name == 'workflow_dispatch' && inputs.sha != '' || github.event_name == 'push' || github.event_name == 'pull_request' + + steps: + - name: Checkout Current Repository (JSON Spec) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: 'recursive' + ref: ${{ inputs.sha || github.ref }} + path: json-spec + + - name: Checkout Linode CLI (dev branch) + uses: actions/checkout@v4 + with: + repository: linode/linode-cli + ref: dev + path: linode-cli + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.9" + + - name: Get JSON Spec Path + run: echo "JSON_SPEC_PATH=$(pwd)/json-spec/spec.json" >> $GITHUB_ENV + + - name: Install Linode CLI dependencies + run: | + cd linode-cli + SPEC=$JSON_SPEC_PATH make install + + - name: Run CLI E2E Tests + run: | + cd linode-cli + make test-int TEST_SUITE="${{ inputs.test_suite }}" RUN_LONG_TESTS="${{ inputs.run_long_tests }}" + env: + LINODE_CLI_TOKEN: ${{ env.LINODE_CLI_TOKEN }} From c05a0019803b899371a4ff5f021eefe193e2e85d Mon Sep 17 00:00:00 2001 From: Youjung Kim Date: Mon, 10 Mar 2025 13:54:18 -0700 Subject: [PATCH 02/12] gha test 1 --- .github/workflows/cli-verify-json-pr.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cli-verify-json-pr.yml b/.github/workflows/cli-verify-json-pr.yml index aa36cb908..b353dc750 100644 --- a/.github/workflows/cli-verify-json-pr.yml +++ b/.github/workflows/cli-verify-json-pr.yml @@ -17,7 +17,7 @@ on: description: 'Specify pull request number associated with the commit. Optional, but recommended when providing a commit hash (sha)' required: false test_suite: - description: "Specify test suite to run from the 'tests/integration' directory. Examples: 'cli', 'domains', 'events', etc. If not provided, all suites are executed" + description: "Specify test suite to run from the 'tests/integration' directory. Examples: 'cli', 'domains', 'events', etc. If not provided, all suites are executed" required: false run_long_tests: description: "Select 'True' to include long-running tests (e.g., database provisioning, server rebuilds). Defaults to 'False'" @@ -52,7 +52,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.9" + python-version: "3.10" - name: Get JSON Spec Path run: echo "JSON_SPEC_PATH=$(pwd)/json-spec/spec.json" >> $GITHUB_ENV @@ -60,11 +60,11 @@ jobs: - name: Install Linode CLI dependencies run: | cd linode-cli - SPEC=$JSON_SPEC_PATH make install + SPEC="$JSON_SPEC_PATH" make install - name: Run CLI E2E Tests run: | cd linode-cli make test-int TEST_SUITE="${{ inputs.test_suite }}" RUN_LONG_TESTS="${{ inputs.run_long_tests }}" env: - LINODE_CLI_TOKEN: ${{ env.LINODE_CLI_TOKEN }} + LINODE_CLI_TOKEN: ${{ secrets.LINODE_CLI_TOKEN }} From dd3759964702940fcb5ae4dcdf594ae90a35320a Mon Sep 17 00:00:00 2001 From: Youjung Kim Date: Mon, 10 Mar 2025 14:05:34 -0700 Subject: [PATCH 03/12] add cli e2e workflow --- .github/workflows/cli-verify-json-pr.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cli-verify-json-pr.yml b/.github/workflows/cli-verify-json-pr.yml index b353dc750..45c4d481c 100644 --- a/.github/workflows/cli-verify-json-pr.yml +++ b/.github/workflows/cli-verify-json-pr.yml @@ -27,11 +27,22 @@ on: - "True" - "False" default: "False" + run_on_pr: + description: "Select 'True' to allow execution on pull requests when using workflow_dispatch. Defaults to 'False'" + required: false + type: choice + options: + - "True" + - "False" + default: "False" jobs: test-linode-cli: runs-on: ubuntu-latest - if: github.event_name == 'workflow_dispatch' && inputs.sha != '' || github.event_name == 'push' || github.event_name == 'pull_request' + if: | + github.event_name == 'workflow_dispatch' && inputs.sha != '' || + github.event_name == 'push' || + (github.event_name == 'pull_request' && inputs.run_on_pr == 'True') steps: - name: Checkout Current Repository (JSON Spec) @@ -55,7 +66,7 @@ jobs: python-version: "3.10" - name: Get JSON Spec Path - run: echo "JSON_SPEC_PATH=$(pwd)/json-spec/spec.json" >> $GITHUB_ENV + run: echo "JSON_SPEC_PATH=$(pwd)/json-spec/openapi.json" >> $GITHUB_ENV - name: Install Linode CLI dependencies run: | From b11b4e9855ab50bf618a9ce38616518bda7be91e Mon Sep 17 00:00:00 2001 From: Youjung Kim Date: Mon, 10 Mar 2025 14:09:59 -0700 Subject: [PATCH 04/12] add cli e2e workflow --- .github/workflows/cli-verify-json-pr.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cli-verify-json-pr.yml b/.github/workflows/cli-verify-json-pr.yml index 45c4d481c..4bc227ef4 100644 --- a/.github/workflows/cli-verify-json-pr.yml +++ b/.github/workflows/cli-verify-json-pr.yml @@ -66,7 +66,10 @@ jobs: python-version: "3.10" - name: Get JSON Spec Path - run: echo "JSON_SPEC_PATH=$(pwd)/json-spec/openapi.json" >> $GITHUB_ENV + run: | + cd json-spec + ls -l + echo "JSON_SPEC_PATH=$(pwd)/openapi.json" >> $GITHUB_ENV - name: Install Linode CLI dependencies run: | From dff05b9e7464f2a1120bfb3fc287c701ed9785f3 Mon Sep 17 00:00:00 2001 From: Youjung Kim Date: Mon, 10 Mar 2025 14:17:43 -0700 Subject: [PATCH 05/12] add cli e2e workflow --- .github/workflows/cli-verify-json-pr.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cli-verify-json-pr.yml b/.github/workflows/cli-verify-json-pr.yml index 4bc227ef4..7d11b287e 100644 --- a/.github/workflows/cli-verify-json-pr.yml +++ b/.github/workflows/cli-verify-json-pr.yml @@ -71,10 +71,14 @@ jobs: ls -l echo "JSON_SPEC_PATH=$(pwd)/openapi.json" >> $GITHUB_ENV + - name: get 10 lines + run: | + cat "${{ env.JSON_SPEC_PATH }}" | head 10 + - name: Install Linode CLI dependencies run: | cd linode-cli - SPEC="$JSON_SPEC_PATH" make install + SPEC="${{ env.JSON_SPEC_PATH }}" make install - name: Run CLI E2E Tests run: | From 6824e6d93e94476473fcc20a36b01344dd26618d Mon Sep 17 00:00:00 2001 From: Youjung Kim Date: Mon, 10 Mar 2025 14:19:06 -0700 Subject: [PATCH 06/12] add cli e2e workflow --- .github/workflows/cli-verify-json-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cli-verify-json-pr.yml b/.github/workflows/cli-verify-json-pr.yml index 7d11b287e..7ab273660 100644 --- a/.github/workflows/cli-verify-json-pr.yml +++ b/.github/workflows/cli-verify-json-pr.yml @@ -73,7 +73,7 @@ jobs: - name: get 10 lines run: | - cat "${{ env.JSON_SPEC_PATH }}" | head 10 + cat "${{ env.JSON_SPEC_PATH }}" | head -10 - name: Install Linode CLI dependencies run: | From 980a3439d982b6b3de210d411e6006663b569e95 Mon Sep 17 00:00:00 2001 From: Youjung Kim Date: Mon, 10 Mar 2025 14:31:21 -0700 Subject: [PATCH 07/12] add cli e2e workflow --- .github/workflows/cli-verify-json-pr.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/cli-verify-json-pr.yml b/.github/workflows/cli-verify-json-pr.yml index 7ab273660..03218f1a7 100644 --- a/.github/workflows/cli-verify-json-pr.yml +++ b/.github/workflows/cli-verify-json-pr.yml @@ -68,14 +68,9 @@ jobs: - name: Get JSON Spec Path run: | cd json-spec - ls -l echo "JSON_SPEC_PATH=$(pwd)/openapi.json" >> $GITHUB_ENV - - name: get 10 lines - run: | - cat "${{ env.JSON_SPEC_PATH }}" | head -10 - - - name: Install Linode CLI dependencies + - name: Install Linode CLI run: | cd linode-cli SPEC="${{ env.JSON_SPEC_PATH }}" make install From 7a427b8afaa3f9a7cda7401c0c90c3e2d94217e1 Mon Sep 17 00:00:00 2001 From: Youjung Kim Date: Mon, 10 Mar 2025 14:39:49 -0700 Subject: [PATCH 08/12] fix lint --- .github/workflows/test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9240a15e5..2dc25c529 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -6,14 +6,14 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: '3.7.x' architecture: 'x64' - name: Cache pip - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.cache/pip # Look to see if there is a cache hit for the corresponding requirements file From 87ba19676f0e418d06ba67bc50c68737d16d9b46 Mon Sep 17 00:00:00 2001 From: Youjung Kim Date: Mon, 10 Mar 2025 14:40:49 -0700 Subject: [PATCH 09/12] fix lint --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2dc25c529..e1b34ff6a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,7 +10,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.7.x' + python-version: '3.10' architecture: 'x64' - name: Cache pip uses: actions/cache@v3 From 3f7aae72a49cc92b1b15490f9479e40ac741e5be Mon Sep 17 00:00:00 2001 From: Youjung Kim Date: Mon, 10 Mar 2025 14:42:41 -0700 Subject: [PATCH 10/12] update yaml to json --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index e1b34ff6a..661b6d3ea 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -27,4 +27,4 @@ jobs: pip install openapi3 - name: openapi linter run: | - python -m openapi3 openapi.yaml \ No newline at end of file + python -m openapi3 openapi.json \ No newline at end of file From d090b300490055448d5acf2380bf5867f2286fd2 Mon Sep 17 00:00:00 2001 From: Youjung Kim Date: Mon, 10 Mar 2025 17:19:00 -0700 Subject: [PATCH 11/12] add spec_file input --- .github/workflows/cli-verify-json-pr.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cli-verify-json-pr.yml b/.github/workflows/cli-verify-json-pr.yml index 03218f1a7..48c09e07e 100644 --- a/.github/workflows/cli-verify-json-pr.yml +++ b/.github/workflows/cli-verify-json-pr.yml @@ -9,9 +9,13 @@ on: - development workflow_dispatch: inputs: + spec_file: + description: 'Choose a file' + required: false + type: 'file' sha: description: 'Specify commit hash to test. This value is mandatory to ensure the tests run against a specific commit' - required: true + required: false default: '' pull_request_number: description: 'Specify pull request number associated with the commit. Optional, but recommended when providing a commit hash (sha)' @@ -40,7 +44,7 @@ jobs: test-linode-cli: runs-on: ubuntu-latest if: | - github.event_name == 'workflow_dispatch' && inputs.sha != '' || + github.event_name == 'workflow_dispatch' || github.event_name == 'push' || (github.event_name == 'pull_request' && inputs.run_on_pr == 'True') @@ -68,12 +72,19 @@ jobs: - name: Get JSON Spec Path run: | cd json-spec + # Set default JSON spec path echo "JSON_SPEC_PATH=$(pwd)/openapi.json" >> $GITHUB_ENV + # If spec_file is provided, use it; otherwise fallback to default + if [[ -n "${{ inputs.spec_file }}" ]]; then + echo "SPEC_FILE_PATH=${{ inputs.spec_file }}" >> $GITHUB_ENV + else + echo "SPEC_FILE_PATH=$(pwd)/openapi.json" >> $GITHUB_ENV + fi - name: Install Linode CLI run: | cd linode-cli - SPEC="${{ env.JSON_SPEC_PATH }}" make install + SPEC="${{ env.SPEC_FILE_PATH }}" make install - name: Run CLI E2E Tests run: | From 8e85d1d58d54a612d8325da5fdc3e7103a5e8b42 Mon Sep 17 00:00:00 2001 From: Youjung Kim Date: Tue, 11 Mar 2025 08:47:00 -0700 Subject: [PATCH 12/12] remove file input --- .github/workflows/cli-verify-json-pr.yml | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/.github/workflows/cli-verify-json-pr.yml b/.github/workflows/cli-verify-json-pr.yml index 48c09e07e..03218f1a7 100644 --- a/.github/workflows/cli-verify-json-pr.yml +++ b/.github/workflows/cli-verify-json-pr.yml @@ -9,13 +9,9 @@ on: - development workflow_dispatch: inputs: - spec_file: - description: 'Choose a file' - required: false - type: 'file' sha: description: 'Specify commit hash to test. This value is mandatory to ensure the tests run against a specific commit' - required: false + required: true default: '' pull_request_number: description: 'Specify pull request number associated with the commit. Optional, but recommended when providing a commit hash (sha)' @@ -44,7 +40,7 @@ jobs: test-linode-cli: runs-on: ubuntu-latest if: | - github.event_name == 'workflow_dispatch' || + github.event_name == 'workflow_dispatch' && inputs.sha != '' || github.event_name == 'push' || (github.event_name == 'pull_request' && inputs.run_on_pr == 'True') @@ -72,19 +68,12 @@ jobs: - name: Get JSON Spec Path run: | cd json-spec - # Set default JSON spec path echo "JSON_SPEC_PATH=$(pwd)/openapi.json" >> $GITHUB_ENV - # If spec_file is provided, use it; otherwise fallback to default - if [[ -n "${{ inputs.spec_file }}" ]]; then - echo "SPEC_FILE_PATH=${{ inputs.spec_file }}" >> $GITHUB_ENV - else - echo "SPEC_FILE_PATH=$(pwd)/openapi.json" >> $GITHUB_ENV - fi - name: Install Linode CLI run: | cd linode-cli - SPEC="${{ env.SPEC_FILE_PATH }}" make install + SPEC="${{ env.JSON_SPEC_PATH }}" make install - name: Run CLI E2E Tests run: |