-
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
wip: added charm config #117
Open
samhotep
wants to merge
27
commits into
main
Choose a base branch
from
add-charm
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.
+15,985
−484
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
c5d76b7
wip: added charm config
samhotep a352567
fix: start even if directory api is unreachable
samhotep 2722d96
chore: update linter to exclude charm/*
samhotep 7ee12d4
fix: bug when checking for existing webpages
samhotep a8eb0b9
feat: revert to filecache if redis not available
samhotep a143a01
chore: removed default debug in local
samhotep d41b2b9
fix: run periodic tasks on celery configure
samhotep e9fd892
feat: added juju deployment CI
samhotep 7132787
fix: use redis for ci
samhotep 7da9d10
fix: create rock directories
samhotep 8418eeb
feat: removed git dependency
samhotep b0114dd
feat: Added copydoctemplate id
samhotep 7204321
chore: lint python
samhotep 00ae8d2
fix: name controller in deployment
samhotep 0a9830e
feat: auto rollback on error
samhotep 3fbc225
feat: directly import google credentials
samhotep 245ba1c
feat: use scoped sessions
samhotep 7574588
fix: updated juju deploy controller
samhotep eaf1046
fix: update vault read controller
samhotep 86fb311
feat: default to flask_ prefix variables
samhotep 62defc5
feat: ping jira server on startup and report
samhotep ec8b793
chore: remove unused var
samhotep a14f010
feat: add google auth check on startup
samhotep 6a114b6
feat: added prod deployment
samhotep 59cc02c
feat: updated repo directory perms
samhotep 60edcbb
feat: make redis optional in charm
samhotep 63da450
feat: reload tree if webpages are incomplete
samhotep 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 |
---|---|---|
|
@@ -94,17 +94,19 @@ jobs: | |
name: Run Python | ||
runs-on: ubuntu-latest | ||
services: | ||
valkey: | ||
image: valkey/valkey | ||
redis: | ||
image: redis | ||
options: >- | ||
--health-cmd "valkey-cli ping" | ||
--health-cmd "redis-cli ping" | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
postgres: | ||
image: postgres:latest | ||
env: | ||
POSTGRES_PASSWORD: postgres | ||
ports: | ||
- 5432:5432 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.12 | ||
|
@@ -121,9 +123,9 @@ jobs: | |
GOOGLE_PRIVATE_KEY_ID: ${{ secrets.PRIVATE_KEY_ID }} | ||
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres | ||
SECRET_KEY: secret_key | ||
VALKEY_HOST: localhost | ||
VALKEY_PORT: 6379 | ||
GH_TOKEN: token | ||
REDIS_HOST: localhost | ||
REDIS_PORT: 6379 | ||
GH_TOKEN: ${{ github.token }} | ||
REPO_ORG: https://github.com/canonical | ||
JIRA_EMAIL: [email protected] | ||
JIRA_TOKEN: jiratoken | ||
|
@@ -141,10 +143,10 @@ jobs: | |
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
services: | ||
valkey: | ||
image: valkey/valkey | ||
redis: | ||
image: redis | ||
options: >- | ||
--health-cmd "valkey-cli ping" | ||
--health-cmd "redis-cli ping" | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
|
@@ -170,9 +172,9 @@ jobs: | |
docker run \ | ||
-p 8104:8104 \ | ||
-e SECRET_KEY=secret_key \ | ||
-e VALKEY_HOST=localhost \ | ||
-e VALKEY_PORT=6379 \ | ||
-e GH_TOKEN=token \ | ||
-e REDIS_HOST=localhost \ | ||
-e REDIS_PORT=6379 \ | ||
-e GH_TOKEN=${{ github.token }} \ | ||
-e REPO_ORG=https://github.com/canonical \ | ||
-e DATABASE_URL=postgresql://postgres:postgres@localhost:5432/postgres \ | ||
-e [email protected] \ | ||
|
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,160 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- add-charm | ||
|
||
env: | ||
CHARMCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: true | ||
ROCKCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: true | ||
|
||
jobs: | ||
pack-charm: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup LXD | ||
uses: canonical/setup-lxd@main | ||
|
||
- name: Setup Charmcraft | ||
run: sudo snap install charmcraft --classic --channel=latest/edge | ||
|
||
- name: Pack charm | ||
run: charmcraft pack -v --project-dir ./charm | ||
|
||
- name: Upload charm | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: cs-canonical-com-charm | ||
path: ./*.charm | ||
|
||
pack-rock: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
|
||
- name: Build Assets | ||
run: | | ||
yarn install | ||
yarn run build | ||
|
||
- name: Setup LXD | ||
uses: canonical/setup-lxd@main | ||
|
||
- name: Create repositories directory | ||
run: | | ||
mkdir -m 777 repositories | ||
mkdir -m 777 tree-cache | ||
|
||
- name: Setup Rockcraft | ||
run: sudo snap install rockcraft --classic --channel=latest/edge | ||
|
||
- name: Pack Rock | ||
run: rockcraft pack | ||
|
||
- name: Upload Rock | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: cs-canonical-com-rock | ||
path: ./*.rock | ||
|
||
publish-image: | ||
runs-on: ubuntu-latest | ||
needs: pack-rock | ||
outputs: | ||
image_url: ${{ steps.set_image_url.outputs.image_url }} | ||
steps: | ||
- name: Get Rock | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: cs-canonical-com-rock | ||
|
||
- name: Set image URL | ||
id: set_image_url | ||
run: echo "image_url=ghcr.io/canonical/cs.canonical.com:$(date +%s)-${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT | ||
|
||
- name: Push to GHCR | ||
run: skopeo --insecure-policy copy oci-archive:$(ls *.rock) docker://${{ steps.set_image_url.outputs.image_url }} --dest-creds "canonical:${{ secrets.GITHUB_TOKEN }}" | ||
|
||
deploy-staging: | ||
runs-on: [self-hosted, self-hosted-linux-amd64-jammy-private-endpoint-medium] | ||
needs: [pack-charm, publish-image] | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Dependencies | ||
run: | | ||
sudo snap install juju --channel=3.4/stable --classic | ||
sudo snap install vault --classic | ||
|
||
- name: Download Charm Artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: cs-canonical-com-charm | ||
|
||
- name: Configure Vault and Juju | ||
run: | | ||
export VAULT_ADDR=https://vault.admin.canonical.com:8200 | ||
export TF_VAR_login_approle_role_id=${{ secrets.VAULT_APPROLE_ROLE_ID }} | ||
export TF_VAR_login_approle_secret_id=${{ secrets.VAULT_APPROLE_SECRET_ID }} | ||
export VAULT_SECRET_PATH_ROLE=secret/prodstack6/roles/stg-cs-canonical-com | ||
export VAULT_SECRET_PATH_COMMON=secret/prodstack6/juju/common | ||
VAULT_TOKEN=$(vault write -f -field=token auth/approle/login role_id=${TF_VAR_login_approle_role_id} secret_id=${TF_VAR_login_approle_secret_id}) | ||
export VAULT_TOKEN | ||
mkdir -p ~/.local/share/juju | ||
vault read -field=controller_config "${VAULT_SECRET_PATH_COMMON}/controllers/juju-controller-36-staging-ps6" | base64 -d > ~/.local/share/juju/controllers.yaml | ||
USERNAME=$(vault read -field=username "${VAULT_SECRET_PATH_ROLE}/juju") | ||
PASSWORD=$(vault read -field=password "${VAULT_SECRET_PATH_ROLE}/juju") | ||
printf "controllers:\n juju-controller-36-staging-ps6:\n user: %s\n password: %s\n" "$USERNAME" "$PASSWORD" > ~/.local/share/juju/accounts.yaml | ||
|
||
- name: Deploy Application to staging | ||
run: | | ||
export JUJU_MODEL=admin/stg-cs-canonical-com | ||
juju refresh cs-canonical-com --path ./cs-canonical-com_ubuntu-22.04-amd64.charm --resource flask-app-image=${{ needs.publish-image.outputs.image_url }} | ||
juju wait-for application cs-canonical-com --query='name=="cs-canonical-com" && (status=="active" || status=="idle")' | ||
|
||
deploy-production: | ||
runs-on: [self-hosted, self-hosted-linux-amd64-jammy-private-endpoint-medium] | ||
needs: [pack-charm, publish-image] | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Dependencies | ||
run: | | ||
sudo snap install juju --channel=3.6/stable --classic | ||
sudo snap install vault --classic | ||
|
||
- name: Download Charm Artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: cs-canonical-com-charm | ||
|
||
- name: Configure Vault and Juju | ||
run: | | ||
export VAULT_ADDR=https://vault.admin.canonical.com:8200 | ||
export TF_VAR_login_approle_role_id=${{ secrets.PROD_VAULT_APPROLE_ROLE_ID }} | ||
export TF_VAR_login_approle_secret_id=${{ secrets.PROD_VAULT_APPROLE_SECRET_ID }} | ||
export VAULT_SECRET_PATH_ROLE=secret/prodstack6/roles/prod-cs-canonical-com | ||
export VAULT_SECRET_PATH_COMMON=secret/prodstack6/juju/common | ||
VAULT_TOKEN=$(vault write -f -field=token auth/approle/login role_id=${TF_VAR_login_approle_role_id} secret_id=${TF_VAR_login_approle_secret_id}) | ||
export VAULT_TOKEN | ||
mkdir -p ~/.local/share/juju | ||
vault read -field=controller_config "${VAULT_SECRET_PATH_COMMON}/controllers/juju-controller-36-production-ps6" | base64 -d > ~/.local/share/juju/controllers.yaml | ||
USERNAME=$(vault read -field=username "${VAULT_SECRET_PATH_ROLE}/juju") | ||
PASSWORD=$(vault read -field=password "${VAULT_SECRET_PATH_ROLE}/juju") | ||
printf "controllers:\n juju-controller-36-production-ps6:\n user: %s\n password: %s\n" "$USERNAME" "$PASSWORD" > ~/.local/share/juju/accounts.yaml | ||
|
||
- name: Deploy Application to production | ||
run: | | ||
export JUJU_MODEL=admin/prod-cs-canonical-com | ||
juju refresh cs-canonical-com --path ./cs-canonical-com_ubuntu-22.04-amd64.charm --resource flask-app-image=${{ needs.publish-image.outputs.image_url }} | ||
juju wait-for application cs-canonical-com --query='name=="cs-canonical-com" && (status=="active" || status=="idle")' |
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
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 @@ | ||
from webapp.app import app # noqa F401 |
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,9 @@ | ||
venv/ | ||
build/ | ||
*.charm | ||
.tox/ | ||
.coverage | ||
__pycache__/ | ||
*.py[cod] | ||
.idea | ||
.vscode/ |
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.
shouldn't it be
.venv
?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.
It's created by default by the charm initialization, along with some charm src files, so I've left it as is