Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI script: use jq to filter and output final format; ensure default target dir #325

Merged
merged 11 commits into from
Aug 29, 2024
31 changes: 20 additions & 11 deletions scripts/run-ci-build.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
#!/bin/bash

# TODO -euo pipefail isn't optimal but I haven't got the energy to improve further -Anatol
set -euxo pipefail

# ensure cargo builds in the default directory (./target)
unset CARGO_TARGET_DIR

# the old filter removed crowtty and manganese, but manganese isn't in deps anymore
# TODO crowtty is currently being filtered because of netlify; when we migrate off of them
# the del part can be done away with.
#
# explanation of jq pipe:
# 1. extract only contents of `workspace_default_members`
# 2. remove entries containing the string "crowtty"
# 3. split each element on " ", and keep the first item of the split result
# 4. convert each element to a `{key: array_idx, value: elem_value}` dict
# 5. map these dicts to "-p elem_dict['value']"

defaultmembers=$( \
cargo metadata --format-version 1 | \
jq .workspace_default_members | \
grep -E ' ".*' | \
# crowtty's dependencies can't easily be installed on netlify
grep -v 'crowtty' | \
# manganese depends on `libudev` (transitive dep via one of its' bindeps)
# which can't be installed on CI.
grep -v 'manganese' | \
cut -d" " -f3 | \
cut -d'"' -f2 | \
sed -E 's/(.*)/-p \1 /g' | \
tr -d '\n' \
jq -r '.workspace_default_members
| del(.[] | select(contains("crowtty")))
| [ .[] | split(" ")[0] ]
| to_entries[]
|"-p \(.value)"'
)

./just docs --document-private-items $defaultmembers
Expand Down
Loading