Metadata-Version: 2.4
Name: squidient
Version: 4.1.0
Summary: CI/CD framework for alya
Project-URL: Homepage, https://alya.gitlab.bsc.es/alya/ci-cd/squidient
Project-URL: Bug Tracker, https://alya.gitlab.bsc.es/alya/ci-cd/squidient/issues
Author-email: Damien Dosimont <damien.dosimont@gmail.com>
License-File: LICENSE.txt
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Requires-Dist: importlib-resources; python_version < '3.9'
Requires-Dist: lxml
Requires-Dist: mariasql>=5
Requires-Dist: packaging>=21.3
Description-Content-Type: text/markdown

# Squidient

Squidient is a scheduler for testing, benchmarking and deploying HPC programs on SLURM machines.

## Refreshing Workspace Data

Squidient records a fingerprint of its packaged `data/` in `version/data.json`
when `squidient init .` completes. A completed full configuration records
that fingerprint in `configuration.json.dataRevision`. Staging and monitoring stop
with exit code 1 if either differs from the installed package, including for older
workspaces without this metadata. No confirmation prompt is displayed. The check
runs before Terraform provisioning, remote connections, or job submission.
A package release that leaves `data/` unchanged does not require a refresh.

Refreshing is explicit: back up any customized workspace files and configuration
first, then run:

```sh
squidient init .
squidient configure --all
```

`init` overwrites packaged workspace files but does not regenerate
`configuration.json`. `configure --all` regenerates the configuration; reapply
your local settings as necessary. Partial reconfiguration does not mark an old
configuration as current. The check never overwrites customizations automatically.
Help and cleanup commands, including `terraform stop`, remain available.
The former `fileFormat` counter and `version/version.json` are no longer used;
legacy configurations must be refreshed before workflow execution when their
data revision cannot be established.

## MR Concurrency Checks

Each MR staging/monitoring `run` job checks the GitLab API before installing
Squidient or starting a campaign. `version:final` repeats the check before its
release-version validation. A running or canceling MR run/version job in another
pipeline makes the current job fail immediately, with the conflicting pipeline
and job identifiers. There is no waiting, automatic cancellation or write API
operation. Jobs in the same parent pipeline, including its staging and monitoring
children, are excluded so those two workflows can still run together.

The check uses `CI_API_V4_URL` and the existing `SQUIDIENT_READ_API_TOKEN`.
Pagination, response sizes and request/check durations are bounded. API failures,
invalid metadata or missing credentials prevent campaign execution. Master and
trigger workflows are unchanged. Retried child runs are detected independently
of their parent pipeline's completion status.

This is a best-effort API snapshot, not an atomic lock: simultaneous starts can
race. That risk is accepted instead of queueing campaigns or using a remote lock.
Retry a rejected job after the other campaign finishes. TestPyPI publication is
automatic after successful validations for eligible version-changing MRs.

## MR Monitoring Build Selection

MR monitoring selects its build preset with `MR_MONITORING_BUILD_SET`.
The temporary default, `mr-no-acc`, retains the MR GPP build and benchmark
without submitting ACC work. Set the variable to `mr` to restore the full MR
monitoring preset. Both choices retain the test database, MR benchmark cases
and MR queue settings. This selector does not change MR staging or monitoring
triggered from Alya.

## CI Report Comments

The three `post` jobs delegate MR comments to Taskmaster's declared `task=comment`
input. The helper sends a JSON `inputs` object, never arbitrary pipeline variables.
Define `TASKMASTER_PROJECT_ID` and `TASKMASTER_TOKEN` in Squidient's CI/CD settings.
The latter is a Taskmaster pipeline trigger token, not a GitLab write API token.
Mask it in job logs and make it available to the MR pipelines that need to post;
the protected write API tokens remain exclusively in Taskmaster for this operation.
`TASKMASTER_REF` optionally selects the trusted execution reference and defaults
to `master`. GitLab provides `CI_API_V4_URL` automatically.

Taskmaster selects its own write credential using the target project: Squidient
for MR staging/monitoring reports, or the calling Alya project for triggered staging reports. Titles
and report links are unchanged. No write API credential is used by the `post`
scripts. Execution jobs use `SQUIDIENT_READ_API_TOKEN` for the watchdog
and MR lock checks. Triggered staging verifies `SRC_PROJECT_PATH` against
`SRC_PROJECT_ID` and selects `ALYA_READ_API_TOKEN` for Alya or
`ALYA_PRIVATE_READ_API_TOKEN` for alya-private. Each reader is scoped to its own
project, masked, with expansion disabled and available to MR jobs. Existing
callers without `SRC_PROJECT_PATH` are identified by their verified project ID.
Neither `ALYA_WRITE_API_TOKEN` nor
`SQUIDIENT_WRITE_API_TOKEN` is required by Squidient's CI anymore. Their use for
publishing comments is confined to Taskmaster.

Triggered staging accepts `ALAMAK_REVISION` and `ALYA_PRIVATE_REVISION` alongside
their branch names. Explicit revisions pin downloads to the commits captured by
the caller; private pipelines use their exact private commit and a reviewed
public driver. The runtime accepts `--token-env NAME...`, `--alamak-user-env`,
`--alamak-token-env`, `--private-user-env` and `--private-token-env` to resolve
credentials in memory without placing their values in command arguments.

The caller only submits the request; successful submission does not mean that
Taskmaster has already posted the comment. Check the indicated Taskmaster pipeline
for the publication result. Posting remains non-blocking for the Squidient
pipeline. Automatic retries are disabled to reduce duplicate comments; manually
rerunning a post job can still create duplicates. Credentials, comment bodies
and API response bodies are not printed by the submission helper.

The Gazix, Taskmaster, Alya and Squidient migrations may be merged together.
Gazix 2.0.0 must finish publishing before Taskmaster jobs can install it. Configure
Taskmaster's protected write credentials and a protected execution ref, then run
its `tools/activate_inputs.py` preflight and explicit activation after both known
master callers have migrated. This disables arbitrary pipeline-variable overrides
in Taskmaster; there is no legacy-variable fallback. Only Alya and
Squidient on the same GitLab instance are currently authorized by Taskmaster;
an explicitly configured source API URL on another instance is rejected rather
than silently posting to the wrong project.

## Private Alya Sources

After the initial workspace configuration, enable the private sources with:

```sh
squidient configure --private
# Optional branch instead of the default master:
squidient configure --private private-branch
```

GitLab configuration accepts `--private`, `--private-branch:<branch>` and
`--private-revision:<revision>`; an explicit revision takes precedence over the
branch. Configuration is stored under `private` in `configuration.json`, with
`enable`, `branch`, `revision` and `path`. Private sources are disabled by default.

Squidient runs `alya/extern/alya-private/alya-private.sh --clean`, then downloads
the selected sources through that script before uploading Alya for compilation.
The script directory is configurable through `private.path`; its checkout is
the nested `alya-private/` directory. CMake receives `WITH_ALYA_PRIVATE=ON` and
the checkout path. Staging also discovers regression tests under
`alya/extern/alya-private/alya-private/tests`, respecting `-d` and `-t` filters.
Monitoring uses the same source download and build setup, retaining its usual
benchmark selection.

SSH is used without credentials. For HTTPS, pass credentials at execution time:

```sh
squidient run all --private-user "$ALYA_PRIVATE_USER" --private-token "$ALYA_PRIVATE_TOKEN"
squidient monitoring all --private-user "$ALYA_PRIVATE_USER" --private-token "$ALYA_PRIVATE_TOKEN"
```

A token without a user uses the downloader's default HTTPS user. A user without
a token lets the downloader use the configured Git credential mechanism.
These values are not stored in the JSON configuration. Build reproduction files
use placeholders rather than credentials; downloader diagnostics go to the
Squidient log with the supplied token redacted. Existing Alamak configuration
and its credentials remain independent.

CI configuration enables private sources for staging, monitoring and installation,
including Squidient MR child pipelines and staging triggered by Alamak itself.
The legacy `TYPE=alamak` jobs triggered by Alya retain their private-source exception.
Set `ALYA_PRIVATE_USER` and `ALYA_PRIVATE_TOKEN` in Squidient's CI/CD variables;
use a project-scoped deploy token with only `read_repository`, mask the values,
disable variable expansion, and make them available to the relevant MR and trigger
jobs. Rotate the token before its expiry. The privileged credential used to create
it is not needed in Squidient CI.

CI staging triggered by Alya enables Alamak for every build type. Configuration
uses `--gitlab --alamak` and the captured commit `ALAMAK_REF`; execution passes `ALAMAK_USER` and
`ALAMAK_TOKEN` alongside the private credentials where applicable. An enabled
Alamak configuration also sets `WITH_ALAMAK=ON` in generated CMake commands.
The `TYPE=alamak` private-source exception remains unchanged. Squidient's own MR
workflows are not automatically switched to Alamak by this rule. Monitoring and
installation configure private sources without enabling Alamak or selecting its
branch, and their execution jobs do not require Alamak credentials. Alya-triggered
staging requires full `ALYA_REF`, `ALAMAK_REF` and `ALYA_PRIVATE_REF` commit SHAs.
They are passed through `--alamak-revision` and `--private-revision`, so later
branch changes cannot select different sources. Monitoring and installation
require the full public/private references and use the captured private revision.
Missing references fail configuration instead of falling back to main or master.

Alamak's child pipeline triggers `FROM=alamak` with `TYPE=fast`, `gpp` or `acc`.
It supplies the same three immutable references and enables both providers.
Its remote workspaces are `alamak_fast`, `alamak_gpp` and `alamak_acc`, separate
from the fast/GPP/ACC workspaces shared by Alya and alya-private. Their remote
locks therefore do not conflict. Alamak's source admission checks only Alamak
pipelines, retaining exclusion between its own pipelines.

The Alamak source watchdog verifies `SRC_PROJECT_PATH=elem-serpens/alamak` and
`SRC_PROJECT_ID` with `ALAMAK_READ_API_TOKEN`, sent only to GitLab.com. Its pipeline
reference uses `project:pipeline@https://gitlab.com/api/v4/projects`; the Squidient
pipeline continues to use its BSC reader and API. HTTPS requests refuse redirects
and keep tokens out of subprocess arguments. Report comments through BSC
Taskmaster remain restricted to BSC projects.

For a standalone compilation check, trigger `FROM=alamak` with
`SQUIDIENT_BUILD_ONLY=true` and the three commit references. This runs
`squidient run build`, enables both providers and watches only its own Squidient
pipeline. It does not depend on an upstream MR pipeline. It uses
`alamak_<type>_buildcheck` so the check can run separately from regular staging.
The ordinary Alamak child pipeline does not set this option and runs the full tests.

Triggered monitoring and installation jobs are created only when Squidient runs
on `master`. Their shared trigger conditions exclude the complete monitoring and
installation job chains on other branches. The separate MR monitoring tests keep
their existing test configuration and credentials.

The `build:wheel` job runs for master, merge requests and trigger pipelines,
including triggers targeting a feature branch. Configuration and execution jobs
consume its `dist/*.whl` artifact through their existing dependencies. Unit tests
keep their separate master/MR rules and are not enabled in trigger pipelines.

