Skip to content

Add workflow to run CLI E2E tests on PRs and Pushes to dev branch #5

Add workflow to run CLI E2E tests on PRs and Pushes to dev branch

Add workflow to run CLI E2E tests on PRs and Pushes to dev branch #5

name: Run Tests with Linode CLI and JSON Spec
on:
push:
branches:
- development
pull_request:
branches:
- 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
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' ||
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
# 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
- 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 }}