logs.gokuls.in

8 pull requests merged across 1 repo

bahdotsh/wrkflw

Problem

Long steps failed. Docker stopped waiting on a step after 5 minutes and Podman after 6, regardless of timeout-minutes, while the job default is 360 minutes. A real build or test step over that limit failed, under Docker with an unexplained exit code of -1.

Timed-out containers kept running. When a job or step timeout fired, wrkflw reported the failure and moved on or exited, but the container was left running. After a run with timeout-minutes: 0.05 and sleep 300, podman ps still showed the step's container.

The two are linked: the caps existed to prevent hangs, but the engine's job and step deadlines already bound every step, as long as a timeout actually stops the container.

Changes

  • Remove the per-step caps, so the job and step timeout-minutes values govern. Short internal operations such as inspect and rm keep their limits.
  • Add ContainerGuard, which force-removes a container when its run is abandoned. Dropping can't await, so it calls the CLI.
  • With --preserve-containers-on-failure the guard is off, so a timed-out container is kept for debugging, as with other failures.

Notes

  • A step with no timeout-minutes can now run for the full 360-minute job default. Hung steps take that long to fail unless a timeout is set, which matches GitHub.
  • Docker cleanup needs the docker CLI on PATH. If it's missing, a warning is logged and the container stays.
  • Kubernetes already has its own guard and is unchanged.

Testing

  • Unit tests for the guard, using a fake CLI.
  • cargo test --workspace and clippy -D warnings pass.
  • End to end under Podman: a job timeout during sleep 300 left 0 containers, and a 390-second step, past the old 360-second cap, completed successfully.
  • Docker wasn't tested end to end, because the local daemon was down. The Docker path has only compiled and shares the guard, so please try it before merging.

Problem

wrkflw run .gitlab-ci.yml ran the wrong jobs, in the wrong environment. The riskiest part is that jobs a pipeline excludes were executed, so a guarded deploy would run locally.

Pipeline configBeforeAfter
image: (job, default:, top level)ignored; ran in the default Ubuntu imageused
rules:ignored; the job always ranfirst match decides, no match excludes the job
rules: - when: neverranexcluded
only: / except:ignoredrefs, keywords, /regex/ and variables evaluated
workflow:rulesignoredan excluded pipeline skips every job
when: manualran automaticallyskipped unless named with --job
when: on_failurealways ranonly after a failure
when: always after a failureranruns
A stage failslater stages still ranlater on_success jobs are skipped
default: before_script / after_scriptignoredused
A job with no stage:ran twiceruns once

Changes

  • gitlab::job_when decides each job's condition from rules:, only:, except: and when:.
  • gitlab::pipeline_exclusion evaluates workflow:rules.
  • rules:if supports ==, !=, =~, !~, &&, ||, parentheses, bare variables, null, and quoted strings. Regex flags i, m and s are supported.
  • The pipeline loop applies those conditions stage by stage, so when: reflects earlier results.
  • Conversion resolves image and scripts through job, then default:, then top level.
  • wrkflw run --variable KEY=value (-V) sets GitLab variables. They override pipeline and job variables, and reach rules, images and scripts.
  • --job <name> runs the named job even if its gate or workflow:rules would exclude it, with a warning. It doesn't lift on_failure, and an earlier stage failure still skips it.

Decisions worth reviewing

  • A condition that can't be evaluated excludes the job. This covers a malformed rules:if, a bad only: regex and an unsupported regex flag. A missing job is safer than a guarded deploy that runs.
  • The host environment is left out of rules, so a run doesn't depend on what's exported. Variables come from predefined values, pipeline and job variables, then --variable.
  • Predefined variables are CI, GITLAB_CI, CI_PIPELINE_SOURCE=push, CI_DEFAULT_BRANCH, CI_CONFIG_PATH, and the current branch. Other predefined variables, including CI_COMMIT_TAG, are unset unless given with --variable.
  • rules:changes, rules:exists and rules:variables aren't evaluated. They warn, and a rule with only changes: counts as a match. only:changes passes and except:changes doesn't exclude.
  • Jobs with an image: use bash when the image has it and sh otherwise, as GitLab does. Jobs with no image keep bash.

Not addressed

  • artifacts: still aren't passed between jobs.
  • image: entrypoint isn't applied. It warns. run_container takes one string, so GitLab's list form needs its own change.
  • when: delayed runs without waiting for start_in. It warns.

Testing

  • Unit tests cover when, rule precedence, each operator, only/except, workflow:rules, and image and script fallback.
  • crates/wrkflw/tests/gitlab_pipeline_test.rs drives real pipelines through emulation: the stage-failure path, allow_failure, --variable, --job and workflow:rules.
  • cargo test --workspace --all-features and clippy -D warnings pass.

Problem

parallel was modelled only as a number, and even that was never used. A pipeline using the matrix form failed to parse, with a message that didn't name the job or key:

Validation failed: YAML parsing error: invalid type: map, expected usize

parallel: 3 parsed, but the job ran once.

Changes

  • Model parallel as a count or a matrix.
  • Convert both to a job matrix. parallel:matrix expands each entry's Cartesian product and exposes the variables as environment variables. parallel: N runs N instances with CI_NODE_INDEX and CI_NODE_TOTAL.
  • Disable fail-fast for these jobs, since GitLab runs every instance.

Testing

  • Unit tests for both forms, including multiple matrix entries.
  • cargo test --workspace and clippy -D warnings pass.
  • End to end under Podman: a pipeline with parallel:matrix now validates and runs, and each instance's script saw its variables.

Problem

actions/upload-artifact handled only a single glob, so common configurations failed or produced a different layout from GitHub:

path:BeforeAfter
out/ or out (a directory)step failed: "No files found"uploads the directory's contents
Multi-line pathstreated as one glob, so no matcheach line is searched
!exclude linesunsupportedexclude matching files, applied in order
packages/*/dist, **/dist (a wildcard matching a directory)selected nothingselect everything below the directory
out/* or a single file, then downloadkept the full out/... pathrelative to the search root, as on GitHub
No matching filesalways failed the stepif-no-files-found is honoured; defaults to warn
An existing artifact namemerged into the earlier uploadfails the step unless overwrite: true
Hidden filesalways uploadedskipped unless include-hidden-files: true

The layout matters because jobs that download an artifact and read got/f.txt would otherwise find it at got/out/f.txt.

Changes

  • Parse path: line by line, with directory expansion and ! exclusions. A later line can re-include a file.
  • A wildcard that matches a directory selects everything below it, as upload-artifact's implicit descendants do. This also applies to exclusions, so !**/node_modules excludes the contents.
  • Compute the artifact root as upload-artifact documents: the part before the first wildcard, the directory given, the parent of a single file, or the common ancestor of several search paths.
  • Support if-no-files-found, include-hidden-files and overwrite, trimmed as core.getInput does.
  • Stage each upload aside, then swap it into the index. A failed upload keeps the earlier artifact, and concurrent uploads of a name have exactly one winner.
  • Follow symlinked directories, with cycle detection, unless they leave the workspace. Every path must resolve inside the workspace, and a path: line outside it now fails the step.

Behaviour changes worth reviewing

All of these are in BREAKING_CHANGES.md.

  • Artifact layout changes for patterns with a leading directory: artifact-dir/* now downloads as payload.txt, not artifact-dir/payload.txt. An existing test pinned the old path and is updated.
  • out/* now includes files in subdirectories of out, as on GitHub.
  • A step that found no files now passes with a warning unless if-no-files-found: error is set. A missing artifact shows up later, at download.
  • Hidden files are now skipped by default, so path: . no longer uploads .git, and path: .config/ matches nothing.
  • Uploading to an existing name now fails. Matrix jobs sharing a name need their own names or overwrite: true, and with overwrite: true in parallel jobs, which job's files survive is not defined.

Testing

  • Unit tests cover directories, wildcards matching directories, exclusions, hidden files, symlinks, duplicate names, concurrent uploads and failed copies.
  • cargo test --workspace --all-features and clippy -D warnings pass.
  • The Podman end-to-end run predates the later commits and has not been repeated: upload out/, download into another job and read nested files; an optional missing path warns; if-no-files-found: error fails the step; actions/cache round trip between jobs.

Problem

continue-on-error was only half supported:

  • At job level it wasn't parsed at all. A failing job failed the whole run, blocked dependents, and triggered fail-fast.
  • As an expression it was a parse error. continue-on-error: ${{ matrix.experimental }} on a step passed wrkflw validate, then wrkflw run rejected the whole workflow.
  • GitLab's allow_failure: true was parsed and ignored, so an allowed failure failed the pipeline.

Also, services: is parsed but never started (a known limitation in the README), and nothing said so at run time. Jobs just failed trying to reach a host that wasn't there.

Changes

  • continue-on-error accepts a boolean or expression, on steps and jobs. Job values are evaluated per matrix combination.
  • JobResult::failure_allowed marks a tolerated failure. Such a job still displays as failed, but doesn't fail the run, block dependents, or trigger fail-fast.
  • GitLab allow_failure: true maps to the same thing. allow_failure: { exit_codes: ... } is unchanged, so those jobs still fail, because wrkflw doesn't track which exit code failed the job.
  • Warn when a job declares services:.

Please check

needs.<job>.result for an allowed failure now reads success. Dependents need the job treated as passed, and I believe this is what GitHub reports, but I couldn't find it documented and haven't confirmed it on GitHub. If GitHub reports failure, the value needs tracking separately from what gates dependents.

Testing

  • Integration tests: allowed failure with a running dependent, per-combination expressions, no fail-fast, step expressions.
  • cargo test --workspace and clippy -D warnings pass.
  • End to end under Podman: a matrix with an expression at job and step level. Jobs showed as failed, the dependent ran, and the exit code was 0.
  • The GitLab mapping and the services: warning have no dedicated test.

Problem

Passing data through composite actions and reusable workflows failed in several ways, usually with an empty value or literal ${{ }} text reaching a step.

ScenarioBefore
with: { who: ${{ env.WHO }} } on a composite actionthe action got the literal ${{ env.WHO }}
Nested composite, with: { value: ${{ inputs.who }} }same
with: { name: ${{ needs.pre.outputs.v }} } on a reusable workflowsame
Reusable input default:ignored, so inputs.x was empty
Input with a hyphen, inputs.my-inputalways empty: written to INPUT_MY-INPUT, read from INPUT_MY_INPUT
Composite default: 3, env: { PORT: 5432 }, if: truedropped, because only strings were read
needs.call.outputs.result from on.workflow_call.outputsempty unless an inner job output had the same name

Changes

  • Evaluate with: in the caller's scope for composite actions and reusable workflows, plus secrets: values for reusable workflows.
  • Apply declared defaults for reusable inputs, and write hyphenated inputs under the name inputs.* reads.
  • Keep non-string YAML scalars in composite steps.
  • Evaluate on.workflow_call.outputs. Workflows that don't declare outputs still get the previous flattening, so existing setups keep working.

Note

A called workflow that declares outputs now exposes only those, as on GitHub. Anything relying on an undeclared inner output leaking through will now read as empty.

Testing

  • Unit tests for each row, and an integration test covering a dynamic input, defaults and a declared output across jobs.
  • cargo test --workspace and clippy -D warnings pass.
  • End to end under Podman: nested composite with hyphenated and numeric inputs, and a reusable workflow with with: from needs, defaults and declared outputs.

Problem

include and exclude accept expressions since #137, but the most common dynamic-matrix form didn't work:

strategy:
  matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}

wrkflw validate reported Matrix must be a mapping, and wrkflw run stopped with a parse error before running anything. An expression for a single axis, such as os: ${{ fromJSON(needs.setup.outputs.os) }}, parsed but was treated as one literal value, so the job ran once with the expression text as its value.

Changes

  • MatrixConfig::expression holds a whole-matrix expression. It's set by Strategy's deserializer, so a plain mapping parses as before.
  • resolve_expressions evaluates the whole matrix first, then axes, then include/exclude.
  • A non-object matrix, a non-array axis, or a context unavailable in strategy produces a clear error. As with include/exclude, that fails the job and the rest of the run continues.
  • validate accepts the whole-matrix form and applies the same context check.

Testing

  • Unit tests in matrix and validators.
  • cargo test --workspace and clippy -D warnings pass.
  • End to end under Podman: a matrix from a job output with include and exclude expanded to the expected 4 jobs and passed matrix values to steps, an axis expression expanded to 4 jobs, and needs.*.outputs worked downstream.

Problem

Under Docker, Podman and Kubernetes, steps run in a Linux container with the workspace at /github/workspace, but the context described the host. On a Mac:

PWD=/github/workspace
GITHUB_WORKSPACE=/Users/me/repo   # doesn't exist in the container
RUNNER_OS=macOS                   # inside a Linux container

So if: runner.os == 'Linux' silently skipped steps, and cd "$GITHUB_WORKSPACE" failed. On Linux hosts runner.os was right, but the paths were still wrong. GitLab's CI_PROJECT_DIR had the same problem.

Separately, working-directory was never evaluated, so ${{ github.workspace }}/src became a literal path segment.

Changes

  • apply_container_context sets GITHUB_WORKSPACE, RUNNER_OS, RUNNER_TEMP, RUNNER_TOOL_CACHE and CI_PROJECT_DIR for container runtimes, for both GitHub and GitLab runs.
  • working-directory evaluates expressions. Paths under the workspace become relative, so the existing check that keeps steps inside the workspace still applies, including to ${{ github.workspace }}/../escape.

Emulation is unchanged: it runs on the host, so host values are correct there.

Notes

  • RUNNER_ARCH still comes from the host. It's right for native images, but not under emulated architectures.
  • Container runtimes always report Linux, since that's what wrkflw runs, including for runs-on: macos-latest.

Testing

  • Unit tests for the context override and for working-directory, including the traversal case.
  • cargo test --workspace and clippy -D warnings pass.
  • End to end under Podman on macOS, in a default job and a container: job: asserted runner.os, cd "$GITHUB_WORKSPACE", $RUNNER_TEMP, and working-directory: ${{ github.workspace }}/src.
  • Not tested end to end on Docker (the local daemon was down) or Kubernetes. Both use the same code path.