Skip to content

Merge pull request #31 from kosli-dev/20260624_fix_tag_ancestry #30

Merge pull request #31 from kosli-dev/20260624_fix_tag_ancestry

Merge pull request #31 from kosli-dev/20260624_fix_tag_ancestry #30

Workflow file for this run

name: Tests
on:
push:
branches:
- main
pull_request: {}
workflow_dispatch: {}
defaults:
run:
shell: bash
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
version: ["2.11.27", "2", "2.11", "latest"]
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Install deps and build
run: npm ci && npm run build
- name: Run unit tests
run: npm test
- name: Setup kosli CLI
id: setup
uses: ./
with:
version: ${{ matrix.version }}
- name: Capture kosli version installed
run: |
export KOSLI_VERSION=$( kosli version --short)
echo 'KOSLI_VERSION_INSTALLED<<EOF' >> $GITHUB_ENV
kosli version --short >> $GITHUB_ENV
echo "\n" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Verify pinned version
if: matrix.version != 'latest'
shell: python
env:
KOSLI_VERSION_EXPECTED: ${{ matrix.version }}
run: |
import os, sys
expected = os.environ["KOSLI_VERSION_EXPECTED"].strip()
installed = os.environ["KOSLI_VERSION_INSTALLED"].strip().splitlines()[0].strip()
# `kosli version --short` prints a leading "v" (e.g. v2.11.27); normalise it.
if installed.startswith("v"):
installed = installed[1:]
# Exact pin: installed must equal it. Major/minor pin (e.g. "2" or "2.11"):
# installed must sit inside that line, which also proves we never crossed
# into a higher major.
ok = installed == expected or installed.startswith(expected + ".")
if not ok:
print(f"expected version {expected!r}, but installed {installed!r}")
sys.exit(1)
- name: Verify latest resolved to a semver
if: matrix.version == 'latest'
shell: python
env:
KOSLI_VERSION_RESOLVED: ${{ steps.setup.outputs.version }}
run: |
import os, re, sys
installed = os.environ["KOSLI_VERSION_INSTALLED"].strip()
resolved = os.environ["KOSLI_VERSION_RESOLVED"].strip()
if not re.match(r"^\d+\.\d+\.\d+", resolved):
print(f"resolved version {resolved!r} does not look like semver")
sys.exit(1)
if resolved not in installed:
print(f"resolved {resolved!r} not found in installed {installed!r}")
sys.exit(1)