Skip to content

Commit

Permalink
ZO-4519: Deploy nightwatch to k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
wosc committed Jan 24, 2024
1 parent 6b529bb commit 6fee72a
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/nightwatch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build and deploy nightwatch tests

on:
push:
branches:
- main
paths:
- '.github/workflows/nightwatch.yaml'
- 'smoketest/**'
pull_request:
paths:
- '.github/workflows/nightwatch.yaml'
- 'smoketest/**'

jobs:
build:
uses: zeitonline/gh-action-workflows/.github/workflows/[email protected]
secrets: inherit
with:
versions: smoketest/k8s/base/versions

# deploy happens via flux (on `main` branch)
29 changes: 29 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

COMMAND=$1
case $COMMAND in
smoke)
set -e
shift
if [[ "$1" != -* ]]; then
environment=$1
shift
else
environment="staging"
fi

cd "$DIR/../smoketest"

image=$(awk -F': ' '$2 == "nightwatch" { l=NR } l && NR==l+1 { print $2 }' \
< k8s/base/kustomization.yaml)
docker buildx build --output type=docker --quiet --tag $image .
docker run --rm ${interactive} $image \
--nightwatch-environment=$environment "$@"
;;
*)
echo "Unrecognized command: $COMMAND"
exit 1
;;
esac
1 change: 1 addition & 0 deletions smoketest/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
k8s/**/*
9 changes: 9 additions & 0 deletions smoketest/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# See https://github.com/ZeitOnline/gh-action-workflows/blob/main/.github/workflows/nightwatch-build.yaml
FROM python:3.12.1-slim as nightwatch
WORKDIR /app
RUN pip --no-cache-dir install pipenv
COPY Pipfile Pipfile.lock ./
RUN pipenv sync
COPY *.py ./
# See https://github.com/ZeitOnline/kustomize/blob/main/components/nightwatch/deployment.yaml
ENTRYPOINT ["pipenv", "run", "pytest", "--tb=native"]
11 changes: 11 additions & 0 deletions smoketest/k8s/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

components:
- github.com/ZeitOnline/kustomize/components/nightwatch?ref=1.3
- versions

# See https://github.com/ZeitOnline/gh-action-workflows/blob/main/.github/workflows/nightwatch-build.yaml
images:
- name: nightwatch
newName: europe-west3-docker.pkg.dev/zeitonline-engineering/docker-zon/vivi-nightwatch
6 changes: 6 additions & 0 deletions smoketest/k8s/base/versions/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component

images:
- name: nightwatch
newTag: "nothing"
15 changes: 15 additions & 0 deletions smoketest/k8s/production/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../base

patches:
- target:
kind: Deployment
name: nightwatch
patch: |-
- op: replace
path: /spec/template/spec/containers/0/args
value:
- "--nightwatch-environment=production"
5 changes: 5 additions & 0 deletions smoketest/k8s/staging/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../base

0 comments on commit 6fee72a

Please sign in to comment.