mirror of
https://github.com/nix-community/nixvim.git
synced 2025-08-06 02:48:08 +02:00
102 lines
2.9 KiB
YAML
102 lines
2.9 KiB
YAML
name: Build
|
|
|
|
description: Builds a flake attribute, list of attributes, or a list of lists of attributes.
|
|
|
|
inputs:
|
|
attribute:
|
|
description: A single attribute to build
|
|
required: false
|
|
attributes:
|
|
description: A JSON array of attributes to build concurrently
|
|
required: false
|
|
attributeGroups:
|
|
description: A JSON object of attribute groups to build sequentially
|
|
required: false
|
|
abortOnWarn:
|
|
description: Whether to fail a build when `builtins.warn` is evaluated
|
|
type: boolean
|
|
required: false
|
|
default: true
|
|
keepGoing:
|
|
description: Whether to keep building after a failure
|
|
type: boolean
|
|
required: false
|
|
default: true
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Prepare build list
|
|
id: builds
|
|
env:
|
|
attr: ${{ inputs.attribute }}
|
|
attrs: ${{ inputs.attributes || '[]' }}
|
|
groups: ${{ inputs.attributeGroups || '{}' }}
|
|
shell: bash
|
|
run: |
|
|
set -Eeu
|
|
builds=$(
|
|
jq \
|
|
--null-input \
|
|
--compact-output \
|
|
--arg attr "$attr" \
|
|
--argjson attrs "$attrs" \
|
|
--argjson groups "$groups" \
|
|
'
|
|
$groups
|
|
| ."" = ([$attr] + $attrs)
|
|
| with_entries(select(.value | type | . == "array"))
|
|
| map_values(. - [""])
|
|
| with_entries(select(.value != []))
|
|
'
|
|
)
|
|
echo "builds=$builds" >> "$GITHUB_OUTPUT"
|
|
- name: Build
|
|
env:
|
|
builds_json: ${{ steps.builds.outputs.builds }}
|
|
keep_going_flag: ${{ inputs.keepGoing && '--keep-going' || '' }}
|
|
abort_on_warn_flag: ${{ inputs.abortOnWarn && '--abort-on-warn' || '' }}
|
|
shell: bash
|
|
run: |
|
|
ok=0
|
|
error=0
|
|
|
|
while read group_json
|
|
do
|
|
name=$(echo "$group_json" | jq --raw-output '.key')
|
|
attrs=(
|
|
$(echo "$group_json" | jq --raw-output '.value[] | ".#\(.)"')
|
|
)
|
|
if [ -n "$name" ]; then
|
|
echo "Building $name"
|
|
fi
|
|
echo "${attrs[*]}"
|
|
if nix build "${attrs[@]}" \
|
|
"$keep_going_flag" \
|
|
"$abort_on_warn_flag" \
|
|
--print-build-logs \
|
|
--log-format raw
|
|
then
|
|
echo "incrementing ok from $ok"
|
|
(( ok++ ))
|
|
echo "incremented ok to $ok"
|
|
else
|
|
echo "incrementing error from $error"
|
|
(( error++ ))
|
|
echo "incremented error to $error"
|
|
if [ -z "$keep_going_flag" ]; then
|
|
echo "Failing fast!"
|
|
exit 1
|
|
fi
|
|
fi
|
|
done < <(
|
|
echo "$builds_json" | jq --compact-output 'to_entries | .[]'
|
|
)
|
|
|
|
(
|
|
echo "$ok build groups succeeded"
|
|
echo "$error build groups failed"
|
|
) >&2
|
|
if [ "$error" -gt 0 ]; then
|
|
exit 1
|
|
fi
|