1111 description : ' The hash value of the commit'
1212 required : false
1313 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'
1425 push :
1526 branches :
1627 - main
1728 - dev
1829
30+ env :
31+ DEFAULT_PYTHON_VERSION : " 3.9"
32+ EOL_PYTHON_VERSION : " 3.8"
33+ EXIT_STATUS : 0
34+
1935jobs :
2036 integration-tests :
2137 runs-on : ubuntu-latest
22- env :
23- EXIT_STATUS : 0
2438 steps :
2539 - name : Clone Repository with SHA
2640 if : ${{ inputs.sha != '' }}
4054 - name : Setup Python
4155 uses : actions/setup-python@v5
4256 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 }}
4458
4559 - name : Install Python deps
4660 run : pip install -U setuptools wheel boto3 certifi
5064 env :
5165 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5266
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-
6167 - name : Set LINODE_TOKEN
6268 run : |
6369 echo "LINODE_TOKEN=${{ secrets[inputs.use_minimal_test_account == 'true' && 'MINIMAL_LINODE_TOKEN' || 'LINODE_TOKEN'] }}" >> $GITHUB_ENV
7076 env :
7177 LINODE_TOKEN : ${{ env.LINODE_TOKEN }}
7278
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-
8079 - name : Upload test results
8180 if : always()
8281 run : |
@@ -92,10 +91,75 @@ jobs:
9291 LINODE_CLI_OBJ_ACCESS_KEY : ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
9392 LINODE_CLI_OBJ_SECRET_KEY : ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
9493
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+
95159 notify-slack :
96160 runs-on : ubuntu-latest
97161 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
99163
100164 steps :
101165 - name : Notify Slack
0 commit comments