Skip to content

Commit 2bf50be

Browse files
committed
ci(tooling): stabilize workflow gates and composite actions
1 parent 4db5625 commit 2bf50be

7 files changed

Lines changed: 172 additions & 54 deletions

File tree

.github/actions/failure-bundle/action.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,24 @@ runs:
2121
using: composite
2222
steps:
2323
- name: Build failure bundle
24+
env:
25+
INPUT_SCRIPT_PATH: ${{ inputs.script-path }}
26+
GITHUB_JOB_NAME: ${{ github.job }}
27+
GITHUB_RUN_ID_VALUE: ${{ github.run_id }}
28+
GITHUB_RUN_ATTEMPT_VALUE: ${{ github.run_attempt }}
2429
shell: bash
2530
run: |
2631
set -euo pipefail
2732
cd "$GITHUB_WORKSPACE"
2833
mkdir -p .runtime-cache/artifacts/ci/failure-bundles
29-
if [[ -f "${{ inputs.script-path }}" ]]; then
30-
bash "${{ inputs.script-path }}" || true
34+
if [[ -f "$INPUT_SCRIPT_PATH" ]]; then
35+
bash "$INPUT_SCRIPT_PATH" || true
3136
else
3237
{
33-
echo "missing ${{ inputs.script-path }}"
34-
echo "job=${{ github.job }}"
35-
echo "run_id=${{ github.run_id }}"
36-
echo "run_attempt=${{ github.run_attempt }}"
38+
echo "missing $INPUT_SCRIPT_PATH"
39+
echo "job=$GITHUB_JOB_NAME"
40+
echo "run_id=$GITHUB_RUN_ID_VALUE"
41+
echo "run_attempt=$GITHUB_RUN_ATTEMPT_VALUE"
3742
} > .runtime-cache/artifacts/ci/failure-bundles/MISSING_SCRIPT.txt
3843
fi
3944
- name: Upload failure bundle artifact

.github/actions/setup-deps/action.yml

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,32 @@ runs:
9494
using: composite
9595
steps:
9696
- name: Resolve toolchain versions from runtime lock
97+
env:
98+
INPUT_NODE_VERSION: ${{ inputs.node-version }}
99+
INPUT_PYTHON_VERSION: ${{ inputs.python-version }}
100+
INPUT_RUNTIME_LOCK_PATH: ${{ inputs.runtime-lock-path }}
97101
shell: bash
98102
run: |
99103
set -euo pipefail
100-
node_version="${{ inputs.node-version }}"
101-
python_version="${{ inputs.python-version }}"
102-
if [[ -f "${{ inputs.runtime-lock-path }}" ]]; then
104+
write_env_var() {
105+
local key="$1"
106+
local value="$2"
107+
local marker="EOF_${key}_$(date +%s%N)"
108+
{
109+
printf '%s<<%s\n' "$key" "$marker"
110+
printf '%s\n' "$value"
111+
printf '%s\n' "$marker"
112+
} >> "$GITHUB_ENV"
113+
}
114+
115+
node_version="$INPUT_NODE_VERSION"
116+
python_version="$INPUT_PYTHON_VERSION"
117+
if [[ -f "$INPUT_RUNTIME_LOCK_PATH" ]]; then
103118
if [[ -z "$node_version" ]]; then
104-
node_version="$(python3 -c 'import json, pathlib; payload=json.loads(pathlib.Path("${{ inputs.runtime-lock-path }}").read_text(encoding="utf-8")); print(str(payload.get("toolchain", {}).get("node", "")).strip())')"
119+
node_version="$(INPUT_RUNTIME_LOCK_PATH="$INPUT_RUNTIME_LOCK_PATH" python3 -c 'import json, os, pathlib; path = pathlib.Path(os.environ["INPUT_RUNTIME_LOCK_PATH"]); payload = json.loads(path.read_text(encoding="utf-8")); print(str(payload.get("toolchain", {}).get("node", "")).strip())')"
105120
fi
106121
if [[ -z "$python_version" ]]; then
107-
python_version="$(python3 -c 'import json, pathlib; payload=json.loads(pathlib.Path("${{ inputs.runtime-lock-path }}").read_text(encoding="utf-8")); print(str(payload.get("toolchain", {}).get("python", "")).strip())')"
122+
python_version="$(INPUT_RUNTIME_LOCK_PATH="$INPUT_RUNTIME_LOCK_PATH" python3 -c 'import json, os, pathlib; path = pathlib.Path(os.environ["INPUT_RUNTIME_LOCK_PATH"]); payload = json.loads(path.read_text(encoding="utf-8")); print(str(payload.get("toolchain", {}).get("python", "")).strip())')"
108123
fi
109124
fi
110125
if [[ -z "$node_version" ]]; then
@@ -113,8 +128,8 @@ runs:
113128
if [[ -z "$python_version" ]]; then
114129
python_version="3.11.15"
115130
fi
116-
echo "UIQ_SETUP_NODE_VERSION=$node_version" >> "$GITHUB_ENV"
117-
echo "UIQ_SETUP_PYTHON_VERSION=$python_version" >> "$GITHUB_ENV"
131+
write_env_var "UIQ_SETUP_NODE_VERSION" "$node_version"
132+
write_env_var "UIQ_SETUP_PYTHON_VERSION" "$python_version"
118133
119134
- name: Setup Node + pnpm
120135
if: ${{ inputs.enable-node == 'true' }}
@@ -126,13 +141,15 @@ runs:
126141
127142
- name: Install Node dependencies
128143
if: ${{ inputs.enable-node == 'true' && inputs.pnpm-install == 'true' }}
144+
env:
145+
INPUT_PNPM_INSTALL_COMMAND: ${{ inputs.pnpm-install-command }}
129146
shell: bash
130147
run: |
131148
set -euo pipefail
132149
cd "$GITHUB_WORKSPACE"
133150
install_log="$(mktemp)"
134151
set +e
135-
${{ inputs.pnpm-install-command }} >"$install_log" 2>&1
152+
bash -lc "$INPUT_PNPM_INSTALL_COMMAND" >"$install_log" 2>&1
136153
install_status=$?
137154
set -e
138155
if [[ "$install_status" -ne 0 ]]; then
@@ -145,7 +162,7 @@ runs:
145162
mkdir -p "${PNPM_STORE_DIR}"
146163
pnpm config set store-dir "${PNPM_STORE_DIR}"
147164
fi
148-
${{ inputs.pnpm-install-command }}
165+
bash -lc "$INPUT_PNPM_INSTALL_COMMAND"
149166
else
150167
rm -f "$install_log"
151168
exit "$install_status"
@@ -164,9 +181,21 @@ runs:
164181
165182
- name: Sync Python dependencies
166183
if: ${{ inputs.enable-python == 'true' && inputs.uv-sync == 'true' }}
184+
env:
185+
INPUT_UV_SYNC_COMMAND: ${{ inputs.uv-sync-command }}
167186
shell: bash
168187
run: |
169188
set -euo pipefail
189+
write_env_var() {
190+
local key="$1"
191+
local value="$2"
192+
local marker="EOF_${key}_$(date +%s%N)"
193+
{
194+
printf '%s<<%s\n' "$key" "$marker"
195+
printf '%s\n' "$value"
196+
printf '%s\n' "$marker"
197+
} >> "$GITHUB_ENV"
198+
}
170199
cd "$GITHUB_WORKSPACE"
171200
requested_python_version="${UIQ_SETUP_PYTHON_VERSION}"
172201
managed_python_env="${PROJECT_PYTHON_ENV:-${UV_PROJECT_ENVIRONMENT:-.runtime-cache/toolchains/python/.venv}}"
@@ -198,9 +227,9 @@ runs:
198227
fi
199228
export PROJECT_PYTHON_ENV="$managed_python_env"
200229
export UV_PROJECT_ENVIRONMENT="$managed_python_env"
201-
echo "PROJECT_PYTHON_ENV=$managed_python_env" >> "$GITHUB_ENV"
202-
echo "UV_PROJECT_ENVIRONMENT=$managed_python_env" >> "$GITHUB_ENV"
203-
${{ inputs.uv-sync-command }}
230+
write_env_var "PROJECT_PYTHON_ENV" "$managed_python_env"
231+
write_env_var "UV_PROJECT_ENVIRONMENT" "$managed_python_env"
232+
bash -lc "$INPUT_UV_SYNC_COMMAND"
204233
205234
- name: Setup Playwright
206235
if: ${{ inputs.enable-playwright == 'true' }}

.github/actions/setup-node-pnpm/action.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,20 @@ runs:
4040
shell: bash
4141
run: |
4242
set -euo pipefail
43+
write_env_var() {
44+
local key="$1"
45+
local value="$2"
46+
local marker="EOF_${key}_$(date +%s%N)"
47+
{
48+
printf '%s<<%s\n' "$key" "$marker"
49+
printf '%s\n' "$value"
50+
printf '%s\n' "$marker"
51+
} >> "$GITHUB_ENV"
52+
}
4353
store_dir="${RUNNER_TEMP}/pnpm-store"
4454
mkdir -p "$store_dir"
4555
pnpm config set store-dir "$store_dir"
46-
echo "PNPM_STORE_DIR=$store_dir" >> "$GITHUB_ENV"
56+
write_env_var "PNPM_STORE_DIR" "$store_dir"
4757
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
4858
with:
4959
node-version: ${{ inputs.node-version }}

.github/actions/setup-playwright/action.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,18 @@ runs:
3232
shell: bash
3333
run: |
3434
set -euo pipefail
35+
write_env_var() {
36+
local key="$1"
37+
local value="$2"
38+
local marker="EOF_${key}_$(date +%s%N)"
39+
{
40+
printf '%s<<%s\n' "$key" "$marker"
41+
printf '%s\n' "$value"
42+
printf '%s\n' "$marker"
43+
} >> "$GITHUB_ENV"
44+
}
3545
mkdir -p "${RUNNER_TEMP}/ms-playwright"
36-
echo "PLAYWRIGHT_BROWSERS_PATH=${RUNNER_TEMP}/ms-playwright" >> "$GITHUB_ENV"
46+
write_env_var "PLAYWRIGHT_BROWSERS_PATH" "${RUNNER_TEMP}/ms-playwright"
3747
- name: Restore Playwright browser cache
3848
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
3949
with:
@@ -48,9 +58,11 @@ runs:
4858
working-directory: ${{ inputs.working-directory }}
4959
env:
5060
PLAYWRIGHT_BROWSERS_PATH: ${{ runner.temp }}/ms-playwright
61+
INPUT_PLAYWRIGHT_BROWSER: ${{ inputs.browser }}
62+
INPUT_INSTALL_DEPS: ${{ inputs.install-deps }}
5163
run: |
52-
install_args=("${{ inputs.browser }}")
53-
if [[ "${{ inputs.install-deps }}" == "true" ]]; then
64+
install_args=("$INPUT_PLAYWRIGHT_BROWSER")
65+
if [[ "$INPUT_INSTALL_DEPS" == "true" ]]; then
5466
install_args=(--with-deps "${install_args[@]}")
5567
fi
5668
@@ -62,7 +74,7 @@ runs:
6274
else
6375
rc=$?
6476
fi
65-
if [[ "${{ inputs.install-deps }}" != "true" ]] || (( attempt >= max_attempts )); then
77+
if [[ "$INPUT_INSTALL_DEPS" != "true" ]] || (( attempt >= max_attempts )); then
6678
exit "$rc"
6779
fi
6880
echo "playwright install attempt ${attempt} failed with rc=${rc}; waiting for apt/dpkg locks to clear before retry" >&2

.github/actions/setup-python-uv/action.yml

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,74 @@ runs:
2323
using: composite
2424
steps:
2525
- name: Resolve Python version from runtime lock
26+
env:
27+
INPUT_PYTHON_VERSION: ${{ inputs.python-version }}
28+
INPUT_RUNTIME_LOCK_PATH: ${{ inputs.runtime-lock-path }}
2629
shell: bash
2730
run: |
2831
set -euo pipefail
29-
requested_python_version="${{ inputs.python-version }}"
32+
write_env_var() {
33+
local key="$1"
34+
local value="$2"
35+
local marker="EOF_${key}_$(date +%s%N)"
36+
{
37+
printf '%s<<%s\n' "$key" "$marker"
38+
printf '%s\n' "$value"
39+
printf '%s\n' "$marker"
40+
} >> "$GITHUB_ENV"
41+
}
42+
43+
requested_python_version="$INPUT_PYTHON_VERSION"
44+
requested_uv_version="$(INPUT_RUNTIME_LOCK_PATH="$INPUT_RUNTIME_LOCK_PATH" python3 -c 'import json, os, pathlib; path = pathlib.Path(os.environ["INPUT_RUNTIME_LOCK_PATH"]); print(str(json.loads(path.read_text(encoding="utf-8")).get("toolchain", {}).get("uv", "")).strip() if path.exists() else "")')"
3045
if [[ -z "$requested_python_version" ]]; then
31-
requested_python_version="$(python3 -c 'import json, pathlib; path=pathlib.Path("${{ inputs.runtime-lock-path }}"); print(str(json.loads(path.read_text(encoding="utf-8")).get("toolchain", {}).get("python", "")).strip() if path.exists() else "")')"
46+
requested_python_version="$(INPUT_RUNTIME_LOCK_PATH="$INPUT_RUNTIME_LOCK_PATH" python3 -c 'import json, os, pathlib; path = pathlib.Path(os.environ["INPUT_RUNTIME_LOCK_PATH"]); print(str(json.loads(path.read_text(encoding="utf-8")).get("toolchain", {}).get("python", "")).strip() if path.exists() else "")')"
3247
fi
3348
if [[ -z "$requested_python_version" ]]; then
3449
requested_python_version="3.11.15"
3550
fi
36-
echo "UIQ_SETUP_PYTHON_VERSION=$requested_python_version" >> "$GITHUB_ENV"
51+
if [[ -z "$requested_uv_version" ]]; then
52+
requested_uv_version="0.8.15"
53+
fi
54+
write_env_var "UIQ_SETUP_PYTHON_VERSION" "$requested_python_version"
55+
write_env_var "UIQ_SETUP_UV_VERSION" "$requested_uv_version"
3756
- name: Configure uv cache directory and lock timeout
3857
shell: bash
3958
run: |
4059
set -euo pipefail
60+
write_env_var() {
61+
local key="$1"
62+
local value="$2"
63+
local marker="EOF_${key}_$(date +%s%N)"
64+
{
65+
printf '%s<<%s\n' "$key" "$marker"
66+
printf '%s\n' "$value"
67+
printf '%s\n' "$marker"
68+
} >> "$GITHUB_ENV"
69+
}
4170
uv_cache_dir="${RUNNER_TEMP}/uv-cache"
4271
mkdir -p "$uv_cache_dir"
43-
echo "UV_CACHE_DIR=$uv_cache_dir" >> "$GITHUB_ENV"
44-
echo "UV_LOCK_TIMEOUT=1200" >> "$GITHUB_ENV"
72+
write_env_var "UV_CACHE_DIR" "$uv_cache_dir"
73+
write_env_var "UV_LOCK_TIMEOUT" "1200"
4574
- uses: astral-sh/setup-uv@d0d8abe699bfb85fec6de9f7adb5ae17292296ff # v6
4675
with:
76+
version: 0.8.15
4777
enable-cache: ${{ inputs.uv-cache }}
4878
cache-dependency-glob: ${{ inputs.uv-cache-dependency-glob }}
4979
- name: Install and activate Python via uv
5080
shell: bash
5181
run: |
5282
set -euo pipefail
83+
write_env_var() {
84+
local key="$1"
85+
local value="$2"
86+
local marker="EOF_${key}_$(date +%s%N)"
87+
{
88+
printf '%s<<%s\n' "$key" "$marker"
89+
printf '%s\n' "$value"
90+
printf '%s\n' "$marker"
91+
} >> "$GITHUB_ENV"
92+
}
93+
5394
uv python install "${UIQ_SETUP_PYTHON_VERSION}"
5495
PY_BIN="$(uv python find "${UIQ_SETUP_PYTHON_VERSION}")"
55-
echo "UV_PYTHON=$PY_BIN" >> "$GITHUB_ENV"
56-
echo "$(dirname "$PY_BIN")" >> "$GITHUB_PATH"
96+
write_env_var "UV_PYTHON" "$PY_BIN"

.github/actions/workspace-sanitize/action.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ runs:
99
using: composite
1010
steps:
1111
- name: Sanitize workspace
12+
env:
13+
INPUT_MODE: ${{ inputs.mode }}
1214
shell: bash
1315
run: |
1416
set -euo pipefail
1517
16-
mode="${{ inputs.mode }}"
18+
mode="$INPUT_MODE"
1719
workspace="${GITHUB_WORKSPACE:?GITHUB_WORKSPACE is required}"
1820
runner_temp="${RUNNER_TEMP:?RUNNER_TEMP is required}"
1921
home_dir="${HOME:-}"
@@ -61,6 +63,17 @@ runs:
6163
fi
6264
}
6365
66+
write_env_var() {
67+
local key="$1"
68+
local value="$2"
69+
local marker="EOF_${key}_$(date +%s%N)"
70+
{
71+
printf '%s<<%s\n' "$key" "$marker"
72+
printf '%s\n' "$value"
73+
printf '%s\n' "$marker"
74+
} >> "$GITHUB_ENV"
75+
}
76+
6477
case "$mode" in
6578
pre)
6679
mkdir -p \
@@ -91,14 +104,14 @@ runs:
91104
"$sanitize_tmp_dir"
92105
fi
93106
{
94-
echo "RUNNER_TOOL_CACHE=$tool_cache_dir"
95-
echo "AGENT_TOOLSDIRECTORY=$tool_cache_dir"
96-
echo "TMPDIR=$tmp_dir"
97-
echo "TMP=$tmp_dir"
98-
echo "TEMP=$tmp_dir"
99-
echo "PRE_COMMIT_HOME=$precommit_home"
100-
echo "PLAYWRIGHT_BROWSERS_PATH=$playwright_cache_dir"
101-
} >> "$GITHUB_ENV"
107+
write_env_var "RUNNER_TOOL_CACHE" "$tool_cache_dir"
108+
write_env_var "AGENT_TOOLSDIRECTORY" "$tool_cache_dir"
109+
write_env_var "TMPDIR" "$tmp_dir"
110+
write_env_var "TMP" "$tmp_dir"
111+
write_env_var "TEMP" "$tmp_dir"
112+
write_env_var "PRE_COMMIT_HOME" "$precommit_home"
113+
write_env_var "PLAYWRIGHT_BROWSERS_PATH" "$playwright_cache_dir"
114+
}
102115
;;
103116
post)
104117
cleanup_paths=(

0 commit comments

Comments
 (0)