1+ name : Testing
2+
3+ on : [push, pull_request]
4+
5+ jobs :
6+ lint :
7+ name : Linter
8+ runs-on : ubuntu-latest
9+ strategy :
10+ matrix :
11+ python :
12+ - " 3.8"
13+ - " 3.9"
14+ - " 3.10"
15+ steps :
16+ - name : Check out code
17+ uses : actions/checkout@v3
18+ - name : Setup Python
19+ uses : actions/setup-python@v4
20+ with :
21+ python-version : ${{ matrix.python }}
22+ - name : Install dependencies
23+ run : pip install tox
24+ - name : Run linter
25+ run : tox -e lint
26+
27+ unit-tests :
28+ needs : lint
29+ name : Unit tests
30+ runs-on : ubuntu-latest
31+ strategy :
32+ matrix :
33+ python :
34+ - " 3.8"
35+ - " 3.9"
36+ - " 3.10"
37+ steps :
38+ - name : Check out code
39+ uses : actions/checkout@v3
40+ - name : Setup Python
41+ uses : actions/setup-python@v4
42+ with :
43+ python-version : ${{ matrix.python }}
44+ - name : Install dependencies
45+ run : pip install tox
46+ - name : Run unit tests
47+ run : tox -e py3
48+
49+ integration :
50+ name : Integration
51+ needs : [lint, unit-tests]
52+ timeout-minutes : 120
53+ runs-on : ubuntu-latest
54+ strategy :
55+ matrix :
56+ python :
57+ - " 3.8"
58+ - " 3.9"
59+ - " 3.10"
60+ steps :
61+ - name : Check out code
62+ uses : actions/checkout@v3
63+ - name : Setup operator environment
64+ uses : charmed-kubernetes/actions-operator@main
65+ with :
66+ provider : lxd
67+ juju-channel : 2.9/stable
68+ - name : Set proxy in controller
69+ run : |
70+ set -euxo pipefail
71+ # build a squid config file
72+ CONTROLLER_IP=$(juju list-controllers --format yaml | yq '.controllers[.current-controller].recent-server' | awk -F '[:]' '{print $1}');
73+ echo "Controller IP is: $CONTROLLER_IP"
74+ PROXY=$CONTROLLER_IP:3128
75+ echo "Proxy address is: $PROXY"
76+ echo "acl all src all" > squid.conf
77+ echo "http_access allow all" >> squid.conf
78+ echo "http_port $PROXY" >> squid.conf
79+ cat squid.conf
80+ # copy to the controller and reconfigure it
81+ juju status -m controller
82+ juju switch controller
83+ juju ssh 0 "sudo apt-get install squid -y"
84+ juju scp squid.conf 0:/tmp/squid.conf
85+ juju ssh 0 "sudo mv /tmp/squid.conf /etc/squid/squid.conf"
86+ juju ssh 0 "sudo squid -k reconfigure"
87+ # Test curl after waiting
88+ sleep 10
89+ echo "Test proxy access"
90+ curl -s -o /dev/null -w "%{http_code}" --proxy http://$PROXY https://charmhub.io
91+ # set model defaults
92+ juju model-defaults apt-http-proxy=$PROXY apt-https-proxy=$PROXY juju-http-proxy=$PROXY juju-https-proxy=$PROXY snap-http-proxy=$PROXY snap-https-proxy=$PROXY
93+ juju model-defaults
94+ - name : Setup Python
95+ uses : actions/setup-python@v4
96+ with :
97+ python-version : ${{ matrix.python }}
98+ - name : Install dependencies
99+ run : pip install tox
100+ - name : Run integration
101+ # Force one single concurrent test
102+ run : tox -e integration -- -n 1
0 commit comments