-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into hotfix-return-types-in-funcs
- Loading branch information
Showing
65 changed files
with
2,149 additions
and
731 deletions.
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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: Deploy Test - Helm | ||
|
||
permissions: read-all | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
jobs: | ||
helm: | ||
name: deploy test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 | ||
with: | ||
egress-policy: audit | ||
|
||
- name: Set up Kubernetes | ||
uses: azure/setup-kubectl@3e0aec4d80787158d308d7b364cb1b702e7feb7f # v4.0.0 | ||
with: | ||
version: 'latest' | ||
|
||
- name: "install k3d" | ||
run: "curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash" | ||
shell: bash | ||
|
||
- name: clone pepr | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
repository: defenseunicorns/pepr | ||
path: pepr | ||
|
||
- name: setup node | ||
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 | ||
with: | ||
node-version: 22 | ||
cache: "npm" | ||
cache-dependency-path: pepr | ||
|
||
- name: "set env: PEPR" | ||
run: echo "PEPR=${GITHUB_WORKSPACE}/pepr" >> "$GITHUB_ENV" | ||
|
||
- name: install pepr deps | ||
run: | | ||
cd "$PEPR" | ||
npm ci | ||
- name: build pepr package + image | ||
run: | | ||
cd "$PEPR" | ||
npm run build:image | ||
- name: "set env: MOD_NAME" | ||
run: | | ||
echo "MOD_NAME=pepr-test-helm" >> "$GITHUB_ENV" | ||
- name: "set env: MOD_PATH" | ||
run: | | ||
echo "MOD_PATH=${PEPR}/${MOD_NAME}" >> "$GITHUB_ENV" | ||
- name: init pepr module | ||
run: | | ||
cd "$PEPR" | ||
npx pepr init --name "$MOD_NAME" --description "$MOD_NAME" --skip-post-init --confirm | ||
sed -i 's/uuid": ".*",/uuid": "'$MOD_NAME'",/g' "$MOD_PATH/package.json" | ||
- name: build pepr module | ||
run: | | ||
cd "$MOD_PATH" | ||
npm install "${PEPR}/pepr-0.0.0-development.tgz" | ||
npx pepr build --custom-image pepr:dev | ||
- name: "set env: CLUSTER" | ||
run: echo "CLUSTER=$MOD_NAME" >> "$GITHUB_ENV" | ||
|
||
- name: prep test cluster | ||
run: | | ||
k3d cluster create "$CLUSTER" | ||
k3d image import pepr:dev --cluster "$CLUSTER" | ||
- name: "set env: KUBECONFIG" | ||
run: echo "KUBECONFIG=$(k3d kubeconfig write "$CLUSTER")" >> "$GITHUB_ENV" | ||
|
||
- name: deploy pepr module | ||
run: | | ||
cd "$MOD_PATH" | ||
helm install "$MOD_NAME" "./dist/${MOD_NAME}-chart" --kubeconfig "$KUBECONFIG" | ||
- name: Check Deployment Readiness | ||
timeout-minutes: 5 | ||
run: | | ||
${PEPR}/.github/workflows/scripts/check-deployment-readiness.sh pepr-$MOD_NAME |
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,110 @@ | ||
name: Deploy Test - Zarf | ||
|
||
permissions: read-all | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
env: | ||
MOD_NAME: pepr-test-zarf | ||
|
||
jobs: | ||
zarf: | ||
name: deploy test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Harden Runner | ||
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 | ||
with: | ||
egress-policy: audit | ||
|
||
- name: Set up Kubernetes | ||
uses: azure/setup-kubectl@3e0aec4d80787158d308d7b364cb1b702e7feb7f # v4.0.0 | ||
with: | ||
version: 'latest' | ||
|
||
- name: "install k3d" | ||
run: "curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash" | ||
shell: bash | ||
|
||
- name: Install The Latest Release Version of Zarf | ||
uses: defenseunicorns/setup-zarf@10e539efed02f75ec39eb8823e22a5c795f492ae #v1.0.1 | ||
with: | ||
download-init-package: true | ||
|
||
- name: clone pepr | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
repository: defenseunicorns/pepr | ||
path: pepr | ||
|
||
- name: setup node | ||
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 | ||
with: | ||
node-version: 22 | ||
cache: "npm" | ||
cache-dependency-path: pepr | ||
|
||
- name: "set env: PEPR" | ||
run: echo "PEPR=${GITHUB_WORKSPACE}/pepr" >> "$GITHUB_ENV" | ||
|
||
- name: Install Pepr Dependencies | ||
run: | | ||
cd "$PEPR" | ||
npm ci | ||
- name: Build Pepr Package + Image | ||
run: | | ||
cd "$PEPR" | ||
npm run build:image | ||
- name: "set env: MOD_PATH" | ||
run: | | ||
echo "MOD_PATH=${PEPR}/${MOD_NAME}" >> "$GITHUB_ENV" | ||
- name: Init Pepr Module | ||
run: | | ||
cd "$PEPR" | ||
npx pepr init --name "$MOD_NAME" --description "$MOD_NAME" --skip-post-init --confirm | ||
sed -i 's/uuid": ".*",/uuid": "'$MOD_NAME'",/g' "$MOD_PATH/package.json" | ||
- name: Build Pepr Module | ||
run: | | ||
cd "$MOD_PATH" | ||
npm install "${PEPR}/pepr-0.0.0-development.tgz" | ||
npx pepr build --custom-image pepr:dev | ||
- name: "set env: CLUSTER" | ||
run: echo "CLUSTER=$MOD_NAME" >> "$GITHUB_ENV" | ||
|
||
- name: Prepare Test Cluster | ||
run: | | ||
k3d cluster create "$CLUSTER" | ||
k3d image import pepr:dev --cluster "$CLUSTER" | ||
- name: "set env: KUBECONFIG" | ||
run: echo "KUBECONFIG=$(k3d kubeconfig write "$CLUSTER")" >> "$GITHUB_ENV" | ||
|
||
|
||
- name: Initialize Zarf | ||
run: | | ||
cd "$MOD_PATH" | ||
zarf init --confirm | ||
- name: Package Pepr Module with Zarf | ||
run: | | ||
cd "$MOD_PATH" | ||
zarf package create --confirm "dist/" | ||
- name: Deploy Pepr Module with Zarf | ||
run: | | ||
cd "$MOD_PATH" | ||
zarf package deploy --confirm zarf-package-pepr-pepr-test-zarf-amd64-0.0.1.tar.zst | ||
- name: Check Deployment Readiness | ||
timeout-minutes: 5 | ||
run: | | ||
${PEPR}/.github/workflows/scripts/check-deployment-readiness.sh pepr-$MOD_NAME |
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,48 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
check_deployment_readiness() { | ||
local deployment_name=$1 | ||
local namespace=$2 | ||
local expected_ready_replicas=$3 | ||
local timeout=${4:-300} # Timeout in seconds (default: 5 minutes) | ||
local interval=${5:-5} # Interval between checks in seconds | ||
local elapsed=0 | ||
|
||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Checking readiness for deployment '$deployment_name' in namespace '$namespace'..." | ||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Using timeout: ${timeout}s, interval: ${interval}s" | ||
|
||
while [ "$elapsed" -lt "$timeout" ]; do | ||
ready_replicas=$(kubectl get deploy "$deployment_name" -n "$namespace" -o jsonpath='{.status.readyReplicas}' 2>/dev/null || echo "0") | ||
ready_replicas=${ready_replicas:-0} # Default to 0 if null | ||
|
||
if [ "$ready_replicas" == "$expected_ready_replicas" ]; then | ||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Deployment '$deployment_name' is ready with $ready_replicas replicas." | ||
return 0 | ||
fi | ||
|
||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Waiting for deployment '$deployment_name' to be ready. Ready replicas: ${ready_replicas:-0}/${expected_ready_replicas}." | ||
kubectl get deploy -n "$namespace" | ||
sleep "$interval" | ||
elapsed=$((elapsed + interval)) | ||
done | ||
|
||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Timeout reached while waiting for deployment '$deployment_name' to be ready." | ||
return 1 | ||
} | ||
|
||
# Define success criteria | ||
expected_pepr_replicas=2 | ||
expected_watcher_replicas=1 | ||
module_name=${1:-} | ||
namespace=${2:-pepr-system} # Default to 'pepr-system' if null | ||
|
||
if [ -z "$module_name" ]; then | ||
echo "Error: Module name MUST be provided as the first argument." | ||
exit 1 | ||
fi | ||
|
||
check_deployment_readiness "$module_name" "$namespace" $expected_pepr_replicas || exit 1 # Check readiness for the first deployment | ||
|
||
check_deployment_readiness "$module_name-watcher" "$namespace" $expected_watcher_replicas || exit 1 # Check readiness for the watcher deployment |
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
Oops, something went wrong.