Skip to content

Commit e2b8c46

Browse files
authored
test: Update smoke test coverage and improve nightly test workflow (#452)
* update smoke test coverage and workflow * make format lint * Replace webhook with slack oauth token * Add fancy slack payload * Clean up slack payload syntax * Clean up slack payload syntax * fix invalid slack payload syntax * fix invalid slack payload syntax * setting payload variable in separate step * fix slack payload syntax * fix slack payload syntax * fix slack payload syntax * fix slack payload syntax * add repository name in slack payload * add slack notifications and conditions
1 parent 77dde13 commit e2b8c46

9 files changed

Lines changed: 150 additions & 0 deletions

File tree

.github/workflows/e2e-test.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,69 @@ jobs:
9191
env:
9292
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
9393
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
94+
95+
notify-slack:
96+
runs-on: ubuntu-latest
97+
needs: [integration-tests]
98+
if: always() && github.repository == 'linode/linode_api4-python' # Run even if integration tests fail and only on main repository
99+
100+
steps:
101+
- name: Notify Slack
102+
uses: slackapi/slack-github-action@v1.27.0
103+
with:
104+
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
105+
payload: |
106+
{
107+
"blocks": [
108+
{
109+
"type": "section",
110+
"text": {
111+
"type": "mrkdwn",
112+
"text": ":rocket: *${{ github.workflow }} Completed in: ${{ github.repository }}* :white_check_mark:"
113+
}
114+
},
115+
{
116+
"type": "divider"
117+
},
118+
{
119+
"type": "section",
120+
"fields": [
121+
{
122+
"type": "mrkdwn",
123+
"text": "*Build Result:*\n${{ steps.integration-tests.outcome == 'success' && ':large_green_circle: Build Passed' || ':red_circle: Build Failed' }}"
124+
},
125+
{
126+
"type": "mrkdwn",
127+
"text": "*Branch:*\n`${{ github.ref_name }}`"
128+
}
129+
]
130+
},
131+
{
132+
"type": "section",
133+
"fields": [
134+
{
135+
"type": "mrkdwn",
136+
"text": "*Commit Hash:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>"
137+
},
138+
{
139+
"type": "mrkdwn",
140+
"text": "*Run URL:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run Details>"
141+
}
142+
]
143+
},
144+
{
145+
"type": "divider"
146+
},
147+
{
148+
"type": "context",
149+
"elements": [
150+
{
151+
"type": "mrkdwn",
152+
"text": "Triggered by: :bust_in_silhouette: `${{ github.actor }}`"
153+
}
154+
]
155+
}
156+
]
157+
}
158+
env:
159+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

.github/workflows/nightly-smoke-tests.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@ on:
44
schedule:
55
- cron: "0 0 * * *"
66
workflow_dispatch:
7+
inputs:
8+
sha:
9+
description: 'Commit SHA to test'
10+
required: false
11+
default: ''
12+
type: string
13+
714

815
jobs:
916
smoke_tests:
17+
if: github.repository == 'linode/linode_api4-python' || github.event_name == 'workflow_dispatch'
1018
runs-on: ubuntu-latest
1119

1220
steps:
@@ -29,7 +37,70 @@ jobs:
2937
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3038

3139
- name: Run smoke tests
40+
id: smoke_tests
3241
run: |
3342
make smoketest
3443
env:
3544
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
45+
46+
- name: Notify Slack
47+
if: always() && github.repository == 'linode/linode_api4-python'
48+
uses: slackapi/slack-github-action@v1.27.0
49+
with:
50+
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
51+
payload: |
52+
{
53+
"blocks": [
54+
{
55+
"type": "section",
56+
"text": {
57+
"type": "mrkdwn",
58+
"text": ":rocket: *${{ github.workflow }} Completed in: ${{ github.repository }}* :white_check_mark:"
59+
}
60+
},
61+
{
62+
"type": "divider"
63+
},
64+
{
65+
"type": "section",
66+
"fields": [
67+
{
68+
"type": "mrkdwn",
69+
"text": "*Build Result:*\n${{ steps.smoke_tests.outcome == 'success' && ':large_green_circle: Build Passed' || ':red_circle: Build Failed' }}"
70+
},
71+
{
72+
"type": "mrkdwn",
73+
"text": "*Branch:*\n`${{ github.ref_name }}`"
74+
}
75+
]
76+
},
77+
{
78+
"type": "section",
79+
"fields": [
80+
{
81+
"type": "mrkdwn",
82+
"text": "*Commit Hash:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>"
83+
},
84+
{
85+
"type": "mrkdwn",
86+
"text": "*Run URL:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run Details>"
87+
}
88+
]
89+
},
90+
{
91+
"type": "divider"
92+
},
93+
{
94+
"type": "context",
95+
"elements": [
96+
{
97+
"type": "mrkdwn",
98+
"text": "Triggered by: :bust_in_silhouette: `${{ github.actor }}`"
99+
}
100+
]
101+
}
102+
]
103+
}
104+
env:
105+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
106+

test/integration/login_client/test_login_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def test_oauth_client_two(test_linode_client):
2727
oauth_client.delete()
2828

2929

30+
@pytest.mark.smoke
3031
def test_get_oathclient(test_linode_client, test_oauth_client):
3132
client = test_linode_client
3233

test/integration/models/lke/test_lke.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def test_get_lke_clusters(test_linode_client, lke_cluster):
127127
assert cluster._raw_json == lke_cluster._raw_json
128128

129129

130+
@pytest.mark.smoke
130131
def test_get_lke_pool(test_linode_client, lke_cluster):
131132
cluster = lke_cluster
132133

test/integration/models/nodebalancer/test_nodebalancer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def test_create_nb_node(
7878
assert "node_test" == node.label
7979

8080

81+
@pytest.mark.smoke
8182
def test_get_nb_node(test_linode_client, create_nb_config):
8283
node = test_linode_client.load(
8384
NodeBalancerNode,

test/integration/models/object_storage/test_obj.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def test_bucket(
9393
assert any(b.label == bucket.label for b in buckets)
9494

9595

96+
@pytest.mark.smoke
9697
def test_list_obj_storage_bucket(
9798
test_linode_client: LinodeClient,
9899
bucket: ObjectStorageBucket,

test/integration/models/placement/test_placement.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import pytest
2+
13
from linode_api4 import PlacementGroup
24

35

6+
@pytest.mark.smoke
47
def test_get_pg(test_linode_client, create_placement_group):
58
"""
69
Tests that a Placement Group can be loaded.
@@ -9,6 +12,7 @@ def test_get_pg(test_linode_client, create_placement_group):
912
assert pg.id == create_placement_group.id
1013

1114

15+
@pytest.mark.smoke
1216
def test_update_pg(test_linode_client, create_placement_group):
1317
"""
1418
Tests that a Placement Group can be updated successfully.

test/integration/models/profile/test_profile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from linode_api4.objects import PersonalAccessToken, Profile, SSHKey
44

55

6+
@pytest.mark.smoke
67
def test_user_profile(test_linode_client):
78
client = test_linode_client
89

@@ -20,6 +21,7 @@ def test_get_personal_access_token_objects(test_linode_client):
2021
assert isinstance(personal_access_tokens[0], PersonalAccessToken)
2122

2223

24+
@pytest.mark.smoke
2325
@pytest.mark.flaky(reruns=3, reruns_delay=2)
2426
def test_get_sshkeys(test_linode_client, test_sshkey):
2527
client = test_linode_client

test/integration/models/vpc/test_vpc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
from linode_api4 import VPC, ApiError, VPCSubnet
66

77

8+
@pytest.mark.smoke
89
def test_get_vpc(test_linode_client, create_vpc):
910
vpc = test_linode_client.load(VPC, create_vpc.id)
1011
test_linode_client.vpcs()
1112
assert vpc.id == create_vpc.id
1213

1314

15+
@pytest.mark.smoke
1416
def test_update_vpc(test_linode_client, create_vpc):
1517
vpc = create_vpc
1618
new_label = create_vpc.label + "-updated"
@@ -33,6 +35,7 @@ def test_get_subnet(test_linode_client, create_vpc_with_subnet):
3335
assert loaded_subnet.id == subnet.id
3436

3537

38+
@pytest.mark.smoke
3639
def test_update_subnet(test_linode_client, create_vpc_with_subnet):
3740
vpc, subnet = create_vpc_with_subnet
3841
new_label = subnet.label + "-updated"

0 commit comments

Comments
 (0)