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
112 changes: 101 additions & 11 deletions .github/workflows/gitlab-manual-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,40 @@ on:
description: "Branch, tag, or SHA in this repository to test"
required: true
default: "develop"
gitlab_target:
description: "GitLab target project"
required: true
type: choice
options:
- swc
- gitlab_com
default: swc
result_server_target:
description: "Result server target resolved by GitLab CI/CD variable scope"
required: true
type: choice
options:
- dev2
- dev
default: dev2
code:
description: "Benchkit code filter, for example: qws,genesis"
required: false
system:
description: "System filter, for example: Fugaku,MiyabiG"
required: false
nodes:
description: "Optional list.csv nodes filter, for example: 1"
required: false
numproc_node:
description: "Optional list.csv numproc_node filter, for example: 4"
required: false
nthreads:
description: "Optional list.csv nthreads filter, for example: 32"
required: false
activity:
description: "Optional public activity/budget label recorded as BK_EXECUTION_ACTIVITY"
required: false
allocation_project_id:
description: "Optional allocation/project ID passed as BK_ALLOCATION_PROJECT_ID"
required: false
Expand Down Expand Up @@ -53,6 +81,17 @@ jobs:
fetch-depth: 0
path: trusted

- name: Reject production main workflow branch
env:
WORKFLOW_REF_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail

if [ "${WORKFLOW_REF_NAME}" = "main" ]; then
echo "::error::GitLab Manual CI must be run from develop or a trusted non-production workflow branch."
exit 1
fi

- name: Reject production main target
env:
TARGET_REF: ${{ inputs.target_ref }}
Expand All @@ -66,12 +105,20 @@ jobs:
;;
esac

- name: Prepare GitLab repository settings
id: gitlab-repo
- name: Prepare SWC GitLab repository settings
if: ${{ inputs.gitlab_target == 'swc' }}
id: gitlab-repo-swc
uses: ./trusted/.github/actions/prepare-gitlab-repo
with:
gitlab-repo: ${{ secrets.GITLAB_REPO }}

- name: Prepare GitLab.com repository settings
if: ${{ inputs.gitlab_target == 'gitlab_com' }}
id: gitlab-repo-com
uses: ./trusted/.github/actions/prepare-gitlab-repo
with:
gitlab-repo: gitlab.com/yoshifuminakamura/benchkit.git

- name: Check out target ref
uses: actions/checkout@v4
with:
Expand All @@ -82,14 +129,22 @@ jobs:
- name: Push target ref to GitLab test branch
working-directory: target
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
GITLAB_REPO_HOST_PATH: ${{ steps.gitlab-repo.outputs.host-path }}
GITLAB_TARGET: ${{ inputs.gitlab_target }}
GITLAB_TOKEN_SWC: ${{ secrets.GITLAB_TOKEN }}
GITLAB_TOKEN_GITLAB_COM: ${{ secrets.GITLAB_COM_TOKEN }}
GITLAB_REPO_HOST_PATH: ${{ steps.gitlab-repo-swc.outputs.host-path || steps.gitlab-repo-com.outputs.host-path }}
TARGET_REF: ${{ inputs.target_ref }}
run: |
set -euo pipefail

case "${GITLAB_TARGET}" in
swc) GITLAB_TOKEN="${GITLAB_TOKEN_SWC}" ;;
gitlab_com) GITLAB_TOKEN="${GITLAB_TOKEN_GITLAB_COM}" ;;
*) echo "Unsupported GitLab target: ${GITLAB_TARGET}"; exit 1 ;;
esac

if [ -z "${GITLAB_TOKEN}" ] || [ -z "${GITLAB_REPO_HOST_PATH}" ]; then
echo "GITLAB_TOKEN and GITLAB_REPO secrets are required."
echo "Selected GitLab target token and repository settings are required."
exit 1
fi

Expand All @@ -106,11 +161,18 @@ jobs:

- name: Trigger and wait for GitLab pipeline
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
GITLAB_HOST: ${{ steps.gitlab-repo.outputs.host }}
GITLAB_PROJECT_PATH: ${{ steps.gitlab-repo.outputs.project-path }}
GITLAB_TARGET: ${{ inputs.gitlab_target }}
GITLAB_TOKEN_SWC: ${{ secrets.GITLAB_TOKEN }}
GITLAB_TOKEN_GITLAB_COM: ${{ secrets.GITLAB_COM_TOKEN }}
GITLAB_HOST: ${{ steps.gitlab-repo-swc.outputs.host || steps.gitlab-repo-com.outputs.host }}
GITLAB_PROJECT_PATH: ${{ steps.gitlab-repo-swc.outputs.project-path || steps.gitlab-repo-com.outputs.project-path }}
CODE_FILTER: ${{ inputs.code }}
SYSTEM_FILTER: ${{ inputs.system }}
NODES_FILTER: ${{ inputs.nodes }}
NUMPROC_NODE_FILTER: ${{ inputs.numproc_node }}
NTHREADS_FILTER: ${{ inputs.nthreads }}
RESULT_SERVER_TARGET: ${{ inputs.result_server_target }}
ACTIVITY: ${{ inputs.activity }}
ALLOCATION_PROJECT_ID: ${{ inputs.allocation_project_id }}
BENCHPARK_APP: ${{ inputs.app }}
BENCHPARK: ${{ inputs.benchpark }}
Expand All @@ -119,6 +181,16 @@ jobs:
run: |
set -euo pipefail

case "${GITLAB_TARGET}" in
swc) GITLAB_TOKEN="${GITLAB_TOKEN_SWC}" ;;
gitlab_com) GITLAB_TOKEN="${GITLAB_TOKEN_GITLAB_COM}" ;;
*) echo "Unsupported GitLab target: ${GITLAB_TARGET}"; exit 1 ;;
esac
if [ -z "${GITLAB_TOKEN}" ] || [ -z "${GITLAB_HOST}" ] || [ -z "${GITLAB_PROJECT_PATH}" ]; then
echo "Selected GitLab target token and repository settings are required."
exit 1
fi

project_encoded="$(PROJECT_PATH="${GITLAB_PROJECT_PATH}" python3 -c 'import os, urllib.parse; print(urllib.parse.quote(os.environ["PROJECT_PATH"], safe=""))')"
api="https://${GITLAB_HOST}/api/v4/projects/${project_encoded}/pipeline"

Expand All @@ -140,6 +212,17 @@ jobs:

add_variable("code", os.environ.get("CODE_FILTER", ""))
add_variable("system", os.environ.get("SYSTEM_FILTER", ""))
add_variable("nodes", os.environ.get("NODES_FILTER", ""))
add_variable("numproc_node", os.environ.get("NUMPROC_NODE_FILTER", ""))
add_variable("nthreads", os.environ.get("NTHREADS_FILTER", ""))
result_server_target = os.environ.get("RESULT_SERVER_TARGET", "")
if result_server_target == "dev":
add_variable("BK_GITLAB_ENVIRONMENT", "develop")
elif result_server_target == "dev2":
print("GitLab result server target: dev2")
elif result_server_target:
raise SystemExit(f"Unsupported result_server_target: {result_server_target}")
add_variable("BK_EXECUTION_ACTIVITY", os.environ.get("ACTIVITY", ""))
add_variable("BK_ALLOCATION_PROJECT_ID", os.environ.get("ALLOCATION_PROJECT_ID", ""))
add_variable("app", os.environ.get("BENCHPARK_APP", ""))

Expand Down Expand Up @@ -212,11 +295,18 @@ jobs:
if: always()
working-directory: trusted
env:
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
GITLAB_REPO_HOST_PATH: ${{ steps.gitlab-repo.outputs.host-path }}
GITLAB_TARGET: ${{ inputs.gitlab_target }}
GITLAB_TOKEN_SWC: ${{ secrets.GITLAB_TOKEN }}
GITLAB_TOKEN_GITLAB_COM: ${{ secrets.GITLAB_COM_TOKEN }}
GITLAB_REPO_HOST_PATH: ${{ steps.gitlab-repo-swc.outputs.host-path || steps.gitlab-repo-com.outputs.host-path }}
run: |
set -euo pipefail
if [ -n "${GITLAB_TEST_BRANCH:-}" ] && [ -n "${GITLAB_REPO_HOST_PATH:-}" ]; then
case "${GITLAB_TARGET}" in
swc) GITLAB_TOKEN="${GITLAB_TOKEN_SWC}" ;;
gitlab_com) GITLAB_TOKEN="${GITLAB_TOKEN_GITLAB_COM}" ;;
*) GITLAB_TOKEN="" ;;
esac
if [ -n "${GITLAB_TEST_BRANCH:-}" ] && [ -n "${GITLAB_TOKEN:-}" ] && [ -n "${GITLAB_REPO_HOST_PATH:-}" ]; then
git remote add gitlab-cleanup "https://oauth2:${GITLAB_TOKEN}@${GITLAB_REPO_HOST_PATH}" || true
git push gitlab-cleanup --delete "${GITLAB_TEST_BRANCH}" || true
fi
19 changes: 18 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ stages:
variables:
code: ""
system: ""
nodes: ""
numproc_node: ""
nthreads: ""
BK_GITLAB_ENVIRONMENT: ""
app: ""
benchpark: "false"
park_only: "false"
Expand Down Expand Up @@ -64,13 +68,26 @@ variables:
echo "No code filter detected, running all programs"
fi
fi
- |
if [[ -n "$nodes" ]]; then
echo "Nodes filter from API variable: $nodes"
fi
if [[ -n "$numproc_node" ]]; then
echo "Processes-per-node filter from API variable: $numproc_node"
fi
if [[ -n "$nthreads" ]]; then
echo "Threads-per-process filter from API variable: $nthreads"
fi
if [[ -n "$BK_GITLAB_ENVIRONMENT" ]]; then
echo "GitLab environment from API variable: $BK_GITLAB_ENVIRONMENT"
fi

generate_matrix:
stage: generate
before_script:
*filters
script:
- bash ./scripts/matrix_generate.sh code=$code system=$system
- bash ./scripts/matrix_generate.sh "code=$code" "system=$system" "nodes=$nodes" "numproc_node=$numproc_node" "nthreads=$nthreads"
tags:
- general
artifacts:
Expand Down
25 changes: 20 additions & 5 deletions docs/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Workflows that push to GitLab or trigger GitLab pipelines use these secrets:

| Secret | Format / 形式 | Purpose / 目的 |
|---|---|---|
| `GITLAB_TOKEN` | GitLab token with push and pipeline API access / pushとpipeline APIに使えるGitLab token | Authenticates Git operations and Pipeline API calls / Git操作とPipeline API呼び出しを認証する |
| `GITLAB_REPO` | Scheme-less `host/path` such as `gitlab.example.com/group/project.git` / `gitlab.example.com/group/project.git` のようなschemeなし`host/path` | Selects the GitLab project used by sync and manual CI / syncとmanual CIが使うGitLab projectを指定する |
| `GITLAB_COM_TOKEN` | GitLab.com token with push access / GitLab.comへのpush権限を持つtoken | Optionally mirrors protected branches and tags to a secondary GitLab.com mirror / 任意で保護ブランチとtagをGitLab.com上の副mirrorへmirrorする |
| `GITLAB_TOKEN` | GitLab token with push and pipeline API access / pushとpipeline APIに使えるGitLab token | Authenticates SWC GitLab operations and Pipeline API calls / SWC GitLabのGit操作とPipeline API呼び出しを認証する |
| `GITLAB_REPO` | Scheme-less `host/path` such as `gitlab.example.com/group/project.git` / `gitlab.example.com/group/project.git` のようなschemeなし`host/path` | Selects the SWC GitLab project used by sync and manual CI / syncとmanual CIが使うSWC GitLab projectを指定する |
| `GITLAB_COM_TOKEN` | GitLab.com token with push and pipeline API access / GitLab.comへのpushとpipeline APIに使えるtoken | Mirrors protected refs to GitLab.com and can run `GitLab Manual CI` when `gitlab_target=gitlab_com` / GitLab.com上の副mirrorへ保護refをmirrorし、`gitlab_target=gitlab_com`時の`GitLab Manual CI`にも使う |

`GITLAB_REPO` に `https://` や `http://` は付けません。`GitLab Manual CI` と `Sync protected branches to GitLab` は同じ形式を検証して使います。

Expand Down Expand Up @@ -70,8 +70,14 @@ The workflow accepts these inputs:
| Input / 入力 | Description / 説明 | Example / 例 |
|---|---|---|
| `target_ref` | Branch, tag, or SHA in the upstream repository to test / upstreamリポジトリ内でテストするbranch、tag、SHA | `feature/my-change`, `ci/pr-123`, `develop` |
| `gitlab_target` | GitLab project to receive the temporary test branch and pipeline trigger / 一時テストbranchのpush先およびpipeline trigger先のGitLab project | `swc`, `gitlab_com` |
| `result_server_target` | Result server target selected through GitLab CI/CD variable environment scope. `dev2` uses the default scope; `dev` sets `BK_GITLAB_ENVIRONMENT=develop`. / GitLab CI/CD変数のenvironment scopeで選ぶ結果返送先。`dev2`はdefault scopeを使い、`dev`は`BK_GITLAB_ENVIRONMENT=develop`を渡します | `dev2`, `dev` |
| `code` | Benchkit program filter / Benchkitプログラムのフィルタ | `qws,genesis` |
| `system` | Benchkit system filter. Legacy Benchpark bridge jobs in this repo do not honor this as a general system selector. / Benchkit systemフィルタ。このrepo内のlegacy Benchpark bridge jobは汎用system selectorとしては扱いません | `Fugaku,MiyabiG` |
| `nodes` | Optional `programs/<code>/list.csv` nodes filter. Use this with `code` and `system` to run only selected matrix rows. / 任意の `programs/<code>/list.csv` nodesフィルタ。`code`、`system`と併用して特定matrix行だけを実行します | `1`, `1,2` |
| `numproc_node` | Optional `list.csv` processes-per-node filter / 任意の `list.csv` processes-per-nodeフィルタ | `4` |
| `nthreads` | Optional `list.csv` threads-per-process filter / 任意の `list.csv` threads-per-processフィルタ | `32` |
| `activity` | Optional public activity or budget label recorded as `BK_EXECUTION_ACTIVITY` and copied into Result environment metadata / `BK_EXECUTION_ACTIVITY`として記録しResult環境metadataへコピーする任意の公開activityまたはbudget label | `SBDProfile` |
| `allocation_project_id` | Optional semantic project/allocation ID passed to GitLab as `BK_ALLOCATION_PROJECT_ID`. Benchkit translates it to scheduler syntax only for systems that require it, for example Slurm `--account=<id>` on RIKYU and PJM `-g <id>` on Fugaku. / GitLab へ `BK_ALLOCATION_PROJECT_ID` として渡す任意の意味的な project/allocation ID。Benchkit は必要な system に限って scheduler 書式へ変換します。例: RIKYU の Slurm `--account=<id>`、Fugaku の PJM `-g <id>` | `rkp00010` |
| `app` | Legacy Benchpark bridge app filter. Active Benchpark CI/CD/CB result handling is maintained in a separate project. / legacy Benchpark bridge appフィルタ。現行Benchpark CI/CD/CB結果受け取りは別プロジェクト側で管理します | `osu-micro-benchmarks` |
| `benchpark` | Enable the legacy Benchpark bridge path together with Benchkit / legacy Benchpark bridge pathも有効化 | `true` |
Expand All @@ -82,6 +88,10 @@ The workflow accepts these inputs:

`GitLab Manual CI` は開発・release candidate検証用であり、本番 `main` branch結果を作る入口ではありません。このworkflowは本番 `main` branchを指す `target_ref` を拒否します。公開用の `main` 計測は、Portal管理のtriggerから、明示的な `code` / `system` scope と明示的な `RESULT_SERVER` pipeline variable を渡して作成します。

GitHub Actions also shows a branch selector for the workflow file itself. If `main` appears there, it only selects which checked-in workflow definition to run. This workflow rejects the production `main` workflow branch and also rejects `target_ref=main` as a manual benchmark target.

GitHub Actions UIにはworkflow file自体のbranch selectorも表示されます。そこに`main`が出る場合でも、それはどのworkflow定義を実行するかの選択に過ぎません。このworkflowは本番`main`のworkflow branchからの実行と、manual benchmark targetとしての`target_ref=main`の両方を拒否します。

このworkflowは以下を行います。

The workflow:
Expand All @@ -94,8 +104,8 @@ The workflow:
- Uses `ci.skip` for that push so the push itself does not start a full GitLab pipeline.
- GitLab Pipeline APIを使ってpipelineを明示的に起動します。
- Starts a GitLab pipeline through the GitLab Pipeline API.
- `code`, `system`, `allocation_project_id`, `app`, `park_only`, `park_send`などの指定変数を渡します。
- Passes the selected scope variables such as `code`, `system`, `allocation_project_id`, `app`, `park_only`, and `park_send`.
- `result_server_target`から決まる`BK_GITLAB_ENVIRONMENT`、および`code`, `system`, `nodes`, `numproc_node`, `nthreads`, `activity`, `allocation_project_id`, `app`, `park_only`, `park_send`などの指定変数を渡します。
- Passes `BK_GITLAB_ENVIRONMENT` derived from `result_server_target`, plus selected scope variables such as `code`, `system`, `nodes`, `numproc_node`, `nthreads`, `activity`, `allocation_project_id`, `app`, `park_only`, and `park_send`.
- GitLab pipelineの完了を待ちます。
- Waits for the GitLab pipeline to finish.
- 実行後、一時GitLabブランチを削除します。
Expand Down Expand Up @@ -160,6 +170,11 @@ The recommended mechanism is pipeline variables. `GitLab Manual CI` uses pipelin
|---|---|---|
| `system` | Benchkit system filter. Legacy Benchpark bridge jobs in this repo are not a general multi-system Benchpark runner. / Benchkit systemフィルタ。このrepo内のlegacy Benchpark bridge jobは汎用multi-system Benchpark runnerではありません | `MiyabiG,MiyabiC,RC_GENOA` |
| `code` | Benchkit program filter / Benchkit programフィルタ | `qws,genesis` |
| `nodes` | Optional `list.csv` nodes filter for selecting specific Benchkit matrix rows / 特定のBenchkit matrix行を選ぶ任意の`list.csv` nodesフィルタ | `1` |
| `numproc_node` | Optional `list.csv` processes-per-node filter / 任意の`list.csv` processes-per-nodeフィルタ | `4` |
| `nthreads` | Optional `list.csv` threads-per-process filter / 任意の`list.csv` threads-per-processフィルタ | `32` |
| `BK_GITLAB_ENVIRONMENT` | Optional GitLab job environment name used for GitLab CI/CD variable environment scope resolution. When unset, jobs use `$CI_COMMIT_BRANCH`. / GitLab CI/CD変数のenvironment scope解決に使う任意のGitLab job environment名。未指定時は`$CI_COMMIT_BRANCH`を使います | `develop` |
| `BK_EXECUTION_ACTIVITY` | Optional public activity or budget label stored in environment snapshot metadata / environment snapshot metadataに保存する任意の公開activityまたはbudget label | `SBDProfile` |
| `BK_ALLOCATION_PROJECT_ID` | Optional semantic project/allocation ID. Benchkit validates the value and derives scheduler arguments only for systems that support it: `--account=<id>` on RIKYU and `-g <id>` on Fugaku/FugakuCN. / 任意の意味的な project/allocation ID。Benchkit は値を検証し、対応 system に限って scheduler 引数へ変換します。RIKYU では `--account=<id>`、Fugaku/FugakuCN では `-g <id>` になります | `rkp00010` |
| `app` | Legacy Benchpark bridge app filter. Active Benchpark CI/CD/CB result handling has moved to a separate project. / legacy Benchpark bridge appフィルタ。現行Benchpark CI/CD/CB結果受け取りは別プロジェクト側へ移行済み | `osu-micro-benchmarks` |
| `benchpark` | Enable the legacy Benchpark bridge path / legacy Benchpark bridge pathを有効化 | `true` |
Expand Down
1 change: 1 addition & 0 deletions result_server/routes/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ def _build_execution_pipeline_plan(store):
park_only=False,
park_send=False,
allocation_project_id=resolve_result.allocation_project_id,
activity=str(profile.get("activity", "")) if profile else "",
scheduler_extra_args="",
result_server_url=_portal_result_server_url(),
target_id=gitlab_target.id if gitlab_target else gitlab_target_id,
Expand Down
Loading
Loading