Skip to content

Commit 00d3774

Browse files
retepsclaude
andauthored
Add CI workflow for running tests (#271)
* Add CI workflow for running tests Adds a GitHub Actions workflow that runs tests on push and pull requests to the main branch. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use cross-platform sed in doc.sh for CI compatibility The macOS-specific `sed -i ''` syntax doesn't work on Linux. Added the sedi() wrapper function that handles both platforms. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: use HOME env var in test for CI compatibility TERM is not available in CI environments (no terminal). HOME is available in both local and CI environments. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 69b6991 commit 00d3774

3 files changed

Lines changed: 37 additions & 5 deletions

File tree

.github/workflows/test.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '22'
20+
cache: 'npm'
21+
22+
- name: Install dependencies
23+
run: npm ci
24+
25+
- name: Run tests
26+
run: npm test

scripts/doc.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ export LINECLEAR="\033[1G\033[2K" # position to column 1; erase whole line
1616
export DIM="\033[0;2m"
1717
export RESET="\033[0;0m"
1818

19+
# Note on the `sed` command:
20+
# On Linux, the -i switch can be used without an extension argument
21+
# On macOS, the -i switch must be followed by an extension argument (which can be empty)
22+
sedi () {
23+
sed --version >/dev/null 2>&1 && sed -i -- "$@" || sed -i '' "$@"
24+
}
1925

2026
printf $BASENAME$DOT$RESET" Building api.md"
2127

@@ -43,9 +49,9 @@ mv ./temp-docs/common ./temp-docs/03
4349
npx concat-md --decrease-title-levels --dir-name-as-title --hide-anchor-links ./temp-docs > ./src/api.md
4450

4551
# Remove `# 01`, `# 02`, `# 03` from the api.md
46-
sed -i '' 's/# 01//g' ./src/api.md
47-
sed -i '' 's/# 02//g' ./src/api.md
48-
sed -i '' 's/# 03//g' ./src/api.md
52+
sedi 's/# 01//g' ./src/api.md
53+
sedi 's/# 02//g' ./src/api.md
54+
sedi 's/# 03//g' ./src/api.md
4955

5056
#rm -rf ./temp-docs
5157

test/cortex/cortex-parse.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ describe('CORTEX PARSING DIRECTIVES', () => {
3131
expect(validUa).toBe(true);
3232
});
3333
test('Environment variable directive', () => {
34-
expect(validCortex('#env("TERM")')).toStrictEqual({
35-
str: process.env['TERM'],
34+
expect(validCortex('#env("HOME")')).toStrictEqual({
35+
str: process.env['HOME'],
3636
});
3737
});
3838
test('Warning directive', () => {

0 commit comments

Comments
 (0)