-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (71 loc) · 2.55 KB
/
Copy pathtest.yaml
File metadata and controls
80 lines (71 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- 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)