-
Notifications
You must be signed in to change notification settings - Fork 3
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
mz2
wants to merge
31
commits into
main
Choose a base branch
from
terraform-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all 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 58fe669
Tweaks to trigger conditions of the terraform_test_deploy workflow
mz2 a5bca3d
Loosens up the filter conditions
mz2 24b4078
Install terraform dependency: unzip
mz2 e787914
Remove redundant terraform apply
mz2 bb49570
min => m as unit
mz2 0c0ccf8
Updates trigger conditions for tests, adds manual dispatching around
mz2 1a33fa2
Updates to the new charm format, updates charm libraries, removes sta…
mz2 2558fed
Merge branch 'main' of github.com:canonical/test_observer into terraf…
mz2 567d6b3
Charm now happily works with multiple units
mz2 d154e5c
Drops some stray whitespaces
mz2 22f8fb1
Removes an accidentally added, redundant .dockerignore
mz2 a23cf00
Drops the template for vscode-settings-default.json
mz2 487370c
Removes the bit in the README about copying in the vscode settings in…
mz2 762d37a
Build the charm locally, upgrade to it
mz2 b1392f2
Adjusted triggers
mz2 600770c
Adjusted triggers once again
mz2 cddd434
Adjusted triggers once again
mz2 79d33e6
Remove the dependency for now
mz2 96ab78b
Adds a type hint back to faults.py
mz2 e42ef9d
Deploy also the frontend charm
mz2 3f02329
Switch the model
mz2 5729678
Adjust the triggers
mz2 c789d9c
Oops, refresh the frontend app with the frontend charm
mz2 075bff2
Remove the if condition for now
mz2 bbc885c
Changes to terraform plan should also lead to a deploy
mz2 80303b8
Wait for application to have deployed
mz2 aaf3826
Wait for _frontend_ before refreshing the frontend charm
mz2 99f6d89
Add crashdump uploading
mz2 a81ba86
Output juju status and juju crashdump
mz2 fa6a77f
Remove redundant SystemExit(0)
mz2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ on: | |
push: | ||
branches: ["main"] | ||
tags: ["v*.*.*"] | ||
workflow_dispatch: | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ on: | |
push: | ||
branches: ["main"] | ||
tags: ["v*.*.*"] | ||
workflow_dispatch: | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
name: Terraform deploy to a fresh microk8s model | ||
on: | ||
pull_request: | ||
branches: | ||
- '**' | ||
paths: | ||
- 'frontend/charm/**' | ||
- 'backend/charm/**' | ||
- 'terraform/**' | ||
pull_request_review: | ||
on: | ||
pull_request_review: | ||
types: | ||
- submitted | ||
paths: | ||
- 'frontend/charm/**' | ||
- 'backend/charm/**' | ||
- 'terraform/**' | ||
push: | ||
branches: ["main"] | ||
tags: ["v*.*.*"] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
deploy: | ||
name: terraform deploy + upgrade charms | ||
# if: github.event.review.state == 'APPROVED' | ||
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 | ||
|
||
# TODO: Separate this build step to its own action once custom VM images are available | ||
# (when there is a charmcraft + LXD capable image available) | ||
- name: Build API charm | ||
run: charmcraft pack | ||
working-directory: ./backend/charm | ||
|
||
# TODO: Separate this build step to its own action once custom VM images are available | ||
# (when there is a charmcraft + LXD capable image available) | ||
- name: Build frontend charm | ||
run: charmcraft pack | ||
working-directory: ./frontend/charm | ||
|
||
- name: Terraform apply | ||
run: | | ||
TF_VAR_environment=development \ | ||
TF_VAR_nginx_ingress_integrator_charm_whitelist_source_range="" \ | ||
terraform apply -auto-approve | ||
|
||
- name: Switch model to test-observer-development | ||
run: | | ||
juju switch test-observer-development | ||
sleep 10 # hack hack, the below wait-for condition is not actually correct, so let's wait a bit | ||
|
||
- name: Replace the API charm with the locally built one | ||
run: | | ||
juju wait-for application api --timeout=10m --query='life=="alive"' | ||
juju refresh api --path ../backend/charm/*.charm | ||
|
||
- name: Replace the frontend charm with the locally built one | ||
run: | | ||
juju wait-for application frontend --timeout=10m --query='life=="alive"' | ||
juju refresh frontend --path ../frontend/charm/*.charm | ||
|
||
- 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")' | ||
|
||
- name: Echo juju status on failure | ||
if: failure() | ||
run: | | ||
juju status --color | ||
|
||
- name: Run juju crashdump on failure | ||
if: failure() | ||
run: | | ||
sudo juju crashdump -o ./ -m test-observer-development --as-root -a juju-show-unit -a juju-show-status-log -a juju-show-machine -a config | ||
sudo chown $USER ./**/juju-crashdump-*.tar.xz | ||
|
||
- name: Archive juju crashdump on failure | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: juju-crashdump | ||
path: ./**/juju-crashdump-*.tar.xz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +0,0 @@ | ||
# Visual Studio Code configurations | ||
.vscode | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"python.analysis.extraPaths": [ | ||
"./backend/charm/lib" | ||
], | ||
"cmake.sourceDirectory": "/home/mz2/Developer/test_observer/frontend/linux" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
*.charm | ||
venv | ||
prime | ||
stage | ||
parts |
6 changes: 4 additions & 2 deletions
6
frontend/charm/.vscode-settings-default.json → backend/charm/.vscode-settings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"python.analysis.extraPaths": [ | ||
"./lib/charms", | ||
"./lib" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,34 @@ | ||
name: test-observer-api | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure about including this path to settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was intentional since VS Code looked like it was now doing relative path updates. However, what I committed was the wrong state of the file 🤦