|
| 1 | +# TunaOS Build Pipeline Guide |
| 2 | + |
| 3 | +This document provides a comprehensive overview of the CI/CD pipeline for TunaOS. The pipeline is designed to be automated, robust, and secure, moving images through a defined promotion strategy from `next` to `testing` to `stable`. |
| 4 | + |
| 5 | +## 🏗️ Architecture Overview |
| 6 | + |
| 7 | +The pipeline consists of three main stages, corresponding to the three channels: |
| 8 | + |
| 9 | +1. **Next (`:next`)**: The bleeding edge. Built frequently (on push to main or schedule). |
| 10 | +2. **Testing (`:testing`)**: The candidate for release. Promoted weekly after passing automated QA. |
| 11 | +3. **Stable (`:stable`)**: The official release. Promoted from testing via Git tags. |
| 12 | + |
| 13 | +### Concepts |
| 14 | + |
| 15 | +- **Variants**: Different OS bases. |
| 16 | + - `albacore` (AlmaLinux) |
| 17 | + - `yellowfin` (AlmaLinux Kitten) |
| 18 | +- **Flavors**: Different package sets. |
| 19 | + - `base`: Minimal OS. |
| 20 | + - `dx`: Developer Experience (includes dev tools). |
| 21 | + - `gdx`: Graphical Developer Experience (includes desktop environment). |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## 🔄 Workflows |
| 26 | + |
| 27 | +### 1. Build Next Image (`build-next.yml`) |
| 28 | + |
| 29 | +This is the primary build workflow. |
| 30 | + |
| 31 | +- **Triggers**: |
| 32 | + - Push to `main`. |
| 33 | + - Schedule (Daily). |
| 34 | + - Manual `workflow_dispatch`. |
| 35 | +- **Process**: |
| 36 | + 1. **Matrix Generation**: Dynamically generates a build matrix for all Variant/Flavor combinations. |
| 37 | + 2. **Build**: Uses `reusable-build-image.yml` to build the container images. |
| 38 | + 3. **Push**: Pushes images to GHCR with the `:next` tag. |
| 39 | +- **Key Features**: |
| 40 | + - **Chaining**: Builds `base` first, then uses it as the base for `dx`, and `dx` for `gdx`. |
| 41 | + |
| 42 | +### 2. Pull Request Checks (`reusable-build-image.yml`) |
| 43 | + |
| 44 | +When a Pull Request is opened, the build workflow runs in a special mode. |
| 45 | + |
| 46 | +- **Triggers**: Pull Request events. |
| 47 | +- **Process**: |
| 48 | + 1. Builds the image from the PR code. |
| 49 | + 2. **Image Diff**: Pulls the current `:next` image and compares it with the PR image. |
| 50 | + 3. **Reporting**: Posts a comment on the PR detailing: |
| 51 | + - Added/Removed/Upgraded RPM packages. |
| 52 | + - File changes in `/usr` and `/etc`. |
| 53 | + |
| 54 | +### 3. Promote to Testing (`promote-to-testing.yml`) |
| 55 | + |
| 56 | +This workflow manages the promotion from `next` to `testing`. |
| 57 | + |
| 58 | +- **Triggers**: |
| 59 | + - Schedule (Weekly, e.g., Mondays). |
| 60 | + - Manual `workflow_dispatch`. |
| 61 | +- **Process**: |
| 62 | + 1. **Candidate Selection**: Identifies the latest successful `build-next` run. |
| 63 | + 2. **QA & Verification**: |
| 64 | + - **SBOM**: Generates a Software Bill of Materials using `syft`. |
| 65 | + - **QEMU Boot Test**: Builds a QCOW2 disk image from the container and boots it in QEMU to verify system integrity. |
| 66 | + 3. **Manual Gate**: Pauses for approval in the `manual-approval` Environment. |
| 67 | + 4. **Promotion**: Upon approval, retags the specific image digest to `:testing`. |
| 68 | + 5. **Summary**: Outputs a summary of promoted images. |
| 69 | + |
| 70 | +### 4. Release Stable (`release-stable.yml`) |
| 71 | + |
| 72 | +This workflow handles the final release. |
| 73 | + |
| 74 | +- **Triggers**: |
| 75 | + - Push of a tag matching `*-YYYYMMDD.x` (e.g., `albacore-20251126.0`). |
| 76 | +- **Process**: |
| 77 | + 1. **Validation**: Parses the tag to identify the Variant/Flavor. |
| 78 | + 2. **Artifact Generation**: Builds a QCOW2 disk image from the `:testing` image. |
| 79 | + 3. **Upload**: Uploads the QCOW2 to S3. |
| 80 | + 4. **Promotion**: Retags the `:testing` image to `:stable` and the versioned tag (e.g., `:20251126.0`). |
| 81 | + |
| 82 | +--- |
| 83 | + |
| 84 | +## 🛠️ Scripts & Tools |
| 85 | + |
| 86 | +The pipeline relies on several helper scripts in the `scripts/` directory: |
| 87 | + |
| 88 | +- **`diff-images.sh`**: Compares two container images and outputs a Markdown report of RPM and file differences. Used in PR checks. |
| 89 | +- **`build-bootc-diskimage.sh`**: A wrapper around `bootc-image-builder` to generate disk images (QCOW2, ISO, etc.) from container images. Requires privileged mode. |
| 90 | +- **`qemu-test.sh`**: Boots a QCOW2 image in QEMU and waits for the SSH port to become active, verifying the image is bootable. |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +## 📖 How-To Guides |
| 95 | + |
| 96 | +### How to Manually Trigger a Build |
| 97 | +1. Go to **Actions** tab in GitHub. |
| 98 | +2. Select **Build Next Image**. |
| 99 | +3. Click **Run workflow**. |
| 100 | +4. Optionally select specific Variants or Flavors. |
| 101 | + |
| 102 | +### How to Approve a Promotion |
| 103 | +1. When `promote-to-testing` runs, it will pause at the "Promote to Testing" job. |
| 104 | +2. Click **Review deployments**. |
| 105 | +3. Check the **Promotion Candidate** summary in the workflow run. |
| 106 | +4. Click **Approve and deploy**. |
| 107 | + |
| 108 | +### How to Cut a Stable Release |
| 109 | +1. Ensure the `:testing` image is the one you want to release. |
| 110 | +2. Create and push a git tag: |
| 111 | + ```bash |
| 112 | + git tag albacore-20251126.0 |
| 113 | + git push origin albacore-20251126.0 |
| 114 | + ``` |
| 115 | +3. The `release-stable` workflow will trigger automatically. |
0 commit comments