diff --git a/.github/workflows/build-charm.yaml b/.github/workflows/build-charm.yaml index 6a25eae..ce1fdeb 100644 --- a/.github/workflows/build-charm.yaml +++ b/.github/workflows/build-charm.yaml @@ -14,7 +14,7 @@ jobs: run: python3 -m pip install tox - name: Run linters run: | - cd k8s_operator + cd vm_operator tox -e lint unit-test: @@ -27,32 +27,5 @@ jobs: run: python -m pip install tox - name: Run tests run: | - cd k8s_operator + cd vm_operator tox -e unit - - integration-test: - name: Integration tests (microk8s) - runs-on: ubuntu-22.04 - needs: - - lint - - unit-test - steps: - - name: Checkout - uses: actions/checkout@v4 - # Do some preemptive setup for the ingress integration test so that our - # bogus dns name resolves properly. - - name: Setup hosts for tests - run: | - echo "10.64.140.43 testing-ratings.foo.bar" | sudo tee -a /etc/hosts - - name: Setup operator environment - uses: charmed-kubernetes/actions-operator@main - with: - provider: microk8s - channel: 1.27-strict/stable - juju-channel: 3.2/stable - microk8s-group: snap_microk8s - microk8s-addons: "hostpath-storage dns metallb:10.64.140.43-10.64.140.43" - - name: Run integration tests - run: | - cd k8s_operator - tox -e integration -- --model=testing diff --git a/.github/workflows/build-rock.yaml b/.github/workflows/build-rock.yaml deleted file mode 100644 index a7f2e78..0000000 --- a/.github/workflows/build-rock.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: Build ROCK - -on: - workflow_call: - -jobs: - build: - name: Build ROCK - runs-on: ubuntu-22.04 - steps: - - name: Checkout source - uses: actions/checkout@v4 - - - id: rockcraft - name: Build ROCK - uses: canonical/craft-actions/rockcraft-pack@main - - - name: Upload ROCK artifact - uses: actions/upload-artifact@v3 - with: - name: ratings-rock - path: ${{ steps.rockcraft.outputs.rock }} diff --git a/.github/workflows/pull-request-charm.yaml b/.github/workflows/pull-request-charm.yaml index 2d50c43..d632ab5 100644 --- a/.github/workflows/pull-request-charm.yaml +++ b/.github/workflows/pull-request-charm.yaml @@ -3,7 +3,7 @@ name: Pull Request (Charm) on: pull_request: paths: - - k8s_operator/** + - vm_operator/** concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index 8eb819c..2e47e48 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -3,7 +3,7 @@ name: Pull Request on: pull_request: paths-ignore: - - k8s_operator/** + - vm_operator/** concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -12,6 +12,3 @@ concurrency: jobs: build: uses: ./.github/workflows/build.yaml - - build-rock: - uses: ./.github/workflows/build-rock.yaml diff --git a/.github/workflows/push-charm.yaml b/.github/workflows/push-charm.yaml index 2de4950..4acb5d6 100644 --- a/.github/workflows/push-charm.yaml +++ b/.github/workflows/push-charm.yaml @@ -5,7 +5,7 @@ on: branches: - main paths: - - k8s_operator/** + - vm_operator/** concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 3fb097b..068e26b 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -12,36 +12,3 @@ concurrency: jobs: build: uses: ./.github/workflows/build.yaml - - build-rock: - uses: ./.github/workflows/build-rock.yaml - - publish-rock: - name: Publish ROCK to GHCR - runs-on: ubuntu-latest - needs: - - build-rock - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Fetch ROCK artifact - uses: actions/download-artifact@v3 - with: - name: ratings-rock - - - name: Upload ROCK to ghcr.io - run: | - commit="$(git rev-parse --short HEAD)" - - # Upload ROCK to ghcr.io/tim-hm/ratings:main- - sudo skopeo --insecure-policy copy \ - "oci-archive:$(realpath ./ratings_*.rock)" \ - "docker://ghcr.io/tim-hm/ratings:main-${commit}" \ - --dest-creds "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" - - # Upload ROCK to ghcr.io/tim-hm/ratings:latest - sudo skopeo --insecure-policy copy \ - "oci-archive:$(realpath ./ratings_*.rock)" \ - "docker://ghcr.io/tim-hm/ratings:latest" \ - --dest-creds "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" diff --git a/vm_operator/requirements.txt b/vm_operator/requirements.txt index d289e4e..b39bdd4 100644 --- a/vm_operator/requirements.txt +++ b/vm_operator/requirements.txt @@ -1,3 +1,4 @@ ops == 2.6.0 psycopg[binary] >= 3.1.10 GitPython==3.1.14 +jinja2 diff --git a/vm_operator/tests/unit/test_charm.py b/vm_operator/tests/unit/test_charm.py index 8ae4404..942b908 100644 --- a/vm_operator/tests/unit/test_charm.py +++ b/vm_operator/tests/unit/test_charm.py @@ -78,7 +78,7 @@ def test_on_start(self, _resume): def test_render_systemd_unit(self, _chmod, _reload): # Create a mock for the `open` method, set the return value of `read` to # the contents of the systemd unit template - with open("../../templates/ratings-service.j2", "r") as f: + with open("templates/ratings-service.j2", "r") as f: m = mock_open(read_data=f.read()) # Patch the `open` method with our mock diff --git a/vm_operator/tox.ini b/vm_operator/tox.ini index 8ad173f..8f40f5c 100644 --- a/vm_operator/tox.ini +++ b/vm_operator/tox.ini @@ -63,43 +63,3 @@ commands = {posargs} \ {[vars]tests_path}/unit coverage report - -[testenv:integration] -description = Run integration tests -deps = - pytest - juju - pytest-operator - grpcio - -r {tox_root}/requirements.txt -commands = - pytest -v \ - -s \ - --tb native \ - --log-cli-level=INFO \ - {posargs} \ - {[vars]tests_path}/integration - -[testenv:grpc] -description = Regenerate gRPC stubs -deps = - grpcio - grpcio-tools -commands = - python3 -m grpc_tools.protoc \ - --proto_path={tox_root}/../proto \ - --python_out={tox_root}/lib/ratings_api \ - --grpc_python_out={tox_root}/lib/ratings_api \ - {tox_root}/../proto/ratings_features_app.proto - - python3 -m grpc_tools.protoc \ - --proto_path={tox_root}/../proto \ - --python_out={tox_root}/lib/ratings_api \ - --grpc_python_out={tox_root}/lib/ratings_api \ - {tox_root}/../proto/ratings_features_chart.proto - - python3 -m grpc_tools.protoc \ - --proto_path={tox_root}/../proto \ - --python_out={tox_root}/lib/ratings_api \ - --grpc_python_out={tox_root}/lib/ratings_api \ - {tox_root}/../proto/ratings_features_user.proto