-
Notifications
You must be signed in to change notification settings - Fork 14
160 lines (134 loc) · 4.07 KB
/
ci.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
name: "CI"
on:
push:
pull_request:
workflow_dispatch:
jobs:
unit-tests:
name: Unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
- name: Install dependencies for testing
run: |
pip install -r requirements-dev.txt
- name: Run tests
run: |
./run_tests
build:
name: Build charms
needs: unit-tests
uses: canonical/data-platform-workflows/.github/workflows/build_charms_with_cache.yaml@v4
with:
artifact-name: charm-packed
bootstrap:
name: "Bootstrap"
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
cloud: ["lxd", "microk8s"]
env:
LOCAL_CHARM_PATH: ${{ github.workspace }}/controller.charm
CHARMHUB_NAME: juju-qa-controller
CHARMHUB_CHANNEL: latest/edge/${{ github.run_id }}
steps:
- name: Download packed charm
id: download
uses: actions/download-artifact@v3
with:
name: ${{ needs.build.outputs.artifact-name }}
- name: Rename charm file
run: |
mv ${{ steps.download.outputs.download-path }}/*.charm \
$LOCAL_CHARM_PATH
# Currently the only way to get charms on k8s is via Charmhub.
- name: Upload charm to Charmhub
id: charmcraft
if: matrix.cloud == 'microk8s'
env:
CHARMCRAFT_AUTH: ${{ secrets.CHARMCRAFT_AUTH }}
run: |
sudo snap install charmcraft --classic
charmcraft upload $LOCAL_CHARM_PATH \
--name $CHARMHUB_NAME --release $CHARMHUB_CHANNEL
- name: Save charmcraft logs as artifact
if: always() && steps.charmcraft.outcome != 'skipped'
uses: actions/upload-artifact@v3
with:
name: charmcraft-upload-logs
path: ~/.local/state/charmcraft/log/
continue-on-error: true
- name: Set up LXD
if: matrix.cloud == 'lxd'
uses: canonical/setup-lxd@90d76101915da56a42a562ba766b1a77019242fd
- name: Set up MicroK8s
if: matrix.cloud == 'microk8s'
uses: balchua/[email protected]
with:
channel: "1.25-strict/stable"
addons: '["dns", "hostpath-storage"]'
- name: Install Juju
run: |
sudo snap install juju --channel 3.3/beta
- name: Bootstrap on LXD
if: matrix.cloud == 'lxd'
run: |
juju bootstrap lxd c \
--controller-charm-path=$LOCAL_CHARM_PATH
- name: Bootstrap on MicroK8s
if: matrix.cloud == 'microk8s'
run: |
sg snap_microk8s <<EOF
juju bootstrap microk8s c \
--controller-charm-path=$CHARMHUB_NAME \
--controller-charm-channel=$CHARMHUB_CHANNEL
EOF
- name: Check charm status
run: |
juju switch controller
juju wait-for application controller --timeout 1m
juju status
# TODO: test integration with dashboard / ha-proxy
release:
name: "Release to edge"
runs-on: ubuntu-latest
needs: [build, bootstrap]
if: github.event_name == 'push'
steps:
- name: Download packed charm
id: download
uses: actions/download-artifact@v3
with:
name: ${{ needs.build.outputs.artifact-name }}
- name: Select Charmhub channel
id: channel
shell: bash
run: |
set -x
case ${{ github.ref_name }} in
3.* | 4.*)
TRACK="${{ github.ref_name }}"
;;
master)
TRACK="latest"
;;
esac
echo "track=$TRACK" >> "$GITHUB_OUTPUT"
if [[ -z $TRACK ]]; then
echo "upload=false" >> "$GITHUB_OUTPUT"
else
echo "upload=true" >> "$GITHUB_OUTPUT"
fi
- name: Upload to Charmhub
if: steps.channel.outputs.upload == 'true'
env:
CHARMCRAFT_AUTH: ${{ secrets.CHARMCRAFT_AUTH }}
run: |
sudo snap install charmcraft --classic
charmcraft upload ${{ steps.download.outputs.download-path }}/*.charm \
--release ${{ steps.channel.outputs.track }}/edge