Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add charm skeleton #2

Merged
merged 4 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,5 @@ jobs:
uses: canonical/charm-logdump-action@main
if: failure()
with:
# TEMPLATE-TODO: Replace the application name
app: operator-template
app: kratos-external-idp-integrator
model: testing
34 changes: 31 additions & 3 deletions .github/workflows/on_pull_request.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
name: Tests
name: On Pull Request

# On pull_request, we:
# * always run lint checks
# * always run tests
# * always publish to charmhub at latest/edge/branchname

on:
pull_request:

jobs:
run-tests:
lint:
name: Lint
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install dependencies
run: python3 -m pip install tox

- name: Run linters
run: tox -e lint

tests:
name: Run Tests
uses: ./.github/workflows/ci.yaml
needs:
- lint
uses: ./.github/workflows/tests.yaml

# publish runs in parallel with tests, as we always publish in this situation
publish-charm:
name: Publish Charm
uses: ./.github/workflows/publish.yaml
secrets:
CHARMCRAFT_CREDENTIALS: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
25 changes: 21 additions & 4 deletions .github/workflows/on_push.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
name: Tests
name: On Push

# On push to a "special" branch, we:
# * always publish to charmhub at latest/edge/branchname
# * always run tests
# where a "special" branch is one of main/master or track/**, as
# by convention these branches are the source for a corresponding
# charmhub edge channel.

on:
push:
branches:
- master
- main
- track/**

jobs:
run-tests:
tests:
name: Run Tests
uses: ./.github/workflows/ci.yaml
uses: ./.github/workflows/tests.yaml
secrets:
charmcraft-credentials: ${{ secrets.CHARMCRAFT_CREDENTIALS }}

# publish runs in series with tests, and only publishes if tests passes
publish-charm:
name: Publish Charm
needs: tests
uses: ./.github/workflows/publish.yaml
secrets:
CHARMCRAFT_CREDENTIALS: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
18 changes: 18 additions & 0 deletions .github/workflows/on_schedule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
on:
schedule:
- cron: '0 8 * * MON'

jobs:
update-charm-libs:
name: Update Charm Libraries
uses: ./.github/workflows/update_libs.yaml

update-deps:
name: Update Dependencies
uses: ./.github/workflows/renovate.yaml

tests:
name: Run Tests
uses: ./.github/workflows/tests.yaml
secrets:
charmcraft-credentials: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
61 changes: 61 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# reusable workflow for publishing all charms in this repo
name: Publish

on:
workflow_call:
inputs:
source_branch:
description: Github branch from this repo to publish. If blank, will use the default branch
default: ''
required: false
type: string
secrets:
CHARMCRAFT_CREDENTIALS:
required: true

workflow_dispatch:
inputs:
destination_channel:
description: CharmHub channel to publish to
required: false
default: 'latest/edge'
type: string
source_branch:
description: Github branch from this repo to publish. If blank, will use the default branch
required: false
default: ''
type: string

jobs:
publish-charm:
name: Publish Charm
runs-on: ubuntu-22.04

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ inputs.source_branch }}

- name: Select charmhub channel
uses: canonical/charming-actions/channel@2.1.0
id: select-channel
if: ${{ inputs.destination_channel == '' }}

# Combine inputs from different sources to a single canonical value so later steps don't
# need logic for picking the right one
- name: Parse and combine inputs
id: parse-inputs
run: |
# destination_channel
destination_channel="${{ inputs.destination_channel || steps.select-channel.outputs.name }}"
echo "setting output of destination_channel=$destination_channel"
echo "::set-output name=destination_channel::$destination_channel"

- name: Upload charm to charmhub
uses: canonical/charming-actions/upload-charm@2.1.0
with:
credentials: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
github-token: ${{ secrets.GITHUB_TOKEN }}
channel: ${{ steps.parse-inputs.outputs.destination_channel }}
26 changes: 26 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# reusable workflow triggered manually
name: Release charm to other tracks and channels

on:
workflow_dispatch:
inputs:
destination-channel:
description: 'Destination Channel'
required: true
origin-channel:
description: 'Origin Channel'
required: true

jobs:
promote-charm:
name: Promote charm
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Release charm to channel
uses: canonical/charming-actions/release-charm@2.1.0
with:
credentials: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
github-token: ${{ secrets.GITHUB_TOKEN }}
destination-channel: ${{ github.event.inputs.destination-channel }}
origin-channel: ${{ github.event.inputs.origin-channel }}
21 changes: 21 additions & 0 deletions .github/workflows/renovate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# workflow for checking package versions and opening PRs to bump
name: Renovate
on:
workflow_dispatch:
workflow_call:

jobs:
renovate:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: List
run: ls -la

- name: Self-hosted Renovate
uses: renovatebot/github-action@v32.236.0
with:
configurationFile: renovate-config.js
token: ${{ github.token }}
45 changes: 45 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Tests
on:
workflow_dispatch:
workflow_call:

jobs:
unit-test:
name: Unit tests
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install dependencies
run: python -m pip install tox

- name: Run tests
run: tox -e unit

integration-test-microk8s:
name: Integration tests (microk8s)
runs-on: ubuntu-22.04
needs:
- unit-test
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
provider: microk8s
channel: 1.25/stable
bootstrap-options: '--agent-version=2.9.34'

- name: Run integration tests
# set a predictable model name so it can be consumed by charm-logdump-action
run: tox -e integration -- --model testing

- name: Dump logs
uses: canonical/charm-logdump-action@main
if: failure()
with:
app: kratos
model: testing
54 changes: 54 additions & 0 deletions .github/workflows/update_libs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# reusable workflow for checking library versions and opening PRs to bump
name: Update Charm Libraries

on:
workflow_call:
inputs:
charmcraft_channel:
description: Channel from which to install charmcraft
default: 'latest/candidate'
required: false
type: string
secrets:
CHARMCRAFT_CREDENTIALS:
required: true
workflow_dispatch:
inputs:
charmcraft_channel:
description: Channel from which to install charmcraft
default: 'latest/candidate'
required: false
type: string

jobs:
update-libs:
name: Update charm libraries
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- run: sudo snap install charmcraft --channel ${{ inputs.charmcraft_channel }} --classic

- name: update charm libs
run: charmcraft fetch-lib
env:
CHARMCRAFT_AUTH: ${{ secrets.CHARMCRAFT_CREDENTIALS }}

- name: Create Pull Request
id: create-pull-request
uses: peter-evans/create-pull-request@v4
with:
title: '(Automated) Update Charm Libs'
body: 'Update charm libs'
commit-message: 'Update charm libs'
signoff: false
delete-branch: true
branch: 'automated-update-charm-libs'

- name: Print Created Pull Request
if: ${{ steps.create-pull-request.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
13 changes: 4 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
This document explains the processes and practices recommended for contributing enhancements to
this operator.

<!-- TEMPLATE-TODO: Update the URL for issue creation -->

- Generally, before developing enhancements to this charm, you should consider [opening an issue
](https://github.com/canonical/operator-template/issues) explaining your use case.
- If you would like to chat with us about your use-cases or proposed implementation, you can reach
](https://github.com/canonical/kratos-external-idp-integrator/issues) explaining your use case.
- If you would like to chat with us about charm development, you can reach
us at [Canonical Mattermost public channel](https://chat.charmhub.io/charmhub/channels/charm-dev)
or [Discourse](https://discourse.charmhub.io/).
- Familiarising yourself with the [Charmed Operator Framework](https://juju.is/docs/sdk) library
Expand Down Expand Up @@ -50,20 +48,17 @@ charmcraft pack

### Deploy

<!-- TEMPLATE-TODO: Update the deploy command for name of charm-->

```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 ./template-operator_ubuntu-20.04-amd64.charm \
juju deploy ./kratos-external-idp-integrator_ubuntu-22.04-amd64.charm \
--resource httpbin-image=kennethreitz/httpbin \
```

## Canonical Contributor Agreement

<!-- TEMPLATE-TODO: Update the description with the name of charm-->

Canonical welcomes contributions to the Charmed Template Operator. Please check out our [contributor agreement](https://ubuntu.com/legal/contributors) if you're interested in contributing to the solution.
Canonical welcomes contributions to the Charmed Kratos IdP Integrator Operator. Please check out our [contributor agreement](https://ubuntu.com/legal/contributors) if you're interested in contributing to the solution.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ TODO: Include a link to the default image your charm uses

## Contributing

<!-- TEMPLATE-TODO: Change this URL to be the full Github path to CONTRIBUTING.md-->

Please see the [Juju SDK docs](https://juju.is/docs/sdk) for guidelines on enhancements to this
charm following best practice guidelines, and
[CONTRIBUTING.md](https://github.com/<name>/<operator>/blob/main/CONTRIBUTING.md) for developer
[CONTRIBUTING.md](https://github.com/canonical/kratos-external-idp-integrator/blob/main/CONTRIBUTING.md) for developer
guidance.
14 changes: 0 additions & 14 deletions actions.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,2 @@
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
#
# TEMPLATE-TODO: change this example to suit your needs.
# If you don't need actions, you can remove the file entirely.
# It ties in to the example _on_fortune_action handler in src/charm.py
#
# Learn more about actions at: https://juju.is/docs/sdk/actions

fortune:
description: Returns a pithy phrase.
params:
fail:
description: "Fail with this message"
type: string
default: ""
4 changes: 2 additions & 2 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type: charm
bases:
- build-on:
- name: "ubuntu"
channel: "20.04"
channel: "22.04"
run-on:
- name: "ubuntu"
channel: "20.04"
channel: "22.04"
Loading