Skip to content

Commit

Permalink
ci(charm): update workflows for vm charm
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-hagemann committed Oct 3, 2023
1 parent 8ebe2c4 commit bcf85e3
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 131 deletions.
31 changes: 2 additions & 29 deletions .github/workflows/build-charm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
22 changes: 0 additions & 22 deletions .github/workflows/build-rock.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/pull-request-charm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Pull Request (Charm)
on:
pull_request:
paths:
- k8s_operator/**
- vm_operator/**

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Pull Request
on:
pull_request:
paths-ignore:
- k8s_operator/**
- vm_operator/**

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -12,6 +12,3 @@ concurrency:
jobs:
build:
uses: ./.github/workflows/build.yaml

build-rock:
uses: ./.github/workflows/build-rock.yaml
2 changes: 1 addition & 1 deletion .github/workflows/push-charm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
paths:
- k8s_operator/**
- vm_operator/**

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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-<commit>
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 }}"
1 change: 1 addition & 0 deletions vm_operator/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ops == 2.6.0
psycopg[binary] >= 3.1.10
GitPython==3.1.14
jinja2
2 changes: 1 addition & 1 deletion vm_operator/tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 0 additions & 40 deletions vm_operator/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit bcf85e3

Please sign in to comment.