Skip to content

Commit

Permalink
add github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam0Brien committed Nov 14, 2024
1 parent 86deaba commit eef1ea2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 8 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: E2E Testing with Kind

on:
workflow_call:
pull_request:
branches: ['main']

jobs:
e2e-test:
name: E2E Test Inventory API
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set Environment Variables
env:
DOCKER_SERVER: registry.access.redhat.com
QUAY_USERNAME: user
QUAY_PASSWORD: pass
QUAY_EMAIL: [email protected]
run: |
echo "Setting up environment variables for Quay authentication."
- name: Inventory Up - Kind Cluster
run: make inventory-up-kind

- name: Monitor Pods in Kind
run: |
timeout 300s kubectl get pods -w || exit 1
- name: View Test Pod Logs
run: |
TEST_POD=$(kubectl get pods --selector=job-name=e2e-inventory-http-tests -o jsonpath='{.items[0].metadata.name}')
kubectl logs $TEST_POD
- name: Inventory Down - Kind Cluster
run: make inventory-down-kind

21 changes: 13 additions & 8 deletions scripts/start-inventory-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ source ./scripts/check_docker_podman.sh

kind create cluster --name inventory-cluster

kubectl create secret docker-registry redhat-registry-secret \
--docker-server=$DOCKER_SERVER \
--docker-username=$QUAY_USERNAME \
--docker-password=$QUAY_PASSWORD \
--docker-email=$QUAY_EMAIL

kubectl create serviceaccount default
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "redhat-registry-secret"}]}'

if [[ -n "$DOCKER_SERVER" && -n "$QUAY_USERNAME" && -n "$QUAY_PASSWORD" ]]; then
kubectl create secret docker-registry redhat-registry-secret \
--docker-server=$DOCKER_SERVER \
--docker-username=$QUAY_USERNAME \
--docker-password=$QUAY_PASSWORD \
--docker-email=$QUAY_EMAIL

kubectl create serviceaccount default
kubectl patch serviceaccount default -p '{"imagePullSecrets": [{"name": "redhat-registry-secret"}]}'
else
echo "Skipping creation of docker-registry secret due to missing credentials."
fi

# build/tag image
${DOCKER} build -t localhost/inventory-api:latest -f Dockerfile .
Expand Down

0 comments on commit eef1ea2

Please sign in to comment.