Skip to content

Commit

Permalink
Merge pull request #1 from canonical/repo-structure
Browse files Browse the repository at this point in the history
Create initial Repo structure
  • Loading branch information
DomFleischmann authored Jul 14, 2022
2 parents dc6929c + 1552d0c commit d8d5608
Show file tree
Hide file tree
Showing 25 changed files with 853 additions and 0 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# reusable workflow triggered by other actions
name: Continuous Integration

on:
workflow_call:
secrets:
charmcraft-credentials:
required: true

jobs:

lib-check:
name: Check libraries
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check libs
uses: canonical/charming-actions/[email protected]
with:
credentials: "${{ secrets.charmcraft-credentials }}"
github-token: "${{ secrets.GITHUB_TOKEN }}"

lint:
name: Lint Code
runs-on: ubuntu-latest
strategy:
matrix:
charm: [kserve-web-app]
steps:
- uses: actions/checkout@v2
- run: sudo apt update && sudo apt install tox
- run: tox -e ${{ matrix.charm }}-lint

unit:
name: Unit Test
runs-on: ubuntu-latest
strategy:
matrix:
charm: [kserve-web-app]
steps:
- uses: actions/checkout@v2
- run: sudo apt update && sudo apt install tox
- run: tox -e ${{ matrix.charm }}-unit

integration:
name: Integration Test
runs-on: ubuntu-latest
strategy:
matrix:
charm: [kserve-web-app]
steps:
- uses: actions/checkout@v2
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
provider: microk8s
channel: 1.21/stable
charmcraft-channel: latest/candidate

- name: Build and test
working-directory: ./charms/${{ matrix.charm }}
run: |
sg microk8s -c "tox -vve integration -- --model testing"
# On failure, capture debugging resources
- name: Get all
run: kubectl get all -A
if: failure()

- name: Describe deployments
run: kubectl describe deployments -A
if: failure()

- name: Describe replicasets
run: kubectl describe replicasets -A
if: failure()

- name: Get juju status
run: juju status
if: failure()

- name: Get application logs
run: kubectl logs -n testing --tail 1000 -ljuju-app=${{ matrix.charm }}
if: failure()

- name: Get argo-controller operator logs
run: kubectl logs -n testing --tail 1000 -ljuju-operator=${{ matrix.charm }}
if: failure()
23 changes: 23 additions & 0 deletions .github/workflows/on_pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Test and publish to branch

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

on:
pull_request:

jobs:

tests:
name: Run Tests
uses: ./.github/workflows/integration.yaml
secrets:
charmcraft-credentials: "${{ secrets.CHARMCRAFT_CREDENTIALS }}"

# 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 }}"
31 changes: 31 additions & 0 deletions .github/workflows/on_push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish to edge if tests passed

# 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:

tests:
name: Run Tests
uses: ./.github/workflows/integration.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 }}"
35 changes: 35 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# reusable workflow triggered by other actions
name: Publish

on:
workflow_call:
secrets:
charmcraft-credentials:
required: true

jobs:

publish-charm:
name: Publish Charm
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
charm:
- kserve-web-app
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Select charmhub channel
uses: canonical/charming-actions/[email protected]
id: channel
- name: Upload charm to charmhub
uses: canonical/charming-actions/[email protected]
with:
credentials: ${{ secrets.charmcraft-credentials }}
github-token: ${{ secrets.GITHUB_TOKEN }}
charm-path: charms/${{ matrix.charm }}
channel: ${{ steps.channel.outputs.name }}
tag-prefix: ${{ matrix.charm }}
31 changes: 31 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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
charm-name:
description: 'Charm subdirectory name'
required: true

jobs:
promote-charm:
name: Promote charm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Release charm to channel
uses: canonical/charming-actions/[email protected]
with:
credentials: ${{ secrets.CHARMCRAFT_CREDENTIALS }}
github-token: ${{ secrets.GITHUB_TOKEN }}
destination-channel: ${{ github.event.inputs.destination-channel }}
origin-channel: ${{ github.event.inputs.origin-channel }}
tag-prefix: ${{ github.event.inputs.charm-name }}
charm-path: charms/${{ github.event.inputs.charm-name}}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.charm
*__pycache__
*.tox
build/
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@canonical/kubeflow
57 changes: 57 additions & 0 deletions charms/kserve-web-app/.github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Bug Report
description: File a bug report
labels: ["Type: Bug", "Status: Triage"]
body:
- type: markdown
attributes:
value: >
Thanks for taking the time to fill out this bug report! Before submitting your issue, please make
sure you are using the latest version of the charm. If not, please switch to this image prior to
posting your report to make sure it's not already solved.
- type: textarea
id: bug-description
attributes:
label: Bug Description
description: >
If applicable, add screenshots to help explain the problem you are facing.
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: To Reproduce
description: >
Please provide a step-by-step instruction of how to reproduce the behavior.
placeholder: |
1. `juju deploy ...`
2. `juju relate ...`
3. `juju status --relations`
validations:
required: true
- type: textarea
id: environment
attributes:
label: Environment
description: >
We need to know a bit more about the context in which you run the charm.
- Are you running Juju locally, on lxd, in multipass or on some other platform?
- What track and channel you deployed the charm from (ie. `latest/edge` or similar).
- Version of any applicable components, like the juju snap, the model controller, lxd, microk8s, and/or multipass.
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant log output
description: >
Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
Fetch the logs using `juju debug-log --replay` and `kubectl logs ...`. Additional details available in the juju docs
at https://juju.is/docs/olm/juju-logs
render: shell
validations:
required: true
- type: textarea
id: additional-context
attributes:
label: Additional context

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Enhancement Proposal
description: File an enhancement proposal
labels: ["Type: Enhancement", "Status: Triage"]
body:
- type: markdown
attributes:
value: >
Thanks for taking the time to fill out this enhancement proposal! Before submitting your issue, please make
sure there isn't already a prior issue concerning this. If there is, please join that discussion instead.
- type: textarea
id: enhancement-proposal
attributes:
label: Enhancement Proposal
description: >
Describe the enhancement you would like to see in as much detail as needed.
validations:
required: true
45 changes: 45 additions & 0 deletions charms/kserve-web-app/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Tests
on:
workflow_call:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run: python3 -m pip install tox
- name: Run linters
run: tox -e lint
unit-test:
name: Unit tests
runs-on: ubuntu-latest
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-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup operator environment
uses: charmed-kubernetes/actions-operator@main
with:
provider: microk8s
- 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:
# TEMPLATE-TODO: Replace the application name
app: operator-template
model: testing
8 changes: 8 additions & 0 deletions charms/kserve-web-app/.github/workflows/on_pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Tests
on:
pull_request:

jobs:
run-tests:
name: Run Tests
uses: ./.github/workflows/ci.yaml
12 changes: 12 additions & 0 deletions charms/kserve-web-app/.github/workflows/on_push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Tests
on:
push:
branches:
- master
- main
- track/**

jobs:
run-tests:
name: Run Tests
uses: ./.github/workflows/ci.yaml
8 changes: 8 additions & 0 deletions charms/kserve-web-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
venv/
build/
*.charm
.tox/
.coverage
__pycache__/
*.py[cod]
.idea
3 changes: 3 additions & 0 deletions charms/kserve-web-app/.jujuignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/venv
*.py[cod]
*.charm
Loading

0 comments on commit d8d5608

Please sign in to comment.