Skip to content

Commit

Permalink
[DPE-4867] - Release new rock and fix broken CI (#35)
Browse files Browse the repository at this point in the history
* fix broken int tests

* use newest rockcraft to build rock

* use data platfrom workflow for build

* fix mongno-snap part

* fix int tests

* run tests as separate jobs

* add log rotate to rock

* fix issues in HA test set up

* revert changes to integration ci for cloud set up

* skip network test
  • Loading branch information
MiaAltieri authored Jul 19, 2024
1 parent 34cad82 commit 120ca52
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 48 deletions.
24 changes: 3 additions & 21 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
name: Build rock
name: Build Charmed MongoDB rock

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup LXD
uses: canonical/setup-lxd@main
- name: Install dependencies
run: |
sudo snap install yq
sudo snap install rockcraft --classic --channel=latest/stable --revision 1206
sudo snap install charmcraft --classic --revision 1349
- name: Build rock
run: |
rockcraft pack
- name: Upload locally built rock artifact
uses: actions/upload-artifact@v3
with:
name: mongodb-rock
path: charmed-mongodb_*_amd64.rock
name: Build rock
uses: canonical/data-platform-workflows/.github/workflows/build_rock.yaml@v16
37 changes: 19 additions & 18 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ on:

jobs:
build:
uses: ./.github/workflows/build.yaml
name: Build rock
uses: canonical/data-platform-workflows/.github/workflows/build_rock.yaml@v16

integration:
runs-on: ubuntu-latest
timeout-minutes: 120
needs: build
strategy:
matrix:
env: []
env: [integration, ha-integration, tls-integration]
fail-fast: false
steps:
- name: Checkout repository
Expand All @@ -27,38 +29,37 @@ jobs:
uses: charmed-kubernetes/actions-operator@main
with:
provider: microk8s
channel: "1.27-strict/stable"
channel: "1.29-strict/stable"
bootstrap-constraints: "cores=2 mem=2G"
juju-channel: 3.1/stable
# This is needed until
# https://bugs.launchpad.net/juju/+bug/1977582 is fixed
bootstrap-options: "--agent-version 3.1.6"
- name: Pin charmcraft version
run: |
sudo snap refresh charmcraft --classic --revision 1349
sudo snap refresh charmcraft --hold=forever
bootstrap-options: "--agent-version 3.1.7"
- name: Install rockcraft
run: |
sudo snap install rockcraft --classic --revision 1206
sudo snap refresh rockcraft --hold=forever
- uses: actions/download-artifact@v3
- name: Download rock package(s)
uses: actions/download-artifact@v4
with:
name: mongodb-rock
- name: Install tox
run: python3 -m pip install tox

pattern: ${{ needs.build.outputs.artifact-prefix }}-*
merge-multiple: true
- name: Install tox & poetry
run: |
pipx install tox
pipx install poetry
- name: Integration Tests
run: |
sg snap_microk8s -c "tox -e ${{ matrix.env }}"
- name: Free disk space
run: |
echo "Free disk space before cleanup"
echo "Free disk space after int tests"
df -T
# free space in the runner
rockcraft clean
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
echo "Free disk space after cleanup"
echo "Free disk after int tests"
df -T
- name: Integration Tests
run: sg snap_microk8s -c "tox -e ${{ matrix.env }}"
9 changes: 3 additions & 6 deletions rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ description: |
as a NoSQL database program, MongoDB uses JSON
-like documents with optional schemas.
license: Apache-2.0 # your application's SPDX license

services:
mongod:
summary: Start Mongod
override: replace
startup: enabled
command: "/bin/bash /bin/start.sh"


platforms: # The platforms this rock should be built on and run on
amd64:

Expand All @@ -29,11 +27,9 @@ parts:
- charmed-mongodb/6/edge
overlay-packages:
- ca-certificates
dep-debs:
plugin: nil
stage-packages:
- libssh-4
- libbrotli1
- logrotate
non-root-user:
plugin: nil
after: [mongo-snap]
Expand Down Expand Up @@ -62,7 +58,7 @@ parts:
arr+=('${Source:Version}\n')
dpkg-query -W -f "${arr[*]}" > ${rocks}/dpkg.query
## for snap packages
# for snap packages
cp snap.charmed-mongodb/manifest.yaml ${rocks}
cp snap.charmed-mongodb/snapcraft.yaml ${rocks}
Expand All @@ -71,6 +67,7 @@ parts:
source: licenses
organize:
LICENSE-rock: licenses/LICENSE-rock
usr/share/doc/logrotate/copyright: licenses/COPYRIGHT-logrotate

entry:
plugin: dump
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ commands =
bash -ec 'microk8s ctr image import {env:name}_*-$(yq .base rockcraft.yaml | \
cut -c 8-)_edge_amd64.rock --base-name {env:registry_namespace}/{env:name}'
bash -ec 'if ! [ -d operator ]; then git clone --single-branch --branch {env:branch} {env:repo} operator; fi' {posargs}
tox --workdir operator -c operator -e integration -- --keep-models
tox --workdir operator -c operator -e integration -- tests/integration/test_charm.py


[testenv:ha-integration]
Expand All @@ -45,7 +45,7 @@ commands =
bash -ec 'microk8s ctr image import {env:name}_*-$(yq .base rockcraft.yaml | \
cut -c 8-)_edge_amd64.rock --base-name {env:registry_namespace}/{env:name}'
bash -ec 'if ! [ -d operator ]; then git clone --single-branch --branch {env:branch} {env:repo} operator; fi' {posargs}
tox --workdir operator -c operator -e ha-integration -- --keep-models
tox --workdir operator -c operator -e integration -- tests/integration/ha_tests/test_ha.py --deselect tests/integration/ha_tests/test_ha.py::test_network_cut


[testenv:tls-integration]
Expand All @@ -60,4 +60,4 @@ commands =
bash -ec 'microk8s ctr image import {env:name}_*-$(yq .base rockcraft.yaml | \
cut -c 8-)_edge_amd64.rock --base-name {env:registry_namespace}/{env:name}'
bash -ec 'if ! [ -d operator ]; then git clone --single-branch --branch {env:branch} {env:repo} operator; fi' {posargs}
tox --workdir operator -c operator -e tls-integration
tox --workdir operator -c operator -e integration -- tests/integration/tls_tests/test_tls.py

0 comments on commit 120ca52

Please sign in to comment.