-
Notifications
You must be signed in to change notification settings - Fork 65
161 lines (155 loc) · 4.82 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Test Suite
on:
pull_request:
branches: [ master ]
jobs:
unit:
name: Unit tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- '3.8' # focal
- '3.10' # jammy
- '3.12' # noble
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Tox
run: pip install tox
- name: Run tests
run: tox -e py
build:
name: Build snap
needs: unit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Add fake tag to make vergit happy
run: git tag v0.0.0
- uses: snapcore/action-build@v1
id: snap-build
- uses: actions/upload-artifact@v1
with:
name: charm-snap
path: ${{ steps.snap-build.outputs.snap }}
integration:
strategy:
matrix:
charmcraft_channel:
- "2.x/stable"
- "3.x/beta"
name: Integration test
needs: build
runs-on: ubuntu-latest
steps:
- name: Init LXD
run: |
set -euxo pipefail
sudo lxd init --auto
# This is a throw-away CI environment, do not do this at home
sudo chmod 666 /var/snap/lxd/common/lxd/unix.socket
# Fixup iptables forwarding issues from LXD containers with a flush and
# re-create of rules.
sudo iptables -F FORWARD
sudo iptables -P FORWARD ACCEPT
- name: Checkout layer-basic
uses: actions/checkout@v2
with:
repository: juju-solutions/layer-basic
- name: Download built charm snap
uses: actions/[email protected]
with:
name: charm-snap
path: tests/charm-minimal/charm-snap
- name: Build reactive charm with charmcraft-2.x
if: ${{ matrix.charmcraft_channel == '2.x/stable' }}
run: |
set -euxo pipefail
sudo snap install --classic --channel ${{ matrix.charmcraft_channel }} charmcraft
cat << EOF | tee tests/charm-minimal/charmcraft.yaml
type: charm
parts:
charm-tools:
plugin: nil
override-build: |
ls -lR \$CRAFT_PROJECT_DIR/
snap install --dangerous --classic /root/project/charm-snap/charm_0.0.0_amd64.snap
rm -rf \$CRAFT_PROJECT_DIR/parts/charm/src/charm-snap
charm:
after: [charm-tools]
source: .
plugin: reactive
reactive-charm-build-arguments:
- -v
- --binary-wheels-from-source
- --upgrade-buildvenv-core-deps
build-packages:
- python3-dev
- libpq-dev
bases:
- name: ubuntu
channel: "18.04"
architectures: [amd64]
- name: ubuntu
channel: "20.04"
architectures: [amd64]
- name: ubuntu
channel: "22.04"
architectures: [amd64]
EOF
charmcraft pack -p tests/charm-minimal -v
- name: Build reactive charm with charmcraft-3.x
if: ${{ matrix.charmcraft_channel == '3.x/beta' }}
run: |
set -euxo pipefail
sudo snap install --classic --channel ${{ matrix.charmcraft_channel }} charmcraft
cat << EOF | tee tests/charm-minimal/charmcraft.yaml
type: charm
parts:
charm-tools:
plugin: nil
override-build: |
ls -lR \$CRAFT_PROJECT_DIR/
snap install --dangerous --classic /root/project/charm-snap/charm_0.0.0_amd64.snap
rm -rf \$CRAFT_PROJECT_DIR/parts/charm/src/charm-snap
charm:
after: [charm-tools]
source: .
plugin: reactive
reactive-charm-build-arguments:
- -v
- --binary-wheels-from-source
- --upgrade-buildvenv-core-deps
build-packages:
- python3-dev
- libpq-dev
base: [email protected]
platforms:
amd64:
EOF
charmcraft pack -p tests/charm-minimal -v
mv minimal_amd64.charm minimal_ubuntu-24.04-amd64.charm
## action to interactively debug CI failures.
# - name: Setup upterm session
# if: failure()
# uses: lhotari/action-upterm@v1
- name: Upload charmcraft execution logs
if: always()
uses: actions/upload-artifact@v3
with:
name: charmcraft execution logs
path: ~/snap/charmcraft/common/cache/charmcraft/log/*.log
- name: Upload built charms
uses: actions/upload-artifact@v3
with:
name: Built charms
path: |
minimal_ubuntu-18.04-amd64.charm
minimal_ubuntu-20.04-amd64.charm
minimal_ubuntu-22.04-amd64.charm
minimal_ubuntu-24.04-amd64.charm