Repository navigation
146 lines (123 loc) · 4.51 KB
/
Copy pathci.yml
File metadata and controls
146 lines (123 loc) · 4.51 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: CI
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
test:
name: Typecheck and test (Node ${{ matrix.node }})
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
# Both majors package.json's engines field claims to support.
node: [20, 22]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: npm
# The optional audio deps (mic, speaker) only matter for `npm run call`;
# npm tolerates their native build failing on a headless runner.
- run: npm ci
- run: npm run build
- run: npm test
repository:
# The tests that start a test runner of their own: the suite run inside
# copies of a repository, with every file compared before and after. Only
# in the engine's own repository; a repository built from this one has no
# use for it.
name: The suite leaves its repository alone
if: github.repository == 'VapiAI/gitops'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run test:repository
actionlint:
name: Lint workflows (actionlint)
runs-on: ubuntu-latest
timeout-minutes: 5
env:
# Pinned version and the sha256 published with that release, so the
# linter can't change underneath us. shellcheck (preinstalled on the
# runner) lints the bash in every `run:` step too.
ACTIONLINT_VERSION: 1.7.12
ACTIONLINT_SHA256: 8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8
steps:
- uses: actions/checkout@v4
- name: Install actionlint
run: |
set -euo pipefail
tarball="actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz"
curl -fsSL -o "$tarball" \
"https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/${tarball}"
echo "${ACTIONLINT_SHA256} ${tarball}" | sha256sum --check --strict
tar -xzf "$tarball" actionlint
- name: Lint workflows
run: ./actionlint -color
validate:
name: Validate resources
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
# Install scripts only build the optional audio deps for `npm run call`.
- run: npm ci --ignore-scripts
# The same validator `apply` runs before every deploy, here before merge:
# a config that `apply` would refuse never reaches main, where it would
# block deploys and promotion until someone noticed. Every org is
# validated, including resources no PR check targets.
#
# `validate` makes no network call, but loading the engine's config
# needs a key to be set. The placeholder below is never sent anywhere
# (the base URL is unroutable, so an accidental API call fails here),
# and no secret is available to this job, so it runs the same on forks.
# `.ts` resources run without `.env.<org>` here, unlike under `apply`.
- name: Validate every org
shell: bash
env:
VAPI_PRIVATE_API_KEY: validate-only-never-sent
VAPI_BASE_URL: http://127.0.0.1:9
run: |
set -euo pipefail
shopt -s nullglob
orgs=()
for dir in resources/*/; do
orgs+=("$(basename "$dir")")
done
if (( ${#orgs[@]} == 0 )); then
echo "No org folders under resources/; nothing to validate."
exit 0
fi
failed=()
for org in "${orgs[@]}"; do
echo "::group::Validate ${org}"
if ! node --import tsx src/validate-cmd.ts "$org"; then
failed+=("$org")
fi
echo "::endgroup::"
done
if (( ${#failed[@]} > 0 )); then
echo "::error::Validation failed for: ${failed[*]}. Each org's findings are in its log group above. To reproduce locally without that org's key: VAPI_PRIVATE_API_KEY=validate-only npm run validate -- <org>"
exit 1
fi
echo "Validated ${#orgs[@]} org(s): ${orgs[*]}"