Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
211 lines
6.3 KiB
Bash
Executable File
211 lines
6.3 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
# Script to start temporal worker build workflow with latest commit SHA
|
|
# Ensures proper error handling and prevents SHA mistakes
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Default values
|
|
REPO_URL="https://github.com/Nine-Minds/alga-psa.git"
|
|
SET_LATEST="true"
|
|
WORKFLOW_TEMPLATE="temporal-worker-build"
|
|
|
|
# Function to get latest commit SHA
|
|
get_latest_sha() {
|
|
local sha=$(git rev-parse HEAD)
|
|
if [ -z "$sha" ]; then
|
|
echo -e "${RED}Error: Failed to get latest commit SHA${NC}" >&2
|
|
exit 1
|
|
fi
|
|
echo "$sha"
|
|
}
|
|
|
|
# Function to check if working directory is clean
|
|
check_working_directory() {
|
|
if ! git diff --quiet || ! git diff --cached --quiet; then
|
|
echo -e "${YELLOW}Warning: You have uncommitted changes${NC}"
|
|
echo "The Kubernetes build will use the code from GitHub at the specified commit."
|
|
echo "Your local uncommitted changes will NOT be included in the build."
|
|
echo ""
|
|
read -p "Continue anyway? (y/N) " -n 1 -r
|
|
echo
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
echo -e "${RED}Build cancelled${NC}"
|
|
exit 1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# Function to check if commit is pushed
|
|
check_commit_pushed() {
|
|
local sha=$1
|
|
local current_branch=$(git branch --show-current)
|
|
|
|
# Check if commit exists on remote
|
|
if ! git branch -r --contains "$sha" | grep -q "origin/"; then
|
|
echo -e "${RED}Error: Local commit $sha is not pushed to remote${NC}" >&2
|
|
echo "The Kubernetes build needs the commit to be available on GitHub."
|
|
echo "Please push your changes first: git push origin $current_branch"
|
|
exit 1
|
|
fi
|
|
|
|
# Double-check by fetching and comparing
|
|
git fetch origin "$current_branch" --quiet
|
|
local remote_sha=$(git rev-parse "origin/$current_branch" 2>/dev/null || echo "")
|
|
|
|
if [ -z "$remote_sha" ]; then
|
|
echo -e "${RED}Error: Branch $current_branch doesn't exist on remote${NC}" >&2
|
|
echo "Please push your branch first: git push -u origin $current_branch"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if our commit is an ancestor of the remote branch
|
|
if ! git merge-base --is-ancestor "$sha" "$remote_sha"; then
|
|
echo -e "${RED}Error: Local commit $sha is not on remote branch $current_branch${NC}" >&2
|
|
echo "The Kubernetes build needs the commit to be available on GitHub."
|
|
echo "Please push your changes first: git push origin $current_branch"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Function to create workflow YAML
|
|
create_workflow_yaml() {
|
|
local sha=$1
|
|
local workflow_file="/tmp/temporal-worker-build-${sha:0:7}.yaml"
|
|
|
|
cat > "$workflow_file" << EOF
|
|
apiVersion: argoproj.io/v1alpha1
|
|
kind: Workflow
|
|
metadata:
|
|
generateName: temporal-worker-build-auto-
|
|
namespace: argo
|
|
spec:
|
|
workflowTemplateRef:
|
|
name: ${WORKFLOW_TEMPLATE}
|
|
arguments:
|
|
parameters:
|
|
- name: repo-url
|
|
value: "${REPO_URL}"
|
|
- name: commit-sha
|
|
value: "${sha}"
|
|
- name: set-latest
|
|
value: "${SET_LATEST}"
|
|
EOF
|
|
|
|
echo "$workflow_file"
|
|
}
|
|
|
|
# Function to submit workflow
|
|
submit_workflow() {
|
|
local workflow_file=$1
|
|
local output
|
|
|
|
echo -e "${GREEN}Submitting workflow...${NC}"
|
|
|
|
# Submit workflow and capture output (use create for generateName)
|
|
if output=$(kubectl create -f "$workflow_file" 2>&1); then
|
|
local workflow_name=$(echo "$output" | grep -o 'workflow.argoproj.io/[^ ]*' | cut -d'/' -f2)
|
|
echo -e "${GREEN}Workflow submitted successfully: ${workflow_name}${NC}"
|
|
echo ""
|
|
echo "Commands to monitor the build:"
|
|
echo " Watch logs: kubectl logs -n argo -f ${workflow_name}"
|
|
echo " Check status: kubectl get workflow -n argo ${workflow_name}"
|
|
echo " View details: kubectl describe workflow -n argo ${workflow_name}"
|
|
echo ""
|
|
echo "To see real-time build progress:"
|
|
echo " kubectl logs -n argo -f ${workflow_name} -c main"
|
|
return 0
|
|
else
|
|
echo -e "${RED}Failed to submit workflow${NC}" >&2
|
|
echo "$output" >&2
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# Main execution
|
|
main() {
|
|
echo -e "${GREEN}=== Temporal Worker Build Script ===${NC}"
|
|
echo ""
|
|
|
|
# Check if we're in a git repository
|
|
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
|
echo -e "${RED}Error: Not in a git repository${NC}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Get latest SHA
|
|
echo "Getting latest commit SHA..."
|
|
SHA=$(get_latest_sha)
|
|
echo "Latest commit: ${SHA}"
|
|
echo ""
|
|
|
|
# Check working directory
|
|
check_working_directory
|
|
|
|
# Check if commit is pushed
|
|
echo "Checking if commit is pushed to remote..."
|
|
check_commit_pushed "$SHA"
|
|
echo -e "${GREEN}✓ Commit is pushed to remote${NC}"
|
|
echo ""
|
|
|
|
# Show commit info
|
|
echo "Commit details:"
|
|
git log -1 --oneline "$SHA"
|
|
echo ""
|
|
|
|
# Create workflow YAML
|
|
WORKFLOW_FILE=$(create_workflow_yaml "$SHA")
|
|
echo "Created workflow file: $WORKFLOW_FILE"
|
|
echo ""
|
|
|
|
# Submit workflow
|
|
if submit_workflow "$WORKFLOW_FILE"; then
|
|
echo ""
|
|
echo -e "${GREEN}✓ Build workflow started successfully${NC}"
|
|
|
|
# Clean up
|
|
rm -f "$WORKFLOW_FILE"
|
|
else
|
|
echo ""
|
|
echo -e "${RED}✗ Failed to start build workflow${NC}"
|
|
echo "Workflow file preserved at: $WORKFLOW_FILE"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Parse command line arguments
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
--no-latest)
|
|
SET_LATEST="false"
|
|
shift
|
|
;;
|
|
--help|-h)
|
|
echo "Usage: $0 [OPTIONS]"
|
|
echo ""
|
|
echo "Options:"
|
|
echo " --no-latest Don't set the 'latest' tag on successful build"
|
|
echo " --help, -h Show this help message"
|
|
echo ""
|
|
echo "This script will:"
|
|
echo " 1. Get the latest commit SHA from your local repository"
|
|
echo " 2. Verify the commit is pushed to GitHub"
|
|
echo " 3. Submit a temporal worker build workflow to Argo"
|
|
echo " 4. Provide commands to monitor the build progress"
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo -e "${RED}Unknown option: $1${NC}" >&2
|
|
echo "Use --help for usage information"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Run main function
|
|
main |