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

GitHub workflow for validating terraform deploy + upgrading charms #81

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0b4b3b9
Adds a workflow for doing a terraform deploy
mz2 Dec 12, 2023
58fe669
Tweaks to trigger conditions of the terraform_test_deploy workflow
mz2 Dec 12, 2023
a5bca3d
Loosens up the filter conditions
mz2 Dec 12, 2023
24b4078
Install terraform dependency: unzip
mz2 Dec 12, 2023
e787914
Remove redundant terraform apply
mz2 Dec 12, 2023
bb49570
min => m as unit
mz2 Dec 12, 2023
0c0ccf8
Updates trigger conditions for tests, adds manual dispatching around
mz2 Dec 12, 2023
1a33fa2
Updates to the new charm format, updates charm libraries, removes sta…
mz2 Dec 12, 2023
2558fed
Merge branch 'main' of github.com:canonical/test_observer into terraf…
mz2 Dec 12, 2023
567d6b3
Charm now happily works with multiple units
mz2 Dec 12, 2023
d154e5c
Drops some stray whitespaces
mz2 Dec 12, 2023
22f8fb1
Removes an accidentally added, redundant .dockerignore
mz2 Dec 12, 2023
a23cf00
Drops the template for vscode-settings-default.json
mz2 Dec 12, 2023
487370c
Removes the bit in the README about copying in the vscode settings in…
mz2 Dec 12, 2023
762d37a
Build the charm locally, upgrade to it
mz2 Dec 12, 2023
b1392f2
Adjusted triggers
mz2 Dec 12, 2023
600770c
Adjusted triggers once again
mz2 Dec 12, 2023
cddd434
Adjusted triggers once again
mz2 Dec 12, 2023
79d33e6
Remove the dependency for now
mz2 Dec 12, 2023
96ab78b
Adds a type hint back to faults.py
mz2 Dec 12, 2023
e42ef9d
Deploy also the frontend charm
mz2 Dec 12, 2023
3f02329
Switch the model
mz2 Dec 12, 2023
5729678
Adjust the triggers
mz2 Dec 12, 2023
c789d9c
Oops, refresh the frontend app with the frontend charm
mz2 Dec 12, 2023
075bff2
Remove the if condition for now
mz2 Dec 12, 2023
bbc885c
Changes to terraform plan should also lead to a deploy
mz2 Dec 12, 2023
80303b8
Wait for application to have deployed
mz2 Dec 12, 2023
aaf3826
Wait for _frontend_ before refreshing the frontend charm
mz2 Dec 12, 2023
99f6d89
Add crashdump uploading
mz2 Dec 12, 2023
a81ba86
Output juju status and juju crashdump
mz2 Dec 12, 2023
fa6a77f
Remove redundant SystemExit(0)
mz2 Dec 14, 2023
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
4 changes: 3 additions & 1 deletion .github/workflows/frontend_charm_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: Run charm tests
on:
pull_request:
branches:
- main
- '**'
paths:
- 'frontend/charm/**'
push:
branches: ["main"]
tags: ["v*.*.*"]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ on:
push:
branches: ["main"]
tags: ["v*.*.*"]
workflow_dispatch:

env:
REGISTRY: ghcr.io
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish_frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ on:
push:
branches: ["main"]
tags: ["v*.*.*"]
workflow_dispatch:

env:
REGISTRY: ghcr.io
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/terraform_test_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Terraform deploy to a fresh microk8s model
on:
# pull_request_review:
# on:
# pull_request_review:
# types:
# - submitted
pull_request:
branches:
- '**'
# paths:
# - 'frontend/charm/**'
# - 'backend/charm/**'
# - 'terraform/**'
push:
tags:
- "v*.*.*"
workflow_dispatch:

jobs:
deploy:
runs-on: [self-hosted, jammy, xlarge]

defaults:
run:
working-directory: ./terraform

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Terraform dependencies
run: |
sudo apt-get update
sudo apt-get install unzip

- name: Set up terraform
uses: hashicorp/setup-terraform@v1

- name: Terraform init
run: terraform init

- name: Set up microk8s
uses: canonical/certification-github-workflows/.github/actions/microk8s-setup@main

- name: Terraform apply
run: |
TF_VAR_environment=development \
TF_VAR_nginx_ingress_integrator_charm_whitelist_source_range="" \
terraform apply -auto-approve

- name: Wait for deployment to complete
run: |
juju wait-for model test-observer-development \
--timeout=10m \
--query='life=="alive" && status=="available" && forEach(applications, app => app.status == "active")'



9 changes: 7 additions & 2 deletions .github/workflows/test_backend.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: Test Backend
on: [push]
# Cancel inprogress runs if new commit pushed
on:
push:
paths:
- 'backend/**'
tags:
- "v*.*.*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: [self-hosted, linux, large]
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/test_frontend.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: Test Frontend
on: [push]
# Cancel inprogress runs if new commit pushed
on:
push:
paths:
- 'frontend/**'
tags:
- "v*.*.*"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: [self-hosted, linux, large]
Expand Down
2 changes: 2 additions & 0 deletions backend/charm/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
prime
stage
3 changes: 3 additions & 0 deletions backend/charm/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
*.charm
venv
prime
stage
parts
14 changes: 14 additions & 0 deletions backend/charm/.vscode-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"python.autoComplete.extraPaths": [
"./lib"
],
"python.analysis.extraPaths": [
"./lib"
],
"yaml.schemas": {
"https://json.schemastore.org/yamllint.json": [
"./metadata.yaml"
]
},
"ansible.python.interpreterPath": "./venv/bin/python3"
}
26 changes: 26 additions & 0 deletions backend/charm/charmcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
name: test-observer-api
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I migrated to the new one-yaml format.

type: charm
summary: |
API to observe the status of artifact (snaps, debs, etc) testing
description: |
API and dashboard to observe the status of artifact (snaps, debs, etc) test status
bases:
- build-on:
- name: ubuntu
channel: "22.04"
run-on:
- name: ubuntu
channel: "22.04"
assumes:
- juju >= 2.9
- k8s-api
containers:
api:
resource: api-image
requires:
database:
interface: postgresql_client
limit: 1
nginx-route:
interface: nginx-route
provides:
test-observer-rest-api:
interface: http
scope: global
resources:
api-image:
type: oci-image
description: OCI image from GitHub Container Repository
upstream-source: ghcr.io/canonical/test_observer/api:main
Loading
Loading