Skip to content

chore: promote next to main #15

chore: promote next to main

chore: promote next to main #15

---
name: Promotion Readiness
on:
pull_request:
branches: [main]
types: [opened, reopened, synchronize, ready_for_review]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
jobs:
zsh:
name: Zsh syntax and compile
runs-on: ubuntu-latest
steps:
- name: Check out the candidate
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Install Zsh and archive tools
run: sudo apt-get update && sudo apt-get install -yq zsh zip unzip
- name: Check and compile Zsh sources
shell: bash
run: |
set -euo pipefail
checked=0
while IFS= read -r -d '' file; do
zsh -n "${file}"
zsh -fc 'zcompile "$1"' _ "${file}"
rm -f "${file}.zwc"
checked=$((checked + 1))
done < <(
find . -type d -name doc -prune -o \
-type f \( -name '*.zsh' -o -name '_zi' \) -print0
)
if ((checked == 0)); then
echo "::error::No Zsh sources were found."
exit 1
fi
- name: Test version reporting
run: zsh tests/version-reporting.zsh
- name: Test self-update reload when present
if: ${{ hashFiles('tests/self-update-reload.zsh') != '' }}
run: zsh -f tests/self-update-reload.zsh
- name: Test path resolution when present
if: ${{ hashFiles('tests/path-resolution.zsh') != '' }}
run: zsh -f tests/path-resolution.zsh
- name: Test archive extraction when present
if: ${{ hashFiles('tests/archive-extraction.zsh') != '' }}
run: zsh tests/archive-extraction.zsh
- name: Test completion refresh when present
if: ${{ hashFiles('tests/completion-refresh.zsh') != '' }}
run: zsh tests/completion-refresh.zsh
- name: Test snippet directory mirror when present
if: ${{ hashFiles('tests/snippet-directory-mirror.zsh') != '' }}
run: zsh -f tests/snippet-directory-mirror.zsh
zd:
name: ZD integration
uses: z-shell/zd/.github/workflows/test-native.yml@fd0995d6f7958fea6c4abbc4fff81a6da2277b66 # z-shell/zd#95, #96, #107
with:
zi_repo: ${{ github.event.pull_request.head.repo.full_name }}
zi_ref: ${{ github.event.pull_request.head.sha }}
include_compat: ${{ github.head_ref == 'next' }}
trunk:
name: Trunk
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
steps:
- name: Check out the candidate
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
with:
fetch-depth: 0
- name: Run Trunk
uses: trunk-io/trunk-action@e1234e67a86010d61ddac8d8ebf4b783e2ffd2fa
codeql:
name: CodeQL
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
security-events: write
steps:
- name: Check out the candidate
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Initialize CodeQL
uses: github/codeql-action/init@db488ddef3bf6cb639b32c2e9a7c0a7ea8271d28 # v4.37.8
with:
build-mode: none
languages: actions
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@db488ddef3bf6cb639b32c2e9a7c0a7ea8271d28 # v4.37.8
with:
category: /language:actions
clean-install:
name: Clean install and startup
runs-on: ubuntu-latest
steps:
- name: Install Zsh
run: sudo apt-get update && sudo apt-get install -yq zsh
- name: Install and start the exact candidate
shell: bash
env:
CANDIDATE_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
CANDIDATE_SHA: ${{ github.event.pull_request.head.sha }}
run: |
set -euo pipefail
checkout="${RUNNER_TEMP}/zi-candidate"
data_root="${RUNNER_TEMP}/zi-fresh-data"
test ! -e "${checkout}"
test ! -e "${data_root}"
git init "${checkout}"
git -C "${checkout}" remote add origin \
"https://github.com/${CANDIDATE_REPOSITORY}.git"
git -C "${checkout}" fetch --no-tags --depth 1 origin -- \
"${CANDIDATE_SHA}"
git -C "${checkout}" checkout --detach FETCH_HEAD
test "$(git -C "${checkout}" rev-parse HEAD)" = "${CANDIDATE_SHA}"
mkdir -p \
"${data_root}/home" \
"${data_root}/cache" \
"${data_root}/config"
env \
CANDIDATE_SHA="${CANDIDATE_SHA}" \
HOME="${data_root}/home" \
XDG_CACHE_HOME="${data_root}/cache" \
XDG_CONFIG_HOME="${data_root}/config" \
XDG_DATA_HOME="${data_root}/data" \
ZDOTDIR="${data_root}/zdotdir" \
ZI_CHECKOUT="${checkout}" \
zsh -f <<'ZSH'
builtin source "${ZI_CHECKOUT}/zi.zsh" || exit 1
[[ ${ZI[BIN_DIR]} = ${ZI_CHECKOUT} ]] || exit 1
[[ "$(git -C "${ZI[BIN_DIR]}" rev-parse HEAD)" = ${CANDIDATE_SHA} ]] ||
exit 1
(( ${+functions[zi]} )) || exit 1
.zi-prepare-home || exit 1
[[ ${ZI[HOME_DIR]} = ${XDG_DATA_HOME}/zi ]] || exit 1
[[ ${ZI[CACHE_DIR]} = ${XDG_CACHE_HOME}/zi ]] || exit 1
[[ ${ZI[CONFIG_DIR]} = ${XDG_CONFIG_HOME}/zi ]] || exit 1
[[ -d ${ZI[HOME_DIR]} ]] || exit 1
ZSH
gate:
name: Promotion gate
if: ${{ always() }}
needs: [zsh, zd, trunk, codeql, clean-install]
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Require every promotion validation
env:
ZSH_RESULT: ${{ needs.zsh.result }}
ZD_RESULT: ${{ needs.zd.result }}
TRUNK_RESULT: ${{ needs.trunk.result }}
CODEQL_RESULT: ${{ needs.codeql.result }}
CLEAN_INSTALL_RESULT: ${{ needs.clean-install.result }}
run: |
failed=0
for result_name in \
ZSH_RESULT \
ZD_RESULT \
TRUNK_RESULT \
CODEQL_RESULT \
CLEAN_INSTALL_RESULT
do
result="${!result_name}"
if [[ "${result}" != success ]]; then
echo "::error::${result_name} was '${result}', not 'success'."
failed=1
fi
done
exit "${failed}"