Skip to content

Commit

Permalink
[DPE-2841] Update rockcraft.yaml to use latest rockcraft revision (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
deusebio authored Nov 10, 2023
1 parent dda6df1 commit f80726f
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 19 deletions.
63 changes: 54 additions & 9 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ concurrency:
on:
pull_request:
workflow_call:
outputs:
rock:
description: "The rock output of build process."
value: ${{ jobs.build.outputs.rock }}

jobs:
lint:
Expand All @@ -31,22 +35,63 @@ jobs:
- name: Setup LXD
uses: canonical/setup-lxd@main
- name: Install dependencies
id: install
run: |
sudo snap install yq
sudo snap install rockcraft --classic --edge --revision 687
sudo snap install rockcraft --classic --edge
- name: Build ROCK
id: build
run: |
app_version=$(yq '.version' rockcraft.yaml)
version=$(yq '(.version|split("-"))[0]' rockcraft.yaml)
base=$(yq '(.base|split(":"))[1]' rockcraft.yaml)
risk=edge
tag=${version}-${base}_${risk}
sed -i "s/${app_version}/${tag}/g" rockcraft.yaml
VERSION=$(yq '.version' rockcraft.yaml)
rockcraft pack --verbose
echo "rock=charmed-zookeeper_${VERSION}_amd64.rock" >> $GITHUB_OUTPUT
- name: Upload locally built ROCK artifact
uses: actions/upload-artifact@v3
with:
name: charmed-zookeeper
path: "charmed-zookeeper_*.rock"
path: ${{ steps.build.outputs.rock }}
outputs:
rock: ${{ steps.build.outputs.rock }}

test:
name: Test Image
runs-on: ubuntu-latest
timeout-minutes: 60
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Docker
run: |
sudo snap install docker
sudo addgroup --system docker; sudo adduser $USER docker
newgrp docker
sudo snap disable docker; sudo snap enable docker
- name: Install skopeo
run: |
sudo snap install --devmode --channel edge skopeo
- uses: actions/download-artifact@v3
with:
name: charmed-zookeeper
- name: Test Image
run: |
sudo skopeo --insecure-policy copy \
oci-archive:${{ needs.build.outputs.rock }} \
docker-daemon:charmed-zookeeper:latest
docker run -d -p 2181:2181 charmed-zookeeper:latest
sleep 10
CHECK=$(echo srvr | nc localhost 2181 | grep "Mode" | wc -l)
if [[ $CHECK != 1 ]];
then
echo "Zookeeper service possibly not running"
exit 1;
else
echo "Zookeeper service up and running!"
fi
9 changes: 5 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,21 @@ jobs:
password: ${{ secrets.GHCR_TOKEN }}
- name: Import and push to GHCR
run: |
app_version=$(yq '.version' rockcraft.yaml)
version=$(yq '(.version|split("-"))[0]' rockcraft.yaml)
base=$(yq '(.base|split(":"))[1]' rockcraft.yaml)
risk=edge
tag=${version}-${base}_${risk}
channel=$(echo ${{ github.ref_name }} | cut -d "-" -f 1)
ROCK_FILE=${{ needs.build.outputs.rock }}
sudo skopeo --insecure-policy copy \
oci-archive:charmed-zookeeper_${tag}_amd64.rock \
oci-archive:$ROCK_FILE \
docker-daemon:ghcr.io/canonical/charmed-zookeeper:${tag}
docker tag \
ghcr.io/canonical/charmed-zookeeper:${tag} \
ghcr.io/canonical/charmed-zookeeper:${channel}-${risk}
ghcr.io/canonical/charmed-zookeeper:${channel}_${risk}
docker push ghcr.io/canonical/charmed-zookeeper:${tag}
docker push ghcr.io/canonical/charmed-zookeeper:${channel}-${risk}
docker push ghcr.io/canonical/charmed-zookeeper:${channel}_${risk}
24 changes: 18 additions & 6 deletions rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,20 @@ license: Apache-2.0 # your application's SPDX license
platforms: # The platforms this ROCK should be built on and run on
amd64:

env:
- JAVA_HOME: /usr/lib/jvm/java-17-openjdk-amd64
- ZOO_LOG_DIR: /var/log/zookeeper
- ZOO_LOG4J_PROP: INFO,CONSOLE,ROLLINGFILE
- ZOO_LOG_FILE: zookeeper.log
- ZOOCFGDIR: /etc/zookeeper
environment:
JAVA_HOME: /usr/lib/jvm/java-17-openjdk-amd64
ZOO_LOG_DIR: /var/log/zookeeper
ZOO_LOG4J_PROP: INFO,CONSOLE,ROLLINGFILE
ZOO_LOG_FILE: zookeeper.log
ZOOCFGDIR: /etc/zookeeper

services:
zookeeper:
override: replace
command: /bin/zkServer.sh --config /etc/zookeeper start-foreground
startup: enabled
user: zookeeper
group: zookeeper

parts:
zookeeper:
Expand All @@ -46,6 +54,10 @@ parts:
mkdir -p $CRAFT_PART_INSTALL/var/log/zookeeper/
mkdir -p $CRAFT_PART_INSTALL/opt/zookeeper/
mkdir -p $CRAFT_PART_INSTALL/etc/zookeeper/
cp $CRAFT_PART_INSTALL/conf/zoo_sample.cfg \
$CRAFT_PART_INSTALL/etc/zookeeper/zoo.cfg
rm -rf $CRAFT_PART_INSTALL/conf
override-prime: |
craftctl default
rm -vf usr/lib/jvm/java-17-openjdk-amd64/lib/security/cacerts
Expand Down

0 comments on commit f80726f

Please sign in to comment.