Skip to content

Commit

Permalink
Merge branch 'main' into test-tweaked-workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
kian99 committed Jul 4, 2023
2 parents 3b63da4 + 1700cee commit b11c682
Show file tree
Hide file tree
Showing 54 changed files with 13,843 additions and 667 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/charm-release.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Release to latest/edge
name: Release to v1/edge

on:
workflow_dispatch:
push:
tags:
- 'v*'
- 'v1*'

# Note this workflow requires a Github secret to provide auth against charmhub.
# This can be generated with the following command
Expand Down Expand Up @@ -35,9 +35,10 @@ jobs:
with:
credentials: "${{ secrets.CHARMHUB_TOKEN }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"
channel: "v1/edge"
channel: "1/edge"
charm-path: "./charms/jimm-k8s"
local-image: "true"
tag-prefix: "v1-k8s"

release-machine-charm:
name: Release machine charm
Expand All @@ -54,15 +55,16 @@ jobs:
with:
name: jimm-snap
- name: Install charmcraft
run: sudo snap install charmcraft --channel=2.x/stable
run: sudo snap install charmcraft --channel=2.x/stable --classic
- name: Publish Charm Resource
run: charmcraft upload-resource juju-jimm jimm-snap --filepath ./jimm-snap
run: charmcraft upload-resource juju-jimm jimm-snap --filepath ./jimm.snap
env:
CHARMCRAFT_AUTH: "${{ secrets.CHARMHUB_TOKEN }}"
- name: Upload charm to charmhub
uses: canonical/charming-actions/[email protected]
with:
credentials: "${{ secrets.CHARMHUB_TOKEN }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"
channel: "v1/edge"
channel: "1/edge"
charm-path: "./charms/jimm"
tag-prefix: "v1-machine"
4 changes: 0 additions & 4 deletions .github/workflows/charm-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
uses: ./.github/workflows/charm-build.yaml

lint:
# Delete this if statement once charms are updated and include tox.
if: ${{ 1 }} == ${{ 2 }}
name: Lint
runs-on: ubuntu-latest
strategy:
Expand All @@ -29,8 +27,6 @@ jobs:
- name: Run linters
run: tox -e lint
unit-tests:
# Delete this if statement once charms are updated and include tox.
if: ${{ 1 }} == ${{ 2 }}
name: Unit tests
runs-on: ubuntu-latest
strategy:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: CI
on:
pull_request:
paths-ignore:
- '.github/**' # Skip this workflow if the only change was inside the .github folder
workflow_call:
workflow_dispatch:


jobs:
# lint:
# runs-on: ubuntu-20.04
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/ci_skip.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: CI
on:
pull_request:
paths:
- '.github/**' # Run this workflow when the only files changed were any in .github
workflow_call:
workflow_dispatch:

jobs:
build_test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- run: 'echo "No build required"'
2 changes: 1 addition & 1 deletion .github/workflows/snap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- run: sudo snap install snapcraft --channel=7.x/stable --classic
- run: mkdir -p snap
- run: cp ./snaps/jimm/snapcraft.yaml ./snap/snapcraft.yaml
- run: snapcraft --destructive-mode
- run: snapcraft snap --destructive-mode --output jimm.snap
- uses: actions/upload-artifact@v3
with:
name: jimm-snap
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ COPY . .
RUN echo "${GIT_COMMIT}" | tee ./version/commit.txt
RUN echo "${VERSION}" | tee ./version/version.txt
RUN --mount=type=ssh source /root/.gvm/scripts/gvm && go mod vendor
RUN --mount=type=ssh source /root/.gvm/scripts/gvm && go build -o jimmsrv -race -v -a -mod vendor ./cmd/jimmsrv
RUN --mount=type=ssh source /root/.gvm/scripts/gvm && go build -tags version -o jimmsrv -v -a -mod vendor ./cmd/jimmsrv

# Define a smaller single process image for deployment
FROM ${DOCKER_REGISTRY}ubuntu:20.04 AS deploy-env
Expand Down
3 changes: 2 additions & 1 deletion charms/jimm-k8s/.flake8
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[flake8]
max-line-length = 99
max-line-length = 120
select: E,W,F,C,N
exclude:
venv
.git
build
dist
*.egg_info
ignore = W503
71 changes: 53 additions & 18 deletions charms/jimm-k8s/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,64 @@
# jimm
# Contributing

## Overview

This documents explains the processes and practices recommended for contributing enhancements to
this operator.

- If you would like to chat with us about your use-cases, you can reach
us at [Discourse](https://chat.charmhub.io/charmhub/channels/jaas).
- Familiarising yourself with the [Charmed Operator Framework](https://juju.is/docs/sdk) library
will help you a lot when working on new features or bug fixes.
- All enhancements require review before being merged. Code review typically examines
- code quality
- test coverage
- user experience for Juju administrators this charm.
- Please help us out in ensuring easy to review branches by rebasing your pull request branch onto
the `main` branch. This also avoids merge commits and creates a linear Git commit history.

## Developing

Create and activate a virtualenv with the development requirements:
You can create an environment for development with `tox`:

```shell
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements-dev.txt
pip install tox
```

The charm additionally requires the following relations:
- ingress, interface: ingress
- database, interface: postgresql_client
- vault, interface: vault-kv
- certificates, interface: tls-certificates

virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements-dev.txt
### Testing

## Intended use case
```shell
tox -e fmt # update your code according to linting rules
tox -e lint # code style
tox -e unit # unit tests
tox -e integration # integration tests
tox # runs 'lint' and 'unit' environments
```

This JIMM operator charm is intended for deploying the
Juju Intelligent Model Manager in a k8s cluster. The charm
does not use relations to connect to postgresql and/or
vault as it is assumed those services could be deployed
in a different model.

## Roadmap
## Build charm

* Add postgresql relation
* Add vault relation (when a k8s vault charm becomes available)
Build the charm in this git repository using:

## Testing
```shell
charmcraft pack
```

The Python operator framework includes a very nice harness for testing
operator behaviour without full deployment. Just `run_tests` :
### Deploy

./run_tests
```bash
# Create a model
juju add-model dev
# Enable DEBUG logging
juju model-config logging-config="<root>=INFO;unit=DEBUG"
# Deploy the charm
juju deploy ./juju-jimm-k8s_ubuntu-22.04-amd64.charm
```
24 changes: 21 additions & 3 deletions charms/jimm-k8s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ Create and activate a virtualenv with the development requirements:
## Testing

The Python operator framework includes a very nice harness for testing
operator behaviour without full deployment. Just `run_tests` :

./run_tests
operator behaviour without full deployment. The test suite can be run
using `tox`. You can either `pip install tox` system-wide or create a
virtual env and install tox there as follows
```
python3 -m venv venv
source ./venv/bin/activate
pip install tox
```
At this point you can run tests/linters/formatters.
```
tox -e fmt
tox -e lint
tox -e unit
tox -e integration
```
Note that integration tests will build the charm and deploy it to a local
microk8s controller (which must be setup prior to running the integration test).
To switch the integration test to use a locally built charm use
```
tox -e integration -- --localCharm
```
1 change: 0 additions & 1 deletion charms/jimm-k8s/actions.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Copyright 2022 Canonical Ltd
# See LICENSE file for licensing details.

20 changes: 16 additions & 4 deletions charms/jimm-k8s/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ type: "charm"
parts:
charm:
charm-python-packages: [setuptools]
charm-binary-python-packages:
- cryptography
- jsonschema
- PyYAML
- attrs
- importlib-resources
- urllib3
- zipp
bases:
# This run-on is not as strict as the machine charm
# as the jimm-server runs in a container.
# So the only restriction for build-on vs run-on is
# the charm code.
- build-on:
- name: "ubuntu"
channel: "20.04"
- name: "ubuntu"
channel: "20.04"
run-on:
- name: "ubuntu"
channel: "20.04"
- name: "ubuntu"
channel: "20.04"
15 changes: 3 additions & 12 deletions charms/jimm-k8s/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ options:
description: |
Whitespace separated list of candid users (or groups) that are
made controller admins by default.
dns-name:
type: string
description: Public DNS hostname that JIMM is being served from.
log-level:
type: string
description: |
Expand All @@ -53,16 +50,10 @@ options:
uuid:
type: string
description: The UUID advertised by the JIMM controller.
vault-url:
type: string
description: Vault URL.
vault-role-id:
type: string
description: Vault Role ID.
vault-token:
type: string
description: Vault Token.
juju-dashboard-location:
type: string
default: https://jaas.ai/models
description: URL of the Juju Dashboard for this controller.
dns-name:
type: string
description: DNS hostname that JIMM is being served from.
Loading

0 comments on commit b11c682

Please sign in to comment.