Skip to content

Commit

Permalink
ci: 👷 deploy preprod with kube instead of terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
this-is-tobi committed Jul 26, 2023
1 parent 6e2cf0d commit 4a2170d
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 26 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/change-values.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
type: string
description: "Namespace name in kubernetes cluster"
default: "basegun"
domain:
required: true
type: string
description: "Nom de domaine utilisé par l'application"
default: "basegun.fr"
branch:
required: true
type: string
Expand Down Expand Up @@ -68,9 +73,14 @@ jobs:
- name: Update Infra Version
run: |
export TAG=$(make get-current-tag)
yq -i '.backend.image.tag = strenv(TAG)' ./infra/kube/basegun/values.yaml
yq -i '.frontend.image.tag = strenv(TAG)' ./infra/kube/basegun/values.yaml
export TAG=$(make get-current-tag)
yq -i '.backend.image.tag = strenv(TAG)' ./infra/kube/helm/values.yaml
yq -i '.frontend.image.tag = strenv(TAG)' ./infra/kube/helm/values.yaml
- name: Update ingress domaine
run: |
export DOMAIN="${{ inputs.domain }}"
yq -i '.ingress.hosts[0].host = strenv(DOMAIN)' ./infra/kube/helm/values.yaml
- name: Commit and push changes
uses: devops-infra/[email protected]
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/preprod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,31 @@ jobs:
organization: datalab-mi
container: basegun/basegun-backend
dry-run: false
untagged: true
prune-untagged: true
- name: Delete untagged images
uses: vlaurin/action-ghcr-prune@main
with:
token: ${{ secrets.PERSO_ACCESS_TOKEN }}
organization: datalab-mi
container: basegun/basegun-frontend
dry-run: false
untagged: true
prune-untagged: true

deploy-preprod:
uses: ./.github/workflows/deploy.yml
uses: ./.github/workflows/change-values.yml
needs: build-push
with:
image_version: "develop"
branch: ${{ github.ref_name }}
volume_size: 10
flavor: "s1-2"
workspace: "preprod"
namespace: basegun-preprod
domain: preprod.basegun.fr
secrets:
API_OVH_TOKEN: ${{ secrets.API_OVH_TOKEN }}
SERVER_IP: ${{ secrets.PREPROD_SERVER_IP }}
OS_PASSWORD: ${{ secrets.OS_PASSWORD }}
OS_PROJECT_ID: ${{ secrets.OS_PROJECT_ID }}
OS_PROJECT_NAME: ${{ secrets.OS_PROJECT_NAME }}
OS_USERNAME: ${{ secrets.OS_USERNAME }}
X_OVH_TOKEN: ${{ secrets.PREPROD_OVH_TOKEN }}
JOB_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
KUBECONFIG: ${{ secrets.PREPROD_K8_CONFIG }}

test:
runs-on: ubuntu-latest
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/test-kube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ jobs:
wait: 60s
verbosity: 2

- name: Set up ingress controller
run: |
helm repo add traefik https://traefik.github.io/charts && helm repo update
helm install --namespace ingress-traefik --create-namespace traefik traefik/traefik --values ./infra/kind/traefik-values.yml
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.11.2

- name: Set up ingress controller
run: |
helm repo add traefik https://traefik.github.io/charts && helm repo update
helm install --namespace ingress-traefik --create-namespace traefik traefik/traefik --values ./infra/kind/traefik-values.yml
- name: Add hosts to /etc/hosts
run: |
sudo echo "127.0.0.1 $LOCAL_DOMAIN" | sudo tee -a /etc/hosts
Expand All @@ -60,9 +60,8 @@ jobs:
--set-string backend.secret.values.OS_USERNAME="${{ secrets.OS_USERNAME }}" \
--set-string backend.secret.values.OS_PASSWORD="${{ secrets.OS_PASSWORD }}" \
--set-string backend.secret.values.OS_PROJECT_NAME="${{ secrets.OS_PROJECT_NAME }}" \
--set-string backend.secret.values.OS_TEST="${{ secrets.OS_TEST }}" \
--set-string backend.secret.values.X_OVH_TOKEN="test" \
--set-string backend.secret.values.API_OVH_TOKEN="test"
--set-string backend.secret.values.X_OVH_TOKEN="${{ secrets.PREPROD_OVH_TOKEN }}" \
--set-string backend.secret.values.API_OVH_TOKEN="${{ secrets.API_OVH_TOKEN }}"
for i in $(kubectl get deploy -o name); do kubectl rollout status $i -w --timeout=130s; done
- name: Display pod logs on failure
Expand Down
11 changes: 11 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ Open localhost:3000
docker run --rm -p 3000:3000 -d basegun-front:dev
```

## Test project
Run end-to-end tests with cypress. You need first to have installed dependancies with `npm ci`.

First run website with Docker then
```bash
# run in headless mode (only in terminal)
npm --prefix frontend run test:e2e-run

# run with graphical interface
npm --prefix frontend run test:e2e-open
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
2 changes: 1 addition & 1 deletion frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"format": "eslint src --fix",
"format:css": "stylelint --fix src/**/*.{css,vue}",
"pretest:unit": "npm run lint",
"test:e2e": "start-server-and-test preview http://localhost:4173 'cypress run --e2e --browser firefox'",
"test:e2e-ci": "cypress run --e2e --browser firefox",
"test:e2e-dev": "API_HOST=localhost start-server-and-test 'vite --port 4173' http://localhost:4173 'cypress open --e2e'"
"test:e2e-open": "FRONTEND_HOST=localhost FRONTEND_PORT=3000 cypress open --e2e --browser firefox",
"test:e2e-run": "FRONTEND_HOST=localhost FRONTEND_PORT=3000 cypress run --e2e --browser firefox"
},
"dependencies": {
"@gouvfr/dsfr": "^1.9.2",
Expand Down
6 changes: 3 additions & 3 deletions infra/kube/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ingress:
#traefik.ingress.kubernetes.io/router.tls: "true"
#traefik.ingress.kubernetes.io/router.tls.certresolver: letsencrypt
hosts:
- host: kube.basegun.fr
- host: preprod.basegun.fr
paths:
- path: /
pathType: Prefix
Expand All @@ -34,7 +34,7 @@ backend:
repository: ghcr.io/datalab-mi/basegun/basegun-backend
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "2.0"
tag: "3.0"
imagePullSecrets: []
podAnnotations: {}
podSecurityContext: {}
Expand Down Expand Up @@ -96,7 +96,7 @@ frontend:
repository: ghcr.io/datalab-mi/basegun/basegun-frontend
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "2.0"
tag: "3.0"
imagePullSecrets: []
podAnnotations: {}
podSecurityContext: {}
Expand Down

0 comments on commit 4a2170d

Please sign in to comment.