diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index b31ae13..3e032e7 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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 diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 100b9ab..194ac2a 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -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 @@ -27,29 +29,31 @@ 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 @@ -57,8 +61,5 @@ jobs: 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 }}" diff --git a/rockcraft.yaml b/rockcraft.yaml index e281880..5bcbc66 100644 --- a/rockcraft.yaml +++ b/rockcraft.yaml @@ -10,7 +10,6 @@ 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 @@ -18,7 +17,6 @@ services: startup: enabled command: "/bin/bash /bin/start.sh" - platforms: # The platforms this rock should be built on and run on amd64: @@ -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] @@ -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} @@ -71,6 +67,7 @@ parts: source: licenses organize: LICENSE-rock: licenses/LICENSE-rock + usr/share/doc/logrotate/copyright: licenses/COPYRIGHT-logrotate entry: plugin: dump diff --git a/tox.ini b/tox.ini index 1ed7ea3..ff8ebfd 100644 --- a/tox.ini +++ b/tox.ini @@ -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] @@ -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] @@ -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