Skip to content

Commit 4e6117a

Browse files
committed
Updated scripts to allow for stable flags
1 parent a4e745d commit 4e6117a

File tree

5 files changed

+67
-22
lines changed

5 files changed

+67
-22
lines changed
Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,53 @@
1-
/^flag / { flag=$2; in_desc=0 }
2-
/^ *description:/ { in_desc=1; if ($0 ~ /\(experimental\)/) print flag; next }
3-
in_desc && /^[[:space:]]+/ { if ($0 ~ /\(experimental\)/) print flag; next }
4-
/^[^[:space:]]/ { in_desc=0 }
1+
# Purpose:
2+
# - If EXPERIMENTAL_ONLY is non-empty -> print flags that contain "(experimental)"
3+
# - If EXPERIMENTAL_ONLY is empty -> print flags that contain NO parentheses at all
4+
5+
# state variables:
6+
# flag - current flag name
7+
# in_desc - 1 when inside a description block
8+
# experimental - 1 if any desc line contains "(experimental)"
9+
# has_parens - 1 if any desc line contains any "(...)"
10+
11+
12+
/^flag[[:space:]]+/ {
13+
# finalize previous flag (if any) before starting a new one
14+
if (flag != "") {
15+
if (EXPERIMENTAL_ONLY != "" && experimental) print flag
16+
else if (EXPERIMENTAL_ONLY == "" && !has_parens) print flag
17+
}
18+
19+
# start new flag
20+
flag = $2
21+
in_desc = 0
22+
experimental = 0
23+
has_parens = 0
24+
next
25+
}
26+
27+
/^ *description:/ {
28+
# enter description; check this line for parentheses
29+
in_desc = 1
30+
if ($0 ~ /\(experimental\)/) experimental = 1
31+
if ($0 ~ /\([^)]+\)/) has_parens = 1
32+
next
33+
}
34+
35+
in_desc && /^[[:space:]]+/ {
36+
# indented description continuation lines
37+
if ($0 ~ /\(experimental\)/) experimental = 1
38+
if ($0 ~ /\([^)]+\)/) has_parens = 1
39+
next
40+
}
41+
42+
/^[^[:space:]]/ {
43+
# non-indented line ends any description block
44+
in_desc = 0
45+
}
46+
47+
END {
48+
# finalize last flag at EOF
49+
if (flag != "") {
50+
if (EXPERIMENTAL_ONLY != "" && experimental) print flag
51+
else if (EXPERIMENTAL_ONLY == "" && !has_parens) print flag
52+
}
53+
}

.github/scripts/add_experimental_flags.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,20 @@ fi
1717

1818
MATRIX_JSON=$(sed -E 's/^matrix=//' <"$MATRIX_FILE")
1919

20-
readarray -t EXP_FLAGS < <(awk -f ./.github/script_helpers/extract_flags.awk "$CABAL_FILE")
20+
readarray -t STABLE_FLAGS < <(awk -f ./.github/script_helpers/extract_flags.awk "$CABAL_FILE")
21+
readarray -t EXP_FLAGS < <(awk -v EXPERIMENTAL_ONLY=1 -f ./.github/script_helpers/extract_flags.awk "$CABAL_FILE")
2122

22-
ORIGINAL=$(jq --arg label "stable" '.include[0] += {label: $label}' <<<"$MATRIX_JSON")
23+
STABLE_FLAGS_STRING=""
24+
if ! [[ ${#STABLE_FLAGS[@]} -eq 0 ]]; then
25+
STABLE_FLAGS_STRING=$(printf '+%s ' "${STABLE_FLAGS[@]}")
26+
fi
27+
ORIGINAL=$(jq --arg flags "$STABLE_FLAGS_STRING" --arg label "stable" '.include[0] += {flags: $flags, label: $label}' <<<"$MATRIX_JSON")
2328

2429
if [[ ${#EXP_FLAGS[@]} -eq 0 ]]; then
2530
UPDATED="$ORIGINAL"
2631
else
2732
EXP_FLAGS_STRING=$(printf '+%s ' "${EXP_FLAGS[@]}")
28-
EXPERIMENTAL=$(jq --arg flags "$EXP_FLAGS_STRING" --arg label "experimental" \
33+
EXPERIMENTAL=$(jq --arg flags "$STABLE_FLAGS_STRING $EXP_FLAGS_STRING" --arg label "experimental" \
2934
'.include[0] += {flags: $flags, label: $label}' <<<"$MATRIX_JSON")
3035

3136
UPDATED=$(jq --argjson exp_include "$(jq '.include' <<<"$EXPERIMENTAL")" \

.github/scripts/configure_project.sh

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,10 @@
22

33
set -euo pipefail
44

5-
IS_EXPERIMENTAL=0
6-
75
cabal configure --project-file cabal.project.release -O1
86

9-
if [[ "$LABEL" == "" ]]; then
10-
echo "LABEL must be set"
11-
elif [[ "$LABEL" == "experimental" ]]; then
12-
IS_EXPERIMENTAL=1
13-
fi
14-
15-
echo "package jbeam-edit" >>cabal.project.release.local
16-
echo " tests: True" >>cabal.project.release.local
17-
if [[ $IS_EXPERIMENTAL -eq 1 ]]; then
7+
printf "package jbeam-edit\n tests: True\n" >>cabal.project.release.local
8+
if ! [[ "$MATRIX_FLAGS" == "" ]]; then
189
echo " flags: $MATRIX_FLAGS" >>cabal.project.release.local
1910
fi
2011

jbeam-edit.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ source-repository head
4545
location: https://github.com/webdevred/jbeam-edit
4646

4747
flag dump-ast
48-
description: Enable building the dump-ast executable
48+
description: Enable building the dump-ast executable (dev-only)
4949
default: False
5050
manual: True
5151

@@ -61,7 +61,7 @@ flag transformation
6161

6262
flag windows-example-paths
6363
description:
64-
Use executable-relative example paths (for Windows release builds)
64+
Use executable-relative example paths (windows-installer-only)
6565

6666
default: False
6767
manual: True

package.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ ghc-options:
5454

5555
flags:
5656
dump-ast:
57-
description: Enable building the dump-ast executable
57+
description: Enable building the dump-ast executable (dev-only)
5858
manual: true
5959
default: false
6060
transformation:
@@ -66,7 +66,7 @@ flags:
6666
manual: true
6767
default: false
6868
windows-example-paths:
69-
description: Use executable-relative example paths (for Windows release builds)
69+
description: Use executable-relative example paths (windows-installer-only)
7070
default: false
7171
manual: true
7272

0 commit comments

Comments
 (0)