diff --git a/.github/workflows/cli-verify-json-pr.yml b/.github/workflows/cli-verify-json-pr.yml new file mode 100644 index 000000000..03218f1a7 --- /dev/null +++ b/.github/workflows/cli-verify-json-pr.yml @@ -0,0 +1,83 @@ +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" + 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' && inputs.run_on_pr == 'True') + + 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.10" + + - name: Get JSON Spec Path + run: | + cd json-spec + echo "JSON_SPEC_PATH=$(pwd)/openapi.json" >> $GITHUB_ENV + + - name: Install Linode CLI + run: | + cd linode-cli + SPEC="${{ env.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: ${{ secrets.LINODE_CLI_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9240a15e5..661b6d3ea 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' + python-version: '3.10' 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 @@ -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