11
11
description : ' The hash value of the commit'
12
12
required : false
13
13
default : ' '
14
+ python-version :
15
+ description : ' Specify Python version to use'
16
+ required : false
17
+ run-eol-python-version :
18
+ description : ' Run EOL python version?'
19
+ required : false
20
+ default : ' false'
21
+ type : choice
22
+ options :
23
+ - ' true'
24
+ - ' false'
14
25
push :
15
26
branches :
16
27
- main
17
28
- dev
18
29
30
+ env :
31
+ DEFAULT_PYTHON_VERSION : " 3.9"
32
+ EOL_PYTHON_VERSION : " 3.8"
33
+ EXIT_STATUS : 0
34
+
19
35
jobs :
20
36
integration-tests :
21
37
runs-on : ubuntu-latest
22
- env :
23
- EXIT_STATUS : 0
24
38
steps :
25
39
- name : Clone Repository with SHA
26
40
if : ${{ inputs.sha != '' }}
40
54
- name : Setup Python
41
55
uses : actions/setup-python@v5
42
56
with :
43
- python-version : ' 3.x '
57
+ python-version : ${{ inputs.run-eol-python-version == 'true' && env.EOL_PYTHON_VERSION || inputs.python-version || env.DEFAULT_PYTHON_VERSION }}
44
58
45
59
- name : Install Python deps
46
60
run : pip install -U setuptools wheel boto3 certifi
50
64
env :
51
65
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
52
66
53
- - name : Download kubectl and calicoctl for LKE clusters
54
- run : |
55
- curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
56
- curl -LO "https://github.com/projectcalico/calico/releases/download/v3.25.0/calicoctl-linux-amd64"
57
- chmod +x calicoctl-linux-amd64 kubectl
58
- mv calicoctl-linux-amd64 /usr/local/bin/calicoctl
59
- mv kubectl /usr/local/bin/kubectl
60
-
61
67
- name : Set LINODE_TOKEN
62
68
run : |
63
69
echo "LINODE_TOKEN=${{ secrets[inputs.use_minimal_test_account == 'true' && 'MINIMAL_LINODE_TOKEN' || 'LINODE_TOKEN'] }}" >> $GITHUB_ENV
70
76
env :
71
77
LINODE_TOKEN : ${{ env.LINODE_TOKEN }}
72
78
73
- - name : Apply Calico Rules to LKE
74
- if : always()
75
- run : |
76
- cd scripts && ./lke_calico_rules_e2e.sh
77
- env :
78
- LINODE_TOKEN : ${{ env.LINODE_TOKEN }}
79
-
80
79
- name : Upload test results
81
80
if : always()
82
81
run : |
@@ -92,10 +91,75 @@ jobs:
92
91
LINODE_CLI_OBJ_ACCESS_KEY : ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
93
92
LINODE_CLI_OBJ_SECRET_KEY : ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
94
93
94
+ apply-calico-rules :
95
+ runs-on : ubuntu-latest
96
+ needs : [integration-tests]
97
+ if : ${{ success() || failure() }}
98
+
99
+ steps :
100
+ - name : Checkout code
101
+ uses : actions/checkout@v4
102
+ with :
103
+ fetch-depth : 0
104
+ submodules : ' recursive'
105
+
106
+ - name : Set LINODE_TOKEN
107
+ run : |
108
+ echo "LINODE_TOKEN=${{ secrets[inputs.use_minimal_test_account == 'true' && 'MINIMAL_LINODE_TOKEN' || 'LINODE_TOKEN'] }}" >> $GITHUB_ENV
109
+
110
+ - name : Download kubectl and calicoctl for LKE clusters
111
+ run : |
112
+ curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
113
+ curl -LO "https://github.com/projectcalico/calico/releases/download/v3.25.0/calicoctl-linux-amd64"
114
+ chmod +x calicoctl-linux-amd64 kubectl
115
+ mv calicoctl-linux-amd64 /usr/local/bin/calicoctl
116
+ mv kubectl /usr/local/bin/kubectl
117
+
118
+ - name : Apply Calico Rules to LKE
119
+ run : |
120
+ cd e2e_scripts/cloud_security_scripts/lke_calico_rules/ && ./lke_calico_rules_e2e.sh
121
+ env :
122
+ LINODE_TOKEN : ${{ env.LINODE_TOKEN }}
123
+
124
+ add-fw-to-remaining-instances :
125
+ runs-on : ubuntu-latest
126
+ needs : [integration-tests]
127
+ if : ${{ success() || failure() }}
128
+
129
+ steps :
130
+ - name : Set up Python
131
+ uses : actions/setup-python@v5
132
+ with :
133
+ python-version : ' 3.x'
134
+
135
+ - name : Install Linode CLI
136
+ run : |
137
+ pip install linode-cli
138
+
139
+ - name : Set LINODE_TOKEN
140
+ run : |
141
+ echo "LINODE_TOKEN=${{ secrets[inputs.use_minimal_test_account == 'true' && 'MINIMAL_LINODE_TOKEN' || 'LINODE_TOKEN'] }}" >> $GITHUB_ENV
142
+
143
+ - name : Create Firewall and Attach to Instances
144
+ run : |
145
+ FIREWALL_ID=$(linode-cli firewalls create --label "e2e-fw-$(date +%s)" --rules.inbound_policy "DROP" --rules.outbound_policy "ACCEPT" --text --format=id --no-headers)
146
+ echo "Created Firewall with ID: $FIREWALL_ID"
147
+
148
+ for instance_id in $(linode-cli linodes list --format "id" --text --no-header); do
149
+ echo "Attaching firewall to instance: $instance_id"
150
+ if linode-cli firewalls device-create "$FIREWALL_ID" --id "$instance_id" --type linode; then
151
+ echo "Firewall attached to instance $instance_id successfully."
152
+ else
153
+ echo "An error occurred while attaching firewall to instance $instance_id. Skipping..."
154
+ fi
155
+ done
156
+ env :
157
+ LINODE_CLI_TOKEN : ${{ env.LINODE_TOKEN }}
158
+
95
159
notify-slack :
96
160
runs-on : ubuntu-latest
97
161
needs : [integration-tests]
98
- if : always() && github.repository == 'linode/linode_api4-python' # Run even if integration tests fail and only on main repository
162
+ if : ${{ (success() || failure()) && github.repository == 'linode/linode_api4-python' }} # Run even if integration tests fail and only on main repository
99
163
100
164
steps :
101
165
- name : Notify Slack
0 commit comments