bazelbuild / bazelbuild/bazel

Support yaml marshal/unmarshal

Open
#24,766 6 comments 28 reactions 0 assignees View on GitHub
team-Loading-API
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

For all the same reasons the `json` module was added to starlark.
Note there's an implementation over here for the Go implementation of starlark https://github.com/qri-io/starlib/tree/master/encoding/yaml but I doubt that's useful in any way.

The motivation is that the `pnpm` tool needs to be integrated as a repository rule, and the data needed to fetch packages in in yaml: https://pnpm.io/git#lockfiles

As a workaround we're using the `yq` toolchain to translate yaml to json, which starlark does know how to read: https://docs.aspect.build/aspect-build/bazel-lib/v0.9.6/docs/yq-docgen.html#yq
however it's difficult in a Bazel repository rule to access a tool provided by a toolchain, and impossible under bzlmod (https://github.com/bazelbuild/bazel/issues/14445 - one module extension fetches a `yq` binary but another module extension wants to run it)

Contributor guide

Open the contributing guide

Research direction

Start by reading the existing `json` module in Starlark and the linked Go Starlark YAML implementation. Define the required marshal/unmarshal behavior from the pnpm lockfile use case, then verify that YAML data can be consumed by repository rules and module extensions without the `yq` workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
yaml
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.