|
| 1 | +name: CI |
| 2 | + |
| 3 | +# Validates the eidolons CLI on every push and PR: |
| 4 | +# - lint: shellcheck + schema validation |
| 5 | +# - install-e2e: curl-pipe install against the checkout on Ubuntu + macOS, |
| 6 | +# with and without a pre-existing yq, to guarantee the |
| 7 | +# bootstrap works on a bare box (the ModuleNotFoundError |
| 8 | +# for PyYAML must never reach a user again) |
| 9 | +# - cli-tests: bats suite covering every command end-to-end |
| 10 | + |
| 11 | +on: |
| 12 | + push: |
| 13 | + branches: [main] |
| 14 | + pull_request: |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +jobs: |
| 18 | + lint: |
| 19 | + name: Lint |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Install shellcheck + yq + jq |
| 25 | + run: | |
| 26 | + sudo apt-get update |
| 27 | + sudo apt-get install -y shellcheck jq |
| 28 | + sudo wget -qO /usr/local/bin/yq \ |
| 29 | + https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64 |
| 30 | + sudo chmod +x /usr/local/bin/yq |
| 31 | +
|
| 32 | + - name: shellcheck all shell scripts (error severity) |
| 33 | + run: | |
| 34 | + set -e |
| 35 | + # -S error = block merges only on real errors, not style/info. |
| 36 | + # Warnings are surfaced but non-blocking; promote to -S warning |
| 37 | + # once the existing warnings are cleaned up. |
| 38 | + find cli -name '*.sh' -type f -print0 | xargs -0 shellcheck -x -S error |
| 39 | + shellcheck -x -S error cli/eidolons |
| 40 | +
|
| 41 | + - name: Validate JSON schemas parse |
| 42 | + run: | |
| 43 | + for schema in schemas/*.json; do |
| 44 | + jq empty "$schema" |
| 45 | + done |
| 46 | +
|
| 47 | + - name: Validate roster/index.yaml required fields |
| 48 | + run: | |
| 49 | + set -euo pipefail |
| 50 | + yq eval '.' roster/index.yaml > /tmp/roster.json |
| 51 | + for name in $(jq -r '.eidolons[].name' /tmp/roster.json); do |
| 52 | + jq -e --arg n "$name" '.eidolons[] | select(.name == $n) | |
| 53 | + .methodology.name and .methodology.version and .methodology.cycle and |
| 54 | + .source.repo and |
| 55 | + .versions.latest and |
| 56 | + .handoffs.upstream and .handoffs.downstream' \ |
| 57 | + /tmp/roster.json > /dev/null || { echo "::error::$name missing required fields"; exit 1; } |
| 58 | + done |
| 59 | +
|
| 60 | + install-e2e: |
| 61 | + name: Install — ${{ matrix.os }} / yq=${{ matrix.yq }} |
| 62 | + runs-on: ${{ matrix.os }} |
| 63 | + strategy: |
| 64 | + fail-fast: false |
| 65 | + matrix: |
| 66 | + os: [ubuntu-latest, macos-latest] |
| 67 | + yq: [preinstalled, absent] |
| 68 | + steps: |
| 69 | + - uses: actions/checkout@v4 |
| 70 | + |
| 71 | + - name: Install jq |
| 72 | + run: | |
| 73 | + if [[ "$RUNNER_OS" == "Linux" ]]; then |
| 74 | + sudo apt-get update && sudo apt-get install -y jq |
| 75 | + else |
| 76 | + brew install jq |
| 77 | + fi |
| 78 | +
|
| 79 | + - name: Remove any pre-existing yq (matrix.yq=absent) |
| 80 | + if: matrix.yq == 'absent' |
| 81 | + run: | |
| 82 | + for p in /usr/local/bin/yq /usr/bin/yq /opt/homebrew/bin/yq "$HOME/.local/bin/yq"; do |
| 83 | + [[ -e "$p" ]] && sudo rm -f "$p" || true |
| 84 | + done |
| 85 | + # Ubuntu runners may have yq via snap too. |
| 86 | + command -v yq && sudo rm -f "$(command -v yq)" || true |
| 87 | + if command -v yq >/dev/null 2>&1; then |
| 88 | + echo "::error::yq still on PATH after cleanup: $(command -v yq)" |
| 89 | + exit 1 |
| 90 | + fi |
| 91 | +
|
| 92 | + - name: Ensure yq is present (matrix.yq=preinstalled) |
| 93 | + if: matrix.yq == 'preinstalled' |
| 94 | + run: | |
| 95 | + if ! command -v yq >/dev/null 2>&1; then |
| 96 | + if [[ "$RUNNER_OS" == "Linux" ]]; then |
| 97 | + sudo wget -qO /usr/local/bin/yq \ |
| 98 | + https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64 |
| 99 | + sudo chmod +x /usr/local/bin/yq |
| 100 | + else |
| 101 | + brew install yq |
| 102 | + fi |
| 103 | + fi |
| 104 | +
|
| 105 | + - name: Run install.sh against the checkout |
| 106 | + env: |
| 107 | + EIDOLONS_REPO: file://${{ github.workspace }} |
| 108 | + EIDOLONS_REF: ${{ github.sha }} |
| 109 | + EIDOLONS_HOME: ${{ github.workspace }}/.e2e-home |
| 110 | + EIDOLONS_BIN_DIR: ${{ github.workspace }}/.e2e-bin |
| 111 | + run: | |
| 112 | + set -euo pipefail |
| 113 | + bash cli/install.sh |
| 114 | + "$EIDOLONS_BIN_DIR/eidolons" version |
| 115 | + # yq must exist after install regardless of matrix.yq. |
| 116 | + command -v yq >/dev/null 2>&1 || [[ -x "$EIDOLONS_BIN_DIR/yq" ]] |
| 117 | +
|
| 118 | + - name: Reproduce the original user bug (list --available must work) |
| 119 | + env: |
| 120 | + EIDOLONS_HOME: ${{ github.workspace }}/.e2e-home |
| 121 | + EIDOLONS_BIN_DIR: ${{ github.workspace }}/.e2e-bin |
| 122 | + run: | |
| 123 | + export PATH="$EIDOLONS_BIN_DIR:$PATH" |
| 124 | + # This is the exact invocation that was failing with |
| 125 | + # ModuleNotFoundError: No module named 'yaml'. |
| 126 | + eidolons list --available |
| 127 | +
|
| 128 | + - name: Second install run is idempotent |
| 129 | + env: |
| 130 | + EIDOLONS_REPO: file://${{ github.workspace }} |
| 131 | + EIDOLONS_REF: ${{ github.sha }} |
| 132 | + EIDOLONS_HOME: ${{ github.workspace }}/.e2e-home |
| 133 | + EIDOLONS_BIN_DIR: ${{ github.workspace }}/.e2e-bin |
| 134 | + run: | |
| 135 | + bash cli/install.sh |
| 136 | + "$EIDOLONS_BIN_DIR/eidolons" version |
| 137 | +
|
| 138 | + cli-tests: |
| 139 | + name: CLI tests (bats) — ${{ matrix.os }} |
| 140 | + runs-on: ${{ matrix.os }} |
| 141 | + needs: lint |
| 142 | + strategy: |
| 143 | + fail-fast: false |
| 144 | + matrix: |
| 145 | + os: [ubuntu-latest, macos-latest] |
| 146 | + steps: |
| 147 | + - uses: actions/checkout@v4 |
| 148 | + |
| 149 | + - name: Install prerequisites (jq, yq, bats) |
| 150 | + run: | |
| 151 | + if [[ "$RUNNER_OS" == "Linux" ]]; then |
| 152 | + sudo apt-get update |
| 153 | + sudo apt-get install -y jq bats |
| 154 | + sudo wget -qO /usr/local/bin/yq \ |
| 155 | + https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64 |
| 156 | + sudo chmod +x /usr/local/bin/yq |
| 157 | + else |
| 158 | + brew install jq yq bats-core |
| 159 | + fi |
| 160 | +
|
| 161 | + - name: Make CLI executable |
| 162 | + run: chmod +x cli/eidolons cli/src/*.sh cli/install.sh |
| 163 | + |
| 164 | + - name: Run bats suite |
| 165 | + run: bats cli/tests/ |
0 commit comments