Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions docs/dev_onborading.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@

- **Goal**: Run and develop CI tests for **NFS-Ganesha** using the `sanity_dev` Jenkins job.
- **Key pieces**:
- `jobs/distributed_test_runner/sanity_dev.groovy` – defines the Jenkins job & parameters.
- `jobs/jjb/dev_sanity.yaml` – defines the Jenkins job & parameters.
- `jobs/Jenkinsfile.sanity_dev` – actual pipeline (checkout, install, run tests).
- `tests/dev_space/` – dev-focused pytest suites (e.g. `test_fsal.py`).
- `ci_utils/` – shared Python helpers.
- `ci_utils/dev_space/` – dev-only helpers (dependencies, node reservation, etc.).
- **Sanity dev pipeline**: [`sanity_dev` Jenkins job](https://jenkins-nfs-ganesha.apps.ocp.cloud.ci.centos.org/view/all/job/sanity_dev/)
- **Sanity dev pipeline**: [`dev-sanity-tests` Jenkins job](https://jenkins-nfs-ganesha.apps.ocp.cloud.ci.centos.org/view/all/job/dev-sanity-tests/)

---

## How the Jenkins Job Works

- **Job definition (`sanity_dev.groovy`)**
- **Job definition (`dev_sanity.yaml`)**
- **Defines parameters**:
- **`TEST_SUITE`**: which test file to run (e.g. `test_fsal` → `test_fsal.py`).
- **`SERVER_NODE_COUNT`**, **`CLIENT_NODE_COUNT`**: how many nodes to reserve.
- **`CI_REPO`/`CI_BRANCH`**: repo/branch for this CI framework (default is this repo).
- **`GIT_REPO`/`GIT_BRANCH`**: NFS-Ganesha source to test.
- **`CMAKE_FLAGS`**, **`CMAKE_OVERRIDE`**: extra/override CMake options.
- **`CENTOS_VERSION`**, **`CENTOS_ARCH`**: OS/arch to use.
Expand Down Expand Up @@ -72,7 +71,7 @@ Use this pattern (fixtures + managers from `ci_utils`) for any new dev tests.
## Typical Dev Workflow

- **To run via Jenkins**:
- Open **`sanity_dev`** job.
- Open **`dev-sanity-tests`** job.
- Set:
- **`TEST_SUITE`**: e.g. `test_fsal`.
- **Node counts**: `SERVER_NODE_COUNT`, `CLIENT_NODE_COUNT`.
Expand All @@ -93,7 +92,7 @@ Use this pattern (fixtures + managers from `ci_utils`) for any new dev tests.
- Reserve nodes, connect via SSH, setup backends, run tests.

- **2. Wire it up in Jenkins**
- In `jobs/distributed_test_runner/sanity_dev.groovy`:
- In `jobs/jjb/dev_sanity.yaml`:
- Add your test suite name to `TEST_SUITE` choices (e.g. `'test_newbackend'`).
- In `jobs/Jenkinsfile.sanity_dev`:
- Make sure `pytest` call matches the pattern:
Expand Down
155 changes: 155 additions & 0 deletions docs/github_actions_workflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# GitHub Actions Workflow - Quick Guide

## Overview

This repository uses GitHub Actions to automatically validate and deploy Jenkins Job Builder (JJB) configurations.

**Two Workflows:**
1. **Validation** (`test.yaml`) - Runs on Pull Requests
2. **Deployment** (`deploy.yaml`) - Runs on merge to `centos-ci` branch

---

## Workflow Architecture

![Workflow Diagram](../docs/images/github_actions_flow.png)

**Simple Flow:**
```
Developer → Pull Request → test.yaml (Validate) → Merge → deploy.yaml (Deploy) → Jenkins Updated
```

---

## 1. Validation Workflow (`test.yaml`)

**Trigger:** Pull Request to any branch

**What it does:**
- Builds Docker container with JJB
- Validates YAML syntax
- Checks macro references
- **Does NOT** connect to Jenkins

**File:** `.github/workflows/test.yaml`

```yaml
on:
pull_request:
branches: ['*']
steps:
- Checkout code
- Build Docker image
- Run: jenkins-jobs test (validation only)
```

---

## 2. Deployment Workflow (`deploy.yaml`)

**Trigger:** Push to `centos-ci` branch

**What it does:**
- Builds Docker container with JJB
- Injects Jenkins API key
- Connects to Jenkins
- Creates/updates jobs

**File:** `.github/workflows/deploy.yaml`

```yaml
on:
push:
branches: ['centos-ci']
steps:
- Checkout code
- Build Docker image
- Run: jenkins-jobs update (actual deployment)
```

---

## Supporting Files

### `tests/Containerfile`
Docker image with JJB installed

### `tests/verify-yaml.sh`
```bash
jenkins-jobs test globals/macros:jobs
```
Validates syntax without Jenkins connection

### `tests/deploy-nfs-ganesha-ci.sh`
```bash
sed "s/JENKINS_API_KEY/$JENKINS_API_KEY/g" tests/jenkins.conf > jobs/jenkins.ini
jenkins-jobs --conf jobs/jenkins.ini update jobs/:globals/macros/
```
Injects API key and deploys to Jenkins

### `tests/jenkins.conf`
JJB configuration template with API key placeholder

### `globals/macros/macros.yml`
Reusable JJB templates (SCM, parameters, triggers, etc.)

### `jobs/jjb/*.yaml`
Jenkins job definitions using JJB format

---

## How Files Work Together

```
Pull Request
test.yaml → Containerfile → verify-yaml.sh → JJB (test mode)
Validation Result → PR Status Check

Merge to centos-ci
deploy.yaml → Containerfile → deploy-nfs-ganesha-ci.sh
jenkins.conf + API Key → JJB (update mode)
macros.yml + jobs/jjb/*.yaml → Jenkins API
Jobs Created/Updated in Jenkins
```

---

## Testing Locally

```bash
# 1. Build container
docker build -t nfs-ganesha-ci-tests -f tests/Containerfile .

# 2. Test validation (like test.yaml)
docker run --rm nfs-ganesha-ci-tests:latest

# 3. Generate XML preview
docker run --rm -v $(pwd)/output:/output nfs-ganesha-ci-tests:latest sh -c \
"jenkins-jobs test globals/macros:jobs/jjb -o /output --config-xml"

# 4. View generated XML
cat output/*/config.xml

# 5. Deploy to Jenkins (requires API key)
docker run --rm --env="JENKINS_API_KEY=your-token" \
--entrypoint=tests/deploy-nfs-ganesha-ci.sh \
nfs-ganesha-ci-tests:latest
```

---

## Quick Reference

**Jenkins Server:** https://jenkins-nfs-ganesha.apps.ocp.cloud.ci.centos.org

**Test locally:** `docker run --rm nfs-ganesha-ci-tests:latest`

**Deploy:** Push to `centos-ci` branch

**Monitor:** https://github.com/nfs-ganesha/ci-tests/actions
Binary file added docs/images/github_actions_flow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions globals/macros/macros.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
skip-tag: true
shallow-clone: true
url: https://github.com/nfs-ganesha/ci-tests.git
basedir: "$WORKSPACE/ci-tests"
basedir: "ci-tests"

- builder:
name: get-node
Expand Down Expand Up @@ -56,7 +56,7 @@
exclude-drafts: true
exclude-no-code-change: true
- comment-added-contains-event:
comment-contains-value: 'recheck {option}'
comment-contains-value: '(?i)recheck {option}'
projects:
- project-compare-type: PLAIN
project-pattern: 'ffilz/nfs-ganesha'
Expand Down Expand Up @@ -103,6 +103,10 @@
default: refs/heads/next
description: Git reference to fetch from the Gerrit project.
name: GERRIT_REFSPEC
- string:
name: GERRIT_USER
default: jenkins-glusterorg
description: Gerrit user to comment with

- parameter:
name: centos_variables
Expand Down
10 changes: 0 additions & 10 deletions jobs/Jenkinsfile.sanity_dev
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ pipeline {

stages {

stage('Checkout CI Tests') {
steps {
echo "Cloning CI repo: ${params.CI_REPO} (${params.CI_BRANCH})"

dir('ci-tests') {
git url: params.CI_REPO, branch: params.CI_BRANCH
}
}
}

stage('Checkout NFS-Ganesha') {
steps {
echo "Cloning Ganesha repo: ${params.GIT_REPO} (${params.GIT_BRANCH})"
Expand Down
93 changes: 0 additions & 93 deletions jobs/distributed_test_runner/sanity_dev.groovy

This file was deleted.

Loading