|
| 1 | +# OpenHPC Continuous Integration (CI) Tools |
| 2 | + |
| 3 | +This directory contains scripts, tools, and configurations used for OpenHPC's continuous integration and testing infrastructure. These tools automate building, testing, and validation of OpenHPC components across multiple distributions and architectures. |
| 4 | + |
| 5 | +## Core CI Scripts |
| 6 | + |
| 7 | +### `run_build.py` |
| 8 | +**Purpose**: Main CI build script that handles OpenHPC package building and testing. |
| 9 | + |
| 10 | +**Features**: |
| 11 | +- Builds source RPMs (SRPMs) and binary RPMs from spec files |
| 12 | +- Supports multiple compiler families (GNU, Intel, ARM, LLVM) |
| 13 | +- Handles multiple MPI implementations (OpenMPI, MPICH, MVAPICH2, Intel MPI) |
| 14 | +- Automatic dependency resolution using `dnf builddep` or `zypper source-install` |
| 15 | +- Detects MPI-dependent and compiler-dependent packages automatically |
| 16 | +- Retry logic for network operations |
| 17 | +- Special handling for architecture-specific builds |
| 18 | + |
| 19 | +**Usage**: |
| 20 | +```bash |
| 21 | +# Build with default gnu15 compiler and openmpi5 MPI |
| 22 | +./run_build.py ohpc-user path/to/component.spec |
| 23 | + |
| 24 | +# Specify compiler family |
| 25 | +./run_build.py ohpc-user --compiler-family=intel path/to/component.spec |
| 26 | + |
| 27 | +# Specify MPI family |
| 28 | +./run_build.py ohpc-user --mpi-family=mpich path/to/component.spec |
| 29 | +``` |
| 30 | + |
| 31 | +**Environment Variables**: |
| 32 | +- `SKIP_CI_SPECS`: Space-separated list of spec files to skip during CI |
| 33 | + |
| 34 | +### `check_spec.py` |
| 35 | +**Purpose**: Validates OpenHPC spec files against project coding standards and conventions. |
| 36 | + |
| 37 | +**Validation Rules**: |
| 38 | +- **Forbidden patterns**: Source42, OHPC_macros in Source lines, %changelog, DocDir, BuildRoot, %defattr, global PROJ_DELIM |
| 39 | +- **Required elements**: Proper Group designation with %{PROJ_NAME}, URL field |
| 40 | + |
| 41 | +**Usage**: |
| 42 | +```bash |
| 43 | +./check_spec.py path/to/component1.spec path/to/component2.spec |
| 44 | +``` |
| 45 | + |
| 46 | +### `spec_to_test_mapping.py` |
| 47 | +**Purpose**: Creates mapping between spec files and their corresponding test suites for automated testing. |
| 48 | + |
| 49 | +**Features**: |
| 50 | +- Maps spec files to test configure options (`--enable-*`) |
| 51 | +- Identifies required packages for testing |
| 52 | +- Handles admin tests vs. user tests |
| 53 | +- Supports compiler family substitution in package names |
| 54 | +- OS-specific Python prefix handling (python3 vs python311 vs python3.11) |
| 55 | + |
| 56 | +**Usage**: |
| 57 | +```bash |
| 58 | +./spec_to_test_mapping.py --compiler-family=gnu15 components/libs/fftw/SPECS/fftw.spec |
| 59 | +# Output: TESTS=(--enable-fftw) ADMIN_TESTS=() PKGS=() |
| 60 | +``` |
| 61 | + |
| 62 | +## Environment Setup Scripts |
| 63 | + |
| 64 | +### `prepare-ci-environment.sh` |
| 65 | +**Purpose**: Configures CI environment with necessary dependencies and repositories. |
| 66 | + |
| 67 | +**Features**: |
| 68 | +- Multi-distribution support (RHEL/Rocky/AlmaLinux, SUSE/openSUSE, openEuler) |
| 69 | +- Automatic package manager detection (dnf vs zypper) |
| 70 | +- OpenHPC repository configuration |
| 71 | +- Intel OneAPI toolkit integration |
| 72 | +- Environment information reporting for debugging |
| 73 | + |
| 74 | +**Usage**: |
| 75 | +```bash |
| 76 | +# Basic setup |
| 77 | +./prepare-ci-environment.sh |
| 78 | + |
| 79 | +# Enable Intel OneAPI |
| 80 | +./prepare-ci-environment.sh intel |
| 81 | + |
| 82 | +# Pre-release mode (skip OHPC_RELEASE) |
| 83 | +./prepare-ci-environment.sh --pre-release |
| 84 | +``` |
| 85 | + |
| 86 | +### `setup_slurm_and_run_tests.sh` |
| 87 | +**Purpose**: Sets up Slurm cluster simulation and executes OpenHPC test suite. |
| 88 | + |
| 89 | +**Features**: |
| 90 | +- Multi-node Slurm cluster simulation (node0, node1) |
| 91 | +- MUNGE authentication setup |
| 92 | +- Test suite configuration and execution |
| 93 | +- Package installation from rebuilt RPMs |
| 94 | +- Comprehensive logging and error reporting |
| 95 | + |
| 96 | +**Usage**: |
| 97 | +```bash |
| 98 | +./setup_slurm_and_run_tests.sh ohpc-user gnu15 components/libs/fftw/SPECS/fftw.spec |
| 99 | +``` |
| 100 | + |
| 101 | +## Utility Scripts |
| 102 | + |
| 103 | +### `cirrus_get_changed_files.sh` |
| 104 | +**Purpose**: Retrieves list of changed files from GitHub pull requests for Cirrus CI. |
| 105 | + |
| 106 | +**Features**: |
| 107 | +- GitHub API integration |
| 108 | +- Multi-commit PR support |
| 109 | +- Deleted file handling |
| 110 | +- Requires `CIRRUS_PR`, `CIRRUS_REPO_OWNER`, `CIRRUS_REPO_NAME` environment variables |
| 111 | + |
| 112 | +**Usage**: |
| 113 | +```bash |
| 114 | +export CIRRUS_PR=123 |
| 115 | +export CIRRUS_REPO_OWNER=openhpc |
| 116 | +export CIRRUS_REPO_NAME=ohpc |
| 117 | +./cirrus_get_changed_files.sh |
| 118 | +``` |
| 119 | + |
| 120 | +## Test Suites |
| 121 | + |
| 122 | +### `test_parse_doc.bats` |
| 123 | +**Purpose**: BATS test suite for validating documentation parsing scripts. |
| 124 | + |
| 125 | +**Test Coverage**: |
| 126 | +- LaTeX macro substitution (install, chrootinstall, etc.) |
| 127 | +- Variable replacement (ARCH, TAG, OSTREE, BASEURL, OSNAME) |
| 128 | +- Input file handling and nested includes |
| 129 | +- HERE document processing |
| 130 | +- Line continuation handling |
| 131 | +- Comment and indentation processing |
| 132 | +- CI-only command filtering |
| 133 | +- Error handling for missing files/macros |
| 134 | + |
| 135 | +**Usage**: |
| 136 | +```bash |
| 137 | +# Test Perl implementation (default) |
| 138 | +bats test_parse_doc.bats |
| 139 | + |
| 140 | +# Test Python implementation |
| 141 | +PARSE_DOC_TEST_IMPL=python bats test_parse_doc.bats |
| 142 | +``` |
| 143 | + |
| 144 | +## Build Automation |
| 145 | + |
| 146 | +### `Makefile` |
| 147 | +**Purpose**: Provides build targets for CI tasks and linting operations. |
| 148 | + |
| 149 | +**Key Targets**: |
| 150 | +- `clang-format-lint`: Code formatting validation using clang-format |
| 151 | +- `build-ohpc-ci`: Build OHPC lint container locally with podman |
| 152 | + |
| 153 | +**Usage**: |
| 154 | +```bash |
| 155 | +# Run clang-format linting |
| 156 | +make -C tests/ci clang-format-lint |
| 157 | + |
| 158 | +# Build lint container locally |
| 159 | +make -C tests/ci build-ohpc-ci |
| 160 | +``` |
| 161 | + |
| 162 | +### `Containerfile.ohpc-lint` |
| 163 | +**Purpose**: Container definition for OpenHPC linting and code quality tools. |
| 164 | + |
| 165 | +**Included Tools**: |
| 166 | +- **codespell**: Spell checking for code |
| 167 | +- **ruff**: Python linting and formatting |
| 168 | +- **ShellCheck**: Shell script analysis |
| 169 | +- **shfmt**: Shell script formatting |
| 170 | +- **clang-tools-extra**: C/C++ code analysis tools |
| 171 | +- **make**: Build automation |
| 172 | +- **git**: Version control operations |
| 173 | + |
| 174 | +**Usage**: |
| 175 | +```bash |
| 176 | +# Build container |
| 177 | +podman build -f Containerfile.ohpc-lint -t ghcr.io/openhpc/ohpc-lint:latest |
| 178 | + |
| 179 | +# Use in CI (automatic via GitHub Actions) |
| 180 | +``` |
| 181 | + |
| 182 | +## CI Workflow Integration |
| 183 | + |
| 184 | +These tools are designed to work together in CI pipelines: |
| 185 | + |
| 186 | +1. **Environment Setup**: `prepare-ci-environment.sh` configures the build environment |
| 187 | +2. **File Detection**: `cirrus_get_changed_files.sh` identifies modified files |
| 188 | +3. **Spec Validation**: `check_spec.py` validates spec file standards |
| 189 | +4. **Package Building**: `run_build.py` builds and tests packages |
| 190 | +5. **Test Mapping**: `spec_to_test_mapping.py` determines required tests |
| 191 | +6. **Test Execution**: `setup_slurm_and_run_tests.sh` runs comprehensive tests |
| 192 | +7. **Documentation Testing**: `test_parse_doc.bats` validates documentation parsing |
| 193 | + |
| 194 | +## Environment Variables |
| 195 | + |
| 196 | +### Global CI Configuration |
| 197 | +- `SKIP_CI_SPECS`: Space-separated list of spec files to skip |
| 198 | +- `SIMPLE_CI`: Set to 1 for simplified CI mode |
| 199 | +- `PARSE_DOC_TEST_IMPL`: Set to "python" to test Python parse_doc implementation |
| 200 | + |
| 201 | +### Cirrus CI Specific |
| 202 | +- `CIRRUS_PR`: Pull request number |
| 203 | +- `CIRRUS_REPO_OWNER`: Repository owner (e.g., "openhpc") |
| 204 | +- `CIRRUS_REPO_NAME`: Repository name (e.g., "ohpc") |
| 205 | + |
| 206 | +## Supported Platforms |
| 207 | + |
| 208 | +- **RHEL/Rocky/AlmaLinux**: EL8, EL9, EL10 |
| 209 | +- **SUSE/openSUSE**: Leap 15.x, Tumbleweed |
| 210 | +- **openEuler**: 22.03, 24.03 |
| 211 | +- **Architectures**: x86_64, aarch64 |
| 212 | + |
| 213 | +## Error Handling and Debugging |
| 214 | + |
| 215 | +All scripts include comprehensive error handling and logging: |
| 216 | +- Retry logic for network operations |
| 217 | +- Detailed environment reporting |
| 218 | +- Log file collection and reporting |
| 219 | +- Architecture-specific workarounds (e.g., single-threaded builds for ARM64) |
| 220 | + |
| 221 | +## Contributing |
| 222 | + |
| 223 | +When adding new components or modifying CI behavior: |
| 224 | +1. Update `spec_to_test_mapping.py` for new testable components |
| 225 | +2. Add any new forbidden patterns to `check_spec.py` |
| 226 | +3. Update environment setup in `prepare-ci-environment.sh` for new dependencies |
| 227 | +4. Add tests to `test_parse_doc.bats` for documentation parsing changes |
0 commit comments