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
19 changes: 17 additions & 2 deletions core/skills/rh-qs-test-suite/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ description: |
**Category:** `github/`
**Reference implementation:** [it-self-service-agent](https://github.com/rh-ai-quickstart/it-self-service-agent) `.github/`

For image publishing, use the skill-local [build-and-push workflow reference](./references/build-and-push-workflow.yaml) as the canonical pattern. It replaces the external example for this workflow.

## Trigger

- Helm chart and Makefile deploy targets exist from **`rh-qs-deploy`** if not create it.
Expand All @@ -21,6 +23,15 @@ description: |

If the request is scoped to nightly testing specifically (e.g. "add nightly testing to `<slug>`", "update the nightly workflow", "refresh the nightly CI setup") rather than the full CI build-out, skip straight to it: resolve the slug/repo as usual, then invoke **`subagents/nightly-tests-prompt.md`** directly (`invocation_mode: standalone`) and report its result. Do not run the PR-checks/E2E/build-and-push phases for this request — they are unrelated to what was asked. This is the same subagent step 8 below delegates to; the only difference is you stop after it instead of continuing the rest of the workflow.

## Build-and-push-only fast path

If the request is scoped to image publishing specifically (e.g. "create only the build-and-push workflow", "update image publishing", "fix the build-and-push workflow") rather than the full CI build-out, resolve the quickstart repository and then invoke **`subagents/build-and-push-prompt.md`** directly (`invocation_mode: standalone`). Do not run the PR-checks/E2E/nightly/promotion phases for this request. This is the same subagent step 7 below delegates to; the only difference is you stop after it instead of continuing the rest of the workflow.

This is a hard scope gate: in standalone build-and-push mode, the only repository
file this path may create or update is `.github/workflows/build-and-push.yaml`.
Do not modify `Makefile`, `README.md`, Helm files, scripts, or any other
workflow merely to make the generated workflow work.

## What it does

1. Splits CI into **focused workflows** (quality, unit tests, Kind E2E, evals, image build) instead of one monolithic job
Expand All @@ -40,7 +51,7 @@ If the request is scoped to nightly testing specifically (e.g. "add nightly test
- [ ] 4. Add composite actions (prepare-runner, kind, inspect)
- [ ] 5. Add PR workflows (checks, e2e, branch policy — as needed)
- [ ] 6. Configure repo secrets/vars (see references/secrets-and-variables.md)
- [ ] 7. Add build-and-push on push to main/dev (if publishing images)
- [ ] 7. When publishing images, invoke `subagents/build-and-push-prompt.md` to add the self-contained workflow for push to main/dev and manual dispatch
- [ ] 8. When design requires nightly testing, invoke `subagents/nightly-tests-prompt.md`; add dev→main promotion workflow separately if needed
- [ ] 9. Register required status checks in branch protection
- [ ] 10. Open test PR and confirm all workflows green
Expand Down Expand Up @@ -68,7 +79,7 @@ If the request is scoped to nightly testing specifically (e.g. "add nightly test
| `pr-pip-install-build.yml` | `pull_request` | Validate alternate install path (`use_pip_install`) |
| `pr-evaluation-check.yml` | `pull_request_target` | Known-bad conversation / regression eval gate |
| `pr-branch-check.yml` | `pull_request` → `main` | Enforce `dev` or `dev-<sha>` source branch |
| `build-and-push.yaml` | `push` to `main`/`dev` | Build and push images to Quay (org-owned repos only) |
| `build-and-push.yaml` | `push` to `main`/`dev`, `workflow_dispatch` | Self-contained build and push using Makefile targets; validates OCI tags and supports `FORCE_BUILD_ALL=TRUE` on manual dispatch to override the optional image-needed target |
| `test-<slug>.yml` | `workflow_call`, `workflow_dispatch` | Reusable deploy + test + teardown against a real OpenShift namespace, via actions copied from `quickstart-ci-testing` — generated by `subagents/nightly-tests-prompt.md` |
| `nightly-main.yml` / `nightly-<dev-branch>.yml` | `schedule`, `workflow_dispatch` | Thin scheduled callers of `test-<slug>.yml`, one per long-lived branch — generated by `subagents/nightly-tests-prompt.md` |
| `create-dev-to-main-pr.yaml` | `workflow_dispatch` | Version-checked promotion PR with temp branch |
Expand Down Expand Up @@ -125,6 +136,8 @@ Implement these targets (names can alias existing ones):

Full list: [references/makefile-ci-contract.md](./references/makefile-ci-contract.md)

Build-and-push generation is delegated to [the dedicated prompt](./subagents/build-and-push-prompt.md). It resolves the version, build, and publish targets from the quickstart's Makefile and README, asks for missing or ambiguous mappings before writing anything, and never substitutes canonical target names for absent targets.

## Secrets and variables

Configure in GitHub **before** enabling `pull_request_target` E2E workflows:
Expand Down Expand Up @@ -194,4 +207,6 @@ When CI workflows are green on a test PR → **`rh-qs-verify-deploy`**, then **`
- [Secrets and variables](./references/secrets-and-variables.md)
- [Makefile CI contract](./references/makefile-ci-contract.md)
- [Workflow skeletons](./references/workflow-skeletons.md) — copy-paste YAML starters
- [Build-and-push workflow reference](./references/build-and-push-workflow.yaml) — canonical local workflow for automatic and manual image publishing
- [Build-and-push subagent](./subagents/build-and-push-prompt.md) — deterministic Make-target resolution and workflow generation
- [Nightly actions catalog](./references/nightly-actions-catalog.md) — `quickstart-ci-testing` actions, reusable test workflow + nightly caller skeletons, provisioning script (used by `subagents/nightly-tests-prompt.md`)
170 changes: 170 additions & 0 deletions core/skills/rh-qs-test-suite/references/build-and-push-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# Canonical local reference for rh-qs-test-suite image publishing.
# Adapt Make target names, variable names, REGISTRY, and toolchain setup to the
# quickstart's Makefile and README. Set IMAGE_REPOSITORIES to every image
# repository built by build-all-images, using fully qualified registry names.
# This workflow is self-contained; it is not a reusable workflow.
name: Build and push images

on:
push:
branches:
- main
- dev
workflow_dispatch:
inputs:
target_branch:
description: Branch whose images should be built
required: true
default: main
type: choice
options:
- main
- dev
force_build_all:
description: Build and publish every image even when the optional Make target says none are needed
required: true
default: 'FALSE'
type: choice
options:
- 'FALSE'
- 'TRUE'

concurrency:
group: ${{ github.workflow }}-${{ github.repository }}-${{ inputs.target_branch || github.ref_name }}
cancel-in-progress: false
queue: max

permissions:
contents: read

env:
REGISTRY: quay.io/rh-ai-quickstart
FORCE_BUILD_ALL: ${{ inputs.force_build_all || 'FALSE' }}
IMAGE_REPOSITORIES: "quay.io/rh-ai-quickstart/replace-with-image-name" # Space-separated; include every image built by the Makefile.
UV_VERSION: "0.8.9" # Replace with the quickstart's Makefile value when uv is used.
PYTHON_VERSION: "3.12" # Replace with the quickstart's required Python version.

jobs:
build-and-push:
if: github.repository_owner == 'rh-ai-quickstart' && github.event.repository.fork == false
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
ref: ${{ inputs.target_branch || github.sha }}

- name: Check whether image publishing is needed
id: image-check
run: |
MAKE_STATUS=0
MAKE_DATABASE="$(make -qp 2>/dev/null)" || MAKE_STATUS=$?
if [ "${MAKE_STATUS}" -gt 1 ]; then
echo "Unable to inspect Makefile targets (make exited ${MAKE_STATUS})." >&2
exit "${MAKE_STATUS}"
fi

if grep -Eq '^build-push-images-needed::?([[:space:]]|$)' <<< "${MAKE_DATABASE}"; then
echo "Found build-push-images-needed; checking whether images need publishing."
TARGET_STATUS=0
if make build-push-images-needed; then
TARGET_STATUS=0
else
TARGET_STATUS=$?
fi

if [ "${FORCE_BUILD_ALL}" = "TRUE" ]; then
echo "FORCE_BUILD_ALL=TRUE; building and publishing all images regardless of the optional target result."
echo "needed=true" >> "$GITHUB_OUTPUT"
elif [ "${TARGET_STATUS}" -eq 0 ]; then
echo "Image build and push are needed."
echo "needed=true" >> "$GITHUB_OUTPUT"
else
echo "Image build and push are not needed; skipping them."
echo "needed=false" >> "$GITHUB_OUTPUT"
fi
else
echo "No build-push-images-needed target found; proceeding with image publishing."
echo "needed=true" >> "$GITHUB_OUTPUT"
fi

- name: Extract image tags
id: version
if: steps.image-check.outputs.needed == 'true'
env:
TARGET_BRANCH: ${{ inputs.target_branch || github.ref_name }}
run: |
BASE_VERSION=$(make version)
if [[ ! "${BASE_VERSION}" =~ ^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$ ]]; then
echo "make version must return a valid OCI tag (1-128 characters, starting with a letter, number, or underscore)." >&2
exit 1
fi
if [ "${TARGET_BRANCH}" = "main" ]; then
TAG_BASE="${BASE_VERSION}"
elif [ "${TARGET_BRANCH}" = "dev" ]; then
TAG_BASE="${BASE_VERSION}-dev"
else
echo "Unsupported target branch: ${TARGET_BRANCH}" >&2
exit 1
fi
COMMIT_SHA=$(git rev-parse HEAD)
VERSIONS="${TAG_BASE} ${TAG_BASE}-${COMMIT_SHA}"
if [ "${TARGET_BRANCH}" = "main" ]; then
VERSIONS="${VERSIONS} latest"
else
VERSIONS="${VERSIONS} dev"
fi
for TAG in ${VERSIONS}; do
if [[ ! "${TAG}" =~ ^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$ ]]; then
echo "Derived image tag is not a valid OCI tag: ${TAG}" >&2
exit 1
fi
done
echo "versions=${VERSIONS}" >> "$GITHUB_OUTPUT"

- name: Set up Docker Buildx
if: steps.image-check.outputs.needed == 'true'
uses: docker/setup-buildx-action@v3

- name: Log in to Quay.io
if: steps.image-check.outputs.needed == 'true'
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

# Include this step only if the quickstart uses uv, with versions from
# its Makefile and README. Add other required runtime setup as needed.
- name: Set up uv
if: steps.image-check.outputs.needed == 'true'
uses: astral-sh/setup-uv@v6
with:
version: ${{ env.UV_VERSION }}
python-version: ${{ env.PYTHON_VERSION }}

- name: Build all images
if: steps.image-check.outputs.needed == 'true'
run: |
IFS=' ' read -ra VERSIONS <<< "${{ steps.version.outputs.versions }}"
VERSION="${VERSIONS[0]}" make build-all-images

- name: Push all images
if: steps.image-check.outputs.needed == 'true'
run: |
IFS=' ' read -ra VERSIONS <<< "${{ steps.version.outputs.versions }}"
VERSION="${VERSIONS[0]}" make push-all-images

- name: Tag pushed images
if: steps.image-check.outputs.needed == 'true'
env:
IMAGE_TAGS: ${{ steps.version.outputs.versions }}
run: |
IFS=' ' read -ra VERSIONS <<< "${IMAGE_TAGS}"
PRIMARY_TAG="${VERSIONS[0]}"
for IMAGE in ${IMAGE_REPOSITORIES}; do
for TAG in "${VERSIONS[@]:1}"; do
echo "Tagging ${IMAGE}:${PRIMARY_TAG} as ${IMAGE}:${TAG}"
docker buildx imagetools create --tag "${IMAGE}:${TAG}" "${IMAGE}:${PRIMARY_TAG}"
done
done
3 changes: 1 addition & 2 deletions core/skills/rh-qs-test-suite/references/workflow-catalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ with:

| File | Trigger | Purpose |
|------|---------|---------|
| `build-and-push.yaml` | `push` to `main`, `dev` | `if: github.repository_owner == 'rh-ai-quickstart'`; version from `make version`; multi-tag push to `quay.io/rh-ai-quickstart` |
| `build-and-push-manual.yaml` | `workflow_dispatch` | Manual image build |
| `build-and-push.yaml` | `push` to `main`, `dev`; `workflow_dispatch` | Self-contained workflow from [the local build-and-push reference](./build-and-push-workflow.yaml); uses `make version`, `make build-all-images`, and `make push-all-images`; manual dispatch can set `FORCE_BUILD_ALL=TRUE` to override the optional image-needed target; excludes forks |
| `create-dev-to-main-pr.yaml` | `workflow_dispatch` | GitHub App token; version sync Makefile ↔ Chart.yaml ↔ values image tags; temp branch `dev-<short-sha>` |
| `create-dev-version-bump-pr.yml` | `workflow_dispatch` | Automated version bump on dev |

Expand Down
43 changes: 1 addition & 42 deletions core/skills/rh-qs-test-suite/references/workflow-skeletons.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,48 +173,7 @@ jobs:

## build-and-push.yaml

```yaml
name: Build and push images

on:
push:
branches: [main, dev]

concurrency:
group: ${{ github.workflow }}-${{ github.sha }}
cancel-in-progress: true

env:
REGISTRY: quay.io/rh-ai-quickstart
UV_VERSION: "0.8.9"
PYTHON_VERSION: "3.12"

jobs:
build-and-push:
if: github.repository_owner == 'rh-ai-quickstart'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: version
run: |
BASE_VERSION=$(make version)
# tag logic: main → latest, dev → dev tag, etc.
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- uses: astral-sh/setup-uv@v6
with:
version: ${{ env.UV_VERSION }}
python-version: ${{ env.PYTHON_VERSION }}
- run: |
for version in ${{ steps.version.outputs.versions }}; do
VERSION="${version}" make build-all-images
VERSION="${version}" make push-all-images
done
```
Use the skill-local [build-and-push workflow reference](./build-and-push-workflow.yaml). It combines push triggers for `main` and `dev` with manual dispatch, checks the repository owner and fork status, and calls the quickstart's Makefile build and push targets. Adapt the registry and toolchain steps to the quickstart.

## Evaluations artifact tarball (reusable snippet)

Expand Down
1 change: 1 addition & 0 deletions core/skills/rh-qs-test-suite/subagents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

| Name | Purpose | Input | Output | When used | Why subagent |
|------|---------|-------|--------|-----------|---------------|
| `build-and-push-prompt.md` | Generate a self-contained build-and-push workflow from the quickstart's real Makefile target contract | `repo_root`, optional `target_mapping`, `invocation_mode` | `.github/workflows/build-and-push.yaml` plus a report of resolved targets, variables, and toolchain setup | Step 7 of the main `rh-qs-test-suite` workflow, or directly when only image publishing is requested | Target discovery and toolchain selection are self-contained and must be deterministic; this prompt forces explicit evidence or a user question before generating the workflow |
| `nightly-tests-prompt.md` | Generate a reusable `workflow_call` test workflow plus scheduled `nightly-main`/`nightly-<dev>` callers, copying shared composite actions from `quickstart-ci-testing`, a namespace/ServiceAccount provisioning script, and reports on required secrets/variables and toolchain setup | `slug`, `repo_root`, `invocation_mode` (`standalone` or `full-pipeline`) | `.qs-factory/pipeline/nightly-tests-manifest.yaml` + a report (toolchain steps used, secrets/variables needed, cluster-admin warning if any, next steps) | Step 8 of the main `rh-qs-test-suite` workflow, or directly via the nightly-only fast path in `SKILL.md` when a quickstart already has CI and just needs nightly testing added or refreshed | Nightly generation is self-contained detection + file-generation logic (Makefile contract resolution, toolchain detection, secret discovery, cluster-admin scan, action copying) that the orchestrator shouldn't have to hold in its own context, and that also needs to be independently invokable without running the rest of the CI build-out |
Loading
Loading