Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
2c0a75f
wip: added charm config
samhotep Jan 28, 2025
cf70fe3
wip: added charm config
samhotep Jan 28, 2025
3114d6c
fix: start even if directory api is unreachable
samhotep Jan 28, 2025
f7b6b84
chore: update linter to exclude charm/*
samhotep Jan 28, 2025
2c22ccb
fix: bug when checking for existing webpages
samhotep Jan 28, 2025
3c2565e
feat: revert to filecache if redis not available
samhotep Feb 18, 2025
7616104
chore: removed default debug in local
samhotep Feb 18, 2025
a168dcf
fix: run periodic tasks on celery configure
samhotep Feb 18, 2025
b217932
feat: added juju deployment CI
samhotep Feb 19, 2025
4c7aca2
fix: use redis for ci
samhotep Feb 19, 2025
be00e28
fix: create rock directories
samhotep Feb 19, 2025
56d0e64
feat: removed git dependency
samhotep Feb 21, 2025
c391c1d
feat: Added copydoctemplate id
samhotep Feb 24, 2025
2572f4d
chore: lint python
samhotep Feb 24, 2025
25d62de
fix: name controller in deployment
samhotep Feb 24, 2025
40f9992
feat: auto rollback on error
samhotep Feb 27, 2025
ef442d8
feat: directly import google credentials
samhotep Feb 27, 2025
0c6c288
feat: use scoped sessions
samhotep Feb 27, 2025
75c9587
fix: updated juju deploy controller
samhotep Feb 27, 2025
1e85a42
fix: update vault read controller
samhotep Feb 27, 2025
d5dd1b7
feat: default to flask_ prefix variables
samhotep Feb 27, 2025
efcfa32
feat: ping jira server on startup and report
samhotep Feb 27, 2025
8faceec
chore: remove unused var
samhotep Feb 27, 2025
d82f2cb
feat: add google auth check on startup
samhotep Feb 27, 2025
68823d3
feat: added prod deployment
samhotep Mar 4, 2025
4cdb3b7
feat: updated repo directory perms
samhotep Mar 4, 2025
6f6f573
feat: make redis optional in charm
samhotep Mar 4, 2025
024775d
feat: reload tree if webpages are incomplete
samhotep Mar 4, 2025
01cfb51
feat: return new tree if pages are incomplete
samhotep Mar 4, 2025
fd72c40
feat: reload incomplete tree root
samhotep Mar 4, 2025
afd467c
chore: lint
samhotep Mar 5, 2025
13b20c8
feat: run deployment job on main branch
samhotep Mar 5, 2025
21ad544
chore: increased delay before image ping
samhotep Mar 5, 2025
f857b7e
chore: run ci in debug mode
samhotep Mar 5, 2025
0940682
feat: added native async tasks
samhotep Mar 7, 2025
06d1527
chore: fix linting
samhotep Mar 7, 2025
049a1fc
fix: return celery fn if celery is active
samhotep Mar 11, 2025
9673ac3
chore: log commit
samhotep Mar 19, 2025
958d154
fix: github cleanup
samhotep Mar 19, 2025
4d3d21e
chore: final fix
samhotep Mar 19, 2025
a4290ea
fix: fix fix
samhotep Mar 19, 2025
87a8e9f
fix:fix fix fix ! promise!!
samhotep Mar 19, 2025
25451fc
feat: build charm when charm files change
samhotep Mar 19, 2025
22977cc
fix: create templates folder if doesnt exist on clone
samhotep Mar 19, 2025
a5bbbb7
feat: checkout code
samhotep Mar 19, 2025
43a7448
feat: conditionally build charm
samhotep Mar 19, 2025
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
5 changes: 3 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PORT=8104
SECRET_KEY=secret_key
VALKEY_HOST=localhost
VALKEY_PORT=6379
REDIS_HOST=localhost
REDIS_PORT=6379
GH_TOKEN=token
REPO_ORG=https://github.com/canonical
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/content
Expand All @@ -18,3 +18,4 @@ GOOGLE_DRIVE_FOLDER_ID=googlecreds
COPYDOC_TEMPLATE_ID=googlecreds
GOOGLE_PRIVATE_KEY=base64encodedprivatekey
GOOGLE_PRIVATE_KEY_ID=privatekeyid
RABBITMQ_URI=amqp://guest:guest@localhost:5672/
29 changes: 16 additions & 13 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: example@canonical.com
JIRA_TOKEN: jiratoken
Expand All @@ -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
Expand All @@ -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 JIRA_EMAIL=example@canonical.com \
Expand All @@ -184,6 +186,7 @@ jobs:
-e COPYDOC_TEMPLATE_ID=templateid \
-e GOOGLE_PRIVATE_KEY="$GOOGLE_PRIVATE_KEY" \
-e GOOGLE_PRIVATE_KEY_ID="$GOOGLE_PRIVATE_KEY_ID" \
-e FLASK_DEBUG=1 \
--network host \
websites-content-system & sleep 1
websites-content-system & sleep 3
curl --head --fail --retry-delay 1 --retry 30 --retry-connrefused http://localhost
144 changes: 144 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
name: Deploy

on:
push:
branches:
- test-deploy
- main

env:
CHARMCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: true
ROCKCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: true

jobs:

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: [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
github-token: ${{ secrets.GITHUB_TOKEN }}

- 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: [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
github-token: ${{ secrets.GITHUB_TOKEN }}

- 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")'
35 changes: 35 additions & 0 deletions .github/workflows/pack-charm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Pack Charm

on:
push:
branches:
- test-deploy
- main
paths:
- 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
8 changes: 4 additions & 4 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
runs-on: ubuntu-latest
services:
valkey:
image: valkey/valkey
image: redis
options: >-
--health-cmd "valkey-cli ping"
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
Expand All @@ -27,8 +27,8 @@ jobs:
env:
DISABLE_SSO: True
SECRET_KEY: secret_key
VALKEY_HOST: localhost
VALKEY_PORT: 6379
REDIS_HOST: localhost
REDIS_PORT: 6379
GH_TOKEN: token
REPO_ORG: https://github.com/canonical
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ COPY . .

# Install python and import python dependencies
RUN apt-get update \
&& apt-get install --no-install-recommends --yes ca-certificates git python3-venv python3-pip python3-psycopg2
&& apt-get install --no-install-recommends --yes ca-certificates python3-venv python3-pip python3-psycopg2
RUN python3 -m venv .venv \
&& . .venv/bin/activate \
&& pip install --no-cache-dir -r requirements.txt
Expand Down
Loading
Loading