-
Notifications
You must be signed in to change notification settings - Fork 5
89 lines (76 loc) · 3.31 KB
/
ci.yaml
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
name: Build and Test
on:
workflow_dispatch:
pull_request:
jobs:
build:
name: Build Snap
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout repository
uses: actions/checkout@v3
- id: dependencies
name: Upgrade linux deps
run: |
sudo apt update
# https://askubuntu.com/questions/1276111/error-upgrading-grub-efi-amd64-signed-special-device-old-ssd-does-not-exist
sudo apt-mark hold grub-efi-amd64-signed grub-efi-amd64-bin
sudo DEBIAN_FRONTEND=noninteractive apt upgrade --yes
- id: get-version
name: Retrieve workload version
run: |
VERSION=$(yq '(.version|split("-"))[0]' snap/snapcraft.yaml)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- id: snapcraft
name: Build snap
uses: snapcore/action-build@v1
- id: upload
name: Upload built snap job artifact
uses: actions/upload-artifact@v3
with:
name: charmed-kafka_snap_amd64
path: charmed-kafka_${{ steps.get-version.outputs.version }}_amd64.snap
outputs:
snap-file: ${{ steps.snapcraft.outputs.snap }}
version: ${{ steps.get-version.outputs.version }}
test:
name: Test Snap
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download snap file
uses: actions/download-artifact@v3
with:
name: charmed-kafka_snap_amd64
path: .
- name: Install snap file
run: |
sudo snap install charmed-kafka_${{ needs.build.outputs.version }}_amd64.snap --dangerous
sudo snap install charmed-zookeeper --channel=3/edge
- name: Set default config
run: |
sudo cp /snap/charmed-kafka/current/opt/kafka/config/server.properties /var/snap/charmed-kafka/current/etc/kafka
sudo cp /snap/charmed-zookeeper/current/opt/zookeeper/conf/zoo_sample.cfg /var/snap/charmed-zookeeper/current/etc/zookeeper/zoo.cfg
sudo cp /snap/charmed-kafka/current/opt/cruise-control/config/cruisecontrol.properties /var/snap/charmed-kafka/current/etc/cruise-control
sudo sed -i -e 's/sample.store.topic.replication.factor=2/sample.store.topic.replication.factor=1/g' /var/snap/charmed-kafka/current/etc/cruise-control/cruisecontrol.properties
sudo sed -i -e 's|capacity.config.file=config/capacityJBOD.json|capacity.config.file=/var/snap/charmed-kafka/current/etc/cruise-control/capacityJBOD.json|g' /var/snap/charmed-kafka/current/etc/cruise-control/cruisecontrol.properties
sudo cp /snap/charmed-kafka/current/opt/cruise-control/config/capacityJBOD.json /var/snap/charmed-kafka/current/etc/cruise-control
- name: Start snap services
run: |
sudo snap start charmed-zookeeper.daemon
sleep 5
sudo snap start charmed-kafka.daemon
sleep 5
- name: Check topic creation
run: |
topic_creation=$(charmed-kafka.topics --create --topic test --bootstrap-server localhost:9092)
if [ "$topic_creation" != "Created topic test." ]; then
exit 1
fi
- name: Check CruiseControl state
run: |
sudo snap start charmed-kafka.cruise-control
sleep 20
curl -s http://localhost:9090/kafkacruisecontrol/state | grep "state: RUNNING"