Skip to content

Commit

Permalink
Merge pull request #82 from scality/improvement/COSI-53-misc-ci-impro…
Browse files Browse the repository at this point in the history
…vements

COSI-53: Optimize CI Workflows, Mono-Repo Migration, and Enhancements
  • Loading branch information
anurag4DSB authored Jan 7, 2025
2 parents a9cf51d + 9c4e7f0 commit 004bebe
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 47 deletions.
7 changes: 3 additions & 4 deletions .github/scripts/cleanup_cosi_resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ trap 'error_handler' ERR

log_and_run() {
echo "Running: $*" | tee -a "$LOG_FILE"
"$@" | tee -a "$LOG_FILE"
"$@" 2>&1 | tee -a "$LOG_FILE"
}

log_and_run echo "Removing COSI driver manifests and namespace..."
Expand Down Expand Up @@ -62,9 +62,8 @@ log_and_run kubectl delete -f cosi-examples/greenfield/bucketclass-deletion-poli
log_and_run echo "Deleting s3-secret-for-cosi secret..."
log_and_run kubectl delete secret s3-secret-for-cosi --namespace=default || { echo "Secret s3-secret-for-cosi not found." | tee -a "$LOG_FILE"; }

log_and_run echo "Deleting COSI CRDs..."
log_and_run kubectl delete -k github.com/kubernetes-sigs/container-object-storage-interface-api || { echo "COSI API CRDs not found." | tee -a "$LOG_FILE"; }
log_and_run kubectl delete -k github.com/kubernetes-sigs/container-object-storage-interface-controller || { echo "COSI Controller CRDs not found." | tee -a "$LOG_FILE"; }
log_and_run echo "Deleting COSI CRD..."
log_and_run kubectl delete -k github.com/kubernetes-sigs/container-object-storage-interface || { echo "COSI API CRDs or controller not found." | tee -a "$LOG_FILE"; }

log_and_run echo "Verifying COSI CRDs deletion..."
if kubectl get crd | grep 'container-object-storage-interface' &>/dev/null; then
Expand Down
5 changes: 4 additions & 1 deletion .github/scripts/e2e_tests_greenfield_use_case.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ trap 'error_handler' ERR
# Log command execution to the log file for debugging
log_and_run() {
echo "Running: $*" | tee -a "$LOG_FILE"
"$@" | tee -a "$LOG_FILE"
if ! "$@" 2>&1 | tee -a "$LOG_FILE"; then
echo "Error: Command failed - $*" | tee -a "$LOG_FILE"
exit 1
fi
}

# Step 1: Create Account in Vault
Expand Down
12 changes: 6 additions & 6 deletions .github/scripts/setup_cosi_resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ trap 'error_handler' ERR
# Log command execution to the log file for debugging
log_and_run() {
echo "Running: $*" | tee -a "$LOG_FILE"
if ! "$@" | tee -a "$LOG_FILE"; then
if ! "$@" 2>&1 | tee -a "$LOG_FILE"; then
echo "Error: Command failed - $*" | tee -a "$LOG_FILE"
exit 1
fi
}

# Step 1: Install COSI CRDs
log_and_run echo "Installing COSI CRDs..."
log_and_run kubectl create -k github.com/kubernetes-sigs/container-object-storage-interface-api
log_and_run kubectl create -k github.com/kubernetes-sigs/container-object-storage-interface-controller
log_and_run echo "Installing COSI CRD..."
log_and_run kubectl create -k github.com/kubernetes-sigs/container-object-storage-interface
log_and_run kubectl get pods --namespace container-object-storage-system

# Step 2: Verify COSI Controller Pod Status
log_and_run echo "Verifying COSI Controller Pod status..."
if ! kubectl wait --namespace default --for=condition=ready pod -l app.kubernetes.io/name=container-object-storage-interface-controller --timeout=10s; then
if ! kubectl wait --namespace container-object-storage-system --for=condition=ready pod -l app.kubernetes.io/name=container-object-storage-interface-controller --timeout=60s; then
echo "Error: COSI Controller pod did not reach ready state." | tee -a "$LOG_FILE"
exit 1
fi
log_and_run kubectl get pods --namespace default
log_and_run kubectl get pods --namespace container-object-storage-system

# Step 3: Build COSI driver Docker image
log_and_run echo "Building COSI driver image..."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI Build and Unit Tests
name: Build & Unit Tests

on:
push:
Expand Down Expand Up @@ -26,6 +26,9 @@ jobs:
- name: Install dependencies
run: go mod tidy

- name: Set GOCOVERDIR
run: echo "GOCOVERDIR=/home/runner/work/cosi-driver/cosi-driver" >> $GITHUB_ENV

- name: Run tests
run: make test

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI End-to-End Tests
name: End to End Feature Tests

on:
push:
Expand All @@ -20,10 +20,27 @@ on:
jobs:
e2e-tests-with-kind:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Login to Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: "${{ github.repository_owner }}"
password: "${{ github.token }}"

- name: Restore Cached Docker Images
id: cache_docker_images
uses: actions/cache@v4
with:
path: /tmp/.docker_cache
key: docker-${{ runner.os }}-${{ hashFiles('.github/s3_and_iam_deployment/.env') }}
restore-keys: |
docker-${{ runner.os }}-
- name: Create k8s KIND Cluster
uses: helm/[email protected]
with:
Expand All @@ -36,50 +53,45 @@ jobs:
kubectl cluster-info
kubectl get nodes
- name: Setup COSI, S3 and IAM environments
run: |
set -e -o pipefail
(
echo "=== Setup COSI Controller, CRDs and Driver ==="
.github/scripts/setup_cosi_resources.sh
) &
(
echo "=== Loading cached S3 and IAM Docker images ==="
if [ -d /tmp/.docker_cache ] && [ "$(ls -A /tmp/.docker_cache 2>/dev/null)" ]; then
for image in /tmp/.docker_cache/*.tar; do
docker load -i "$image" || true # continue on failure
done
else
echo "No cached images found. Skipping load."
fi
) &
# Wait for both background processes
wait
- name: "Debug: SSH to runner"
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
uses: scality/actions/action-ssh-to-runner@v1
with:
tmate-server-host: ${{ secrets.TMATE_SERVER_HOST }}
tmate-server-port: ${{ secrets.TMATE_SERVER_PORT }}
tmate-server-rsa-fingerprint: ${{ secrets.TMATE_SERVER_RSA_FINGERPRINT }}
tmate-server-ed25519-fingerprint: ${{ secrets.TMATE_SERVER_ED25519_FINGERPRINT }}
detached: true
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
timeout-minutes: 10
continue-on-error: true

- name: Setup COSI Controller, CRDs and Driver
run: |
pwd
.github/scripts/setup_cosi_resources.sh
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: "${{ github.repository_owner }}"
password: "${{ github.token }}"

- name: Restore Cached Docker Images
id: cache_docker_images
uses: actions/cache@v4
with:
path: /tmp/.docker_cache
key: docker-${{ runner.os }}-${{ hashFiles('.github/s3_and_iam_deployment/.env') }}
restore-keys: |
docker-${{ runner.os }}-
- name: Load Cached Images
run: |
for image in /tmp/.docker_cache/*.tar; do
docker load -i "$image" || true
done
continue-on-error: true

- name: Setup IAM and S3 Services
run: |-
set -e -o pipefail;
mkdir -p logs/s3 logs/iam logs/cosi_driver data/vaultdb && chown -R runner:docker logs data && chmod -R ugo+rwx logs data
mkdir -p logs/s3 logs/iam logs/cosi_driver data/vaultdb
chown -R runner:docker logs data
chmod -R ugo+rwx logs data
docker compose --profile iam_s3 up -d --quiet-pull
bash ../scripts/wait_for_local_port.bash 8600 30
bash ../scripts/wait_for_local_port.bash 8000 30
Expand Down Expand Up @@ -116,28 +128,28 @@ jobs:
working-directory: .github/s3_and_iam_deployment

- name: Move S3 and IAM logs and data to artifacts directory
if: always()
run: |-
set -e -o pipefail;
mkdir -p .github/e2e_tests/artifacts/logs .github/e2e_tests/artifacts/data
cp -r .github/s3_and_iam_deployment/logs/* .github/e2e_tests/artifacts/logs/
cp -r .github/s3_and_iam_deployment/data/* .github/e2e_tests/artifacts/data/
if: always()
- name: Capture Kubernetes Logs in artifacts directory
if: always()
run: |
.github/scripts/capture_k8s_logs.sh
if: always()
- name: Cleanup COSI CRDs, Controller, and Driver
run: |
.github/scripts/cleanup_cosi_resources.sh
- name: Upload logs and data to Scality artifacts
if: always()
uses: scality/action-artifacts@v4
with:
method: upload
url: https://artifacts.scality.net
user: ${{ secrets.ARTIFACTS_USER }}
password: ${{ secrets.ARTIFACTS_PASSWORD }}
source: .github/e2e_tests/artifacts
if: always()
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI Smoke Tests
name: Helm Validation

on:
push:
Expand Down

0 comments on commit 004bebe

Please sign in to comment.