Skip to content

Commit ac7377e

Browse files
Merge pull request #475 from linode/dev
Release 5.41.0
2 parents 3dc7147 + 7c9e549 commit ac7377e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1370
-467
lines changed

.github/workflows/e2e-suite-pr.yml

Lines changed: 131 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,61 @@
11
on:
22
pull_request:
3-
repository_dispatch:
4-
types: [acctest-command]
3+
workflow_dispatch:
4+
inputs:
5+
test_path:
6+
description: 'Test path to be tested: e.g. integration/cli'
7+
required: false
8+
sha:
9+
description: 'The hash value of the commit.'
10+
required: true
11+
pull_request_number:
12+
description: 'The number of the PR.'
13+
required: false
514

615
name: PR E2E Tests
716

817
jobs:
9-
# Maintainer has commented /acctest on a pull request
10-
integration-fork:
18+
integration-fork-ubuntu:
1119
runs-on: ubuntu-latest
1220
if:
13-
github.event_name == 'repository_dispatch' &&
14-
github.event.client_payload.slash_command.sha != '' &&
15-
github.event.client_payload.pull_request.head.sha == github.event.client_payload.slash_command.sha
21+
github.event_name == 'workflow_dispatch' && inputs.sha != ''
1622

1723
steps:
1824
- uses: actions-ecosystem/action-regex-match@v2
1925
id: validate-tests
2026
with:
21-
text: ${{ github.event.client_payload.slash_command.tests }}
27+
text: ${{ inputs.test_path }}
2228
regex: '[^a-z0-9-:.\/_]' # Tests validation
2329
flags: gi
2430

2531
# Check out merge commit
2632
- name: Checkout PR
2733
uses: actions/checkout@v3
2834
with:
29-
ref: ${{ github.event.client_payload.slash_command.sha }}
35+
ref: ${{ inputs.sha }}
36+
37+
- name: Get the hash value of the latest commit from the PR branch
38+
uses: octokit/graphql-action@v2.x
39+
id: commit-hash
40+
if: ${{ inputs.pull_request_number != '' }}
41+
with:
42+
query: |
43+
query PRHeadCommitHash($owner: String!, $repo: String!, $pr_num: Int!) {
44+
repository(owner:$owner, name:$repo) {
45+
pullRequest(number: $pr_num) {
46+
headRef {
47+
target {
48+
... on Commit {
49+
oid
50+
}
51+
}
52+
}
53+
}
54+
}
55+
}
56+
owner: ${{ github.event.repository.owner.login }}
57+
repo: ${{ github.event.repository.name }}
58+
pr_num: ${{ fromJSON(inputs.pull_request_number) }}
3059

3160
- name: Update system packages
3261
run: sudo apt-get update -y
@@ -47,16 +76,16 @@ jobs:
4776
env:
4877
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4978

50-
- run: make INTEGRATION_TEST_PATH="${{ github.event.client_payload.slash_command.tests }}" testint
79+
- run: make INTEGRATION_TEST_PATH="${{ inputs.test_path }}" testint
5180
if: ${{ steps.validate-tests.outputs.match == '' }}
5281
env:
5382
LINODE_CLI_TOKEN: ${{ secrets.LINODE_TOKEN }}
5483

55-
- uses: actions/github-script@v5
84+
- uses: actions/github-script@v6
5685
id: update-check-run
57-
if: ${{ always() }}
86+
if: ${{ inputs.pull_request_number != '' && fromJson(steps.commit-hash.outputs.data).repository.pullRequest.headRef.target.oid == inputs.sha }}
5887
env:
59-
number: ${{ github.event.client_payload.pull_request.number }}
88+
number: ${{ inputs.pull_request_number }}
6089
job: ${{ github.job }}
6190
conclusion: ${{ job.status }}
6291
with:
@@ -79,3 +108,92 @@ jobs:
79108
conclusion: process.env.conclusion
80109
});
81110
return result;
111+
112+
integration-fork-windows:
113+
runs-on: windows-latest
114+
if:
115+
github.event_name == 'workflow_dispatch' && inputs.sha != ''
116+
117+
steps:
118+
- uses: actions-ecosystem/action-regex-match@v2
119+
id: validate-tests
120+
with:
121+
text: ${{ inputs.test_path }}
122+
regex: '[^a-z0-9-:.\/_]' # Tests validation
123+
flags: gi
124+
125+
# Check out merge commit
126+
- name: Checkout PR
127+
uses: actions/checkout@v3
128+
with:
129+
ref: ${{ inputs.sha }}
130+
131+
- name: Get the hash value of the latest commit from the PR branch
132+
uses: octokit/graphql-action@v2.x
133+
id: commit-hash
134+
if: ${{ inputs.pull_request_number != '' }}
135+
with:
136+
query: |
137+
query PRHeadCommitHash($owner: String!, $repo: String!, $pr_num: Int!) {
138+
repository(owner:$owner, name:$repo) {
139+
pullRequest(number: $pr_num) {
140+
headRef {
141+
target {
142+
... on Commit {
143+
oid
144+
}
145+
}
146+
}
147+
}
148+
}
149+
}
150+
owner: ${{ github.event.repository.owner.login }}
151+
repo: ${{ github.event.repository.name }}
152+
pr_num: ${{ fromJSON(inputs.pull_request_number) }}
153+
env:
154+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155+
156+
- name: Setup Python
157+
uses: actions/setup-python@v4
158+
with:
159+
python-version: '3.x'
160+
161+
- name: Install Python deps
162+
run: pip install -r requirements.txt -r requirements-dev.txt wheel boto3
163+
164+
- name: Install the CLI
165+
run: make install
166+
env:
167+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168+
169+
- run: make INTEGRATION_TEST_PATH="${{ inputs.test_path }}" testint
170+
env:
171+
LINODE_CLI_TOKEN: ${{ secrets.LINODE_TOKEN_2 }}
172+
173+
- uses: actions/github-script@v6
174+
id: update-check-run
175+
if: ${{ inputs.pull_request_number != '' && fromJson(steps.commit-hash.outputs.data).repository.pullRequest.headRef.target.oid == inputs.sha }}
176+
env:
177+
number: ${{ github.event.client_payload.pull_request.number }}
178+
job: ${{ github.job }}
179+
conclusion: ${{ job.status }}
180+
with:
181+
github-token: ${{ secrets.GITHUB_TOKEN }}
182+
script: |
183+
const { data: pull } = await github.rest.pulls.get({
184+
...context.repo,
185+
pull_number: process.env.number
186+
});
187+
const ref = pull.head.sha;
188+
const { data: checks } = await github.rest.checks.listForRef({
189+
...context.repo,
190+
ref
191+
});
192+
const check = checks.check_runs.filter(c => c.name === process.env.job);
193+
const { data: result } = await github.rest.checks.update({
194+
...context.repo,
195+
check_run_id: check[0].id,
196+
status: 'completed',
197+
conclusion: process.env.conclusion
198+
});
199+
return result;

.github/workflows/remote-release-trigger.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,43 @@ jobs:
2727
env:
2828
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2929

30-
- name: Get the next minor version
31-
id: semvers
32-
uses: WyriHaximus/github-action-next-semvers@d079934efaf011a4cf8912d4637097fe35d32b93 # pin@v1
30+
- name: Calculate the desired release version
31+
id: calculate_version
32+
uses: actions/github-script@v6
33+
env:
34+
SPEC_VERSION: ${{ github.event.client_payload.spec_version }}
35+
PREVIOUS_CLI_VERSION: ${{ steps.previoustag.outputs.tag }}
3336
with:
37+
result-encoding: string
3438
version: ${{ steps.previoustag.outputs.tag }}
39+
script: |
40+
let spec_version_segments = process.env.SPEC_VERSION.replace("v", "").split(".");
41+
let cli_version_segments = process.env.PREVIOUS_CLI_VERSION.replace("v", "").split(".");
42+
43+
// Default to a patch version bump
44+
let bump_idx = 2;
45+
46+
// This is a minor version bump
47+
if (spec_version_segments[2] == "0") {
48+
bump_idx = 1;
49+
50+
// The patch number should revert to 0
51+
cli_version_segments[2] = "0"
52+
}
53+
54+
// Bump the version
55+
cli_version_segments[bump_idx] = (parseInt(cli_version_segments[bump_idx]) + 1).toString()
56+
57+
return "v" + cli_version_segments.join(".")
3558
3659
- uses: rickstaa/action-create-tag@84c90e6ba79b47b5147dcb11ff25d6a0e06238ba # pin@v1
3760
with:
38-
tag: ${{ steps.semvers.outputs.v_minor }}
61+
tag: ${{ steps.calculate_version.outputs.result }}
3962

4063
- name: Release
4164
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1
4265
with:
4366
target_commitish: 'main'
4467
token: ${{ steps.generate_token.outputs.token }}
4568
body: Built from Linode OpenAPI spec ${{ github.event.client_payload.spec_version }}
46-
tag_name: ${{ steps.semvers.outputs.v_minor }}
69+
tag_name: ${{ steps.calculate_version.outputs.result }}

.github/workflows/unit-tests.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ on:
44
push:
55
pull_request:
66
jobs:
7-
unit-tests:
8-
name: Run unit tests
7+
unit-tests-on-ubuntu:
98
runs-on: ubuntu-latest
109
steps:
1110
- name: Clone Repository
@@ -35,3 +34,33 @@ jobs:
3534

3635
- name: Run the unit test suite
3736
run: make test
37+
38+
unit-tests-on-windows:
39+
runs-on: windows-latest
40+
steps:
41+
- name: Clone Repository
42+
uses: actions/checkout@v3
43+
44+
- name: Setup Python
45+
uses: actions/setup-python@v4
46+
with:
47+
python-version: '3.x'
48+
49+
- name: Install Python wheel
50+
run: pip install wheel boto3
51+
52+
- name: Update cert
53+
run: pip install certifi -U
54+
55+
- name: Install deps
56+
run: pip install -r requirements.txt -r requirements-dev.txt
57+
58+
- name: Install Package
59+
shell: pwsh
60+
run: |
61+
make install
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Run the unit test suite
66+
run: make test

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#
22
# Makefile for more convenient building of the Linode CLI and its baked content
33
#
4-
54
INTEGRATION_TEST_PATH :=
5+
TEST_CASE_COMMAND :=
6+
7+
ifdef TEST_CASE
8+
TEST_CASE_COMMAND = -k $(TEST_CASE)
9+
endif
10+
611

712
SPEC_VERSION ?= latest
813
ifndef SPEC
@@ -49,13 +54,12 @@ testunit:
4954

5055
.PHONY: testint
5156
testint:
52-
pytest tests/integration/${INTEGRATION_TEST_PATH}
57+
pytest tests/integration/${INTEGRATION_TEST_PATH} ${TEST_CASE_COMMAND} --disable-warnings
5358

5459
.PHONY: testall
5560
testall:
5661
pytest tests
5762

58-
5963
# Alias for unit; integration tests should be explicit
6064
.PHONY: test
6165
test: testunit

README.rst

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ you can execute the following::
179179

180180
linode-cli linodes create --region us-east --type g6-nanode-1 --tags tag1 --tags tag2
181181

182+
Lists consisting of nested structures can also be expressed through the command line.
183+
For example, to create a Linode with a public interface on ``eth0`` and a VLAN interface
184+
on ``eth1`` you can execute the following::
185+
186+
linode-cli linodes create \
187+
--region us-east --type g6-nanode-1 --image linode/ubuntu22.04 \
188+
--root_pass "myr00tp4ss123" \
189+
--interfaces.purpose public \
190+
--interfaces.purpose vlan --interfaces.label my-vlan
191+
182192
Specifying Nested Arguments
183193
"""""""""""""""""""""""""""
184194

@@ -241,6 +251,9 @@ the ``obj`` plugin that ships with the CLI. To do so, simply set
241251
appropriate values. This allows using Linode Object Storage through the CLI
242252
without having a configuration file, which is desirable in some situations.
243253

254+
You may also specify the path to a custom Certificate Authority file using the ``LINODE_CLI_CA``
255+
environment variable.
256+
244257
Configurable API URL
245258
""""""""""""""""""""
246259

@@ -412,45 +425,31 @@ Testing
412425
with the account. It is only recommended to run these tests if you are an advanced
413426
user.
414427

415-
Installation
416-
^^^^^^^^^^^^
417-
418-
The CLI uses the Bash Automated Testing System (BATS) for testing. To install run the following:
419-
420-
**OSX users**::
428+
Running the Tests
429+
^^^^^^^^^^^^^^^^^
421430

422-
brew install bats-core
431+
Running the tests locally is simple. The only requirements are that you export Linode API token as LINODE_CLI_TOKEN::
423432

424-
**Installing Bats from source**
433+
export LINODE_CLI_TOKEN="your_token"
425434

426-
Check out a copy of the Bats repository. Then, either add the Bats bin directory to your
427-
$PATH, or run the provided install.sh command with the location to the prefix in which you
428-
want to install Bats. For example, to install Bats into /usr/local::
429435

430-
git clone https://github.com/bats-core/bats-core.git
431-
cd bats-core
432-
./install.sh /usr/local
433436

434-
Running the Tests
435-
^^^^^^^^^^^^^^^^^
437+
More information on Managing Linode API tokens can be found here - https://www.linode.com/docs/products/tools/api/guides/manage-api-tokens/
436438

437-
Running the tests is simple. The only requirements are that you have a .linode-cli in your user folder containing your test user token::
439+
In order to run the full integration test, run::
438440

439-
./test/test-runner.sh
441+
make testint
440442

441-
**Running Tests via Docker**
443+
To run specific test package, use environment variable `INTEGRATION_TEST_PATH` with `testint` command::
442444

443-
The openapi spec must first be saved to the base of the linode-cli project:
445+
make INTEGRATION_TEST_PATH="cli" testint
444446

445-
curl -o ./openapi.yaml https://www.linode.com/docs/api/openapi.yaml
446447

447-
Run the following command to build the tests container:
448448

449-
docker build -f Dockerfile-bats -t linode-cli-tests .
449+
Lastly, to run specific test case, use environment variables `TEST_CASE` with `testint` command::
450450

451-
Run the following command to run the test
451+
make TEST_CASE=test_help_page_for_non_aliased_actions testint
452452

453-
docker run -e TOKEN_1=$INSERT_YOUR_TOKEN_HERE -e TOKEN_2=$INSERT_YOUR_TOKEN_HERE --rm linode-cli-tests
454453

455454
Contributing
456455
------------

0 commit comments

Comments
 (0)