Skip to content

Commit 48b2731

Browse files
committed
feat: initial implementation of setup-vlt GitHub Action
- Complete TypeScript implementation with vlt installation via npm - Support for version specification (latest, specific, semver ranges) - Version file support (package.json engines.vlt, packageManager, .vlt-version) - Intelligent caching with @actions/cache for faster subsequent runs - Cross-platform support (Ubuntu, macOS, Windows) - Custom registry URL support - Comprehensive test suite with unit and integration tests - Full CI/CD pipeline with linting, building, and testing - Post action for cache saving - Complete documentation and usage examples Outputs: - vlt-version: Installed version - vlt-path: Path to vlt executable - cache-hit: Whether cache was used Binaries available: vlt, vlr, vlx, vlrx, vlxl
1 parent d0d5b8c commit 48b2731

19 files changed

Lines changed: 7954 additions & 2 deletions

.eslintrc.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"parser": "@typescript-eslint/parser",
3+
"plugins": ["@typescript-eslint"],
4+
"extends": ["eslint:recommended"],
5+
"parserOptions": {
6+
"ecmaVersion": 2022,
7+
"sourceType": "module"
8+
},
9+
"env": {
10+
"node": true,
11+
"es2022": true,
12+
"jest": true
13+
},
14+
"rules": {
15+
"prefer-const": "error",
16+
"no-var": "error"
17+
},
18+
"ignorePatterns": ["dist/", "node_modules/", "*.js"]
19+
}

.github/workflows/ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
name: Build and Test
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
cache: 'npm'
23+
24+
- name: Install dependencies
25+
run: npm ci
26+
27+
- name: Lint
28+
run: npm run lint
29+
30+
- name: Format check
31+
run: npm run format -- --check
32+
33+
- name: Build
34+
run: npm run build
35+
36+
- name: Test
37+
run: npm test
38+
39+
- name: Check dist is up to date
40+
run: |
41+
npm run build
42+
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
43+
echo "Detected uncommitted changes after build. See status below:"
44+
git diff
45+
exit 1
46+
fi
47+
id: diff
48+
49+
- name: Upload dist artifacts
50+
if: failure() && steps.diff.conclusion == 'failure'
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: dist
54+
path: dist/

.github/workflows/test.yml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: Integration Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
name: Test on ${{ matrix.os }}
12+
runs-on: ${{ matrix.os }}
13+
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, macos-latest, windows-latest]
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Test setup-vlt with latest version
23+
uses: ./
24+
id: setup-latest
25+
with:
26+
vlt-version: 'latest'
27+
28+
- name: Verify vlt installation (latest)
29+
run: |
30+
vlt --version
31+
echo "Installed version: ${{ steps.setup-latest.outputs.vlt-version }}"
32+
echo "vlt path: ${{ steps.setup-latest.outputs.vlt-path }}"
33+
echo "Cache hit: ${{ steps.setup-latest.outputs.cache-hit }}"
34+
35+
- name: Test vlt basic functionality
36+
run: |
37+
vlt --help
38+
vlr --help || true # vlr might not have help
39+
vlx --help || true # vlx might not have help
40+
41+
- name: Test setup-vlt with specific version
42+
uses: ./
43+
id: setup-specific
44+
with:
45+
vlt-version: '1.0.0-rc.18'
46+
47+
- name: Verify vlt installation (specific version)
48+
run: |
49+
vlt --version
50+
echo "Installed version: ${{ steps.setup-specific.outputs.vlt-version }}"
51+
52+
test-version-file:
53+
name: Test version file support
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
60+
- name: Create .vlt-version file
61+
run: echo '1.0.0-rc.18' > .vlt-version
62+
63+
- name: Test setup-vlt with version file
64+
uses: ./
65+
id: setup-version-file
66+
with:
67+
vlt-version-file: '.vlt-version'
68+
69+
- name: Verify version from file
70+
run: |
71+
vlt --version
72+
echo "Installed version: ${{ steps.setup-version-file.outputs.vlt-version }}"
73+
74+
- name: Create package.json with engines.vlt
75+
run: |
76+
cat > package.json << 'EOF'
77+
{
78+
"name": "test-package",
79+
"engines": {
80+
"vlt": "^1.0.0"
81+
}
82+
}
83+
EOF
84+
85+
- name: Test setup-vlt with package.json
86+
uses: ./
87+
id: setup-package-json
88+
with:
89+
vlt-version-file: 'package.json'
90+
91+
- name: Verify version from package.json
92+
run: |
93+
vlt --version
94+
echo "Installed version: ${{ steps.setup-package-json.outputs.vlt-version }}"
95+
96+
test-caching:
97+
name: Test caching functionality
98+
runs-on: ubuntu-latest
99+
100+
steps:
101+
- name: Checkout
102+
uses: actions/checkout@v4
103+
104+
- name: Test setup-vlt with caching (first run)
105+
uses: ./
106+
id: setup-cache-1
107+
with:
108+
vlt-version: '1.0.0-rc.18'
109+
110+
- name: Verify first installation
111+
run: |
112+
echo "First run cache hit: ${{ steps.setup-cache-1.outputs.cache-hit }}"
113+
vlt --version
114+
115+
- name: Test setup-vlt with caching (second run)
116+
uses: ./
117+
id: setup-cache-2
118+
with:
119+
vlt-version: '1.0.0-rc.18'
120+
121+
- name: Verify cache behavior
122+
run: |
123+
echo "Second run cache hit: ${{ steps.setup-cache-2.outputs.cache-hit }}"
124+
vlt --version
125+
126+
- name: Test setup-vlt with no-cache
127+
uses: ./
128+
id: setup-no-cache
129+
with:
130+
vlt-version: '1.0.0-rc.18'
131+
no-cache: 'true'
132+
133+
- name: Verify no-cache behavior
134+
run: |
135+
echo "No-cache run cache hit: ${{ steps.setup-no-cache.outputs.cache-hit }}"
136+
vlt --version

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build outputs (except dist/ which is committed for GitHub Actions)
5+
lib/
6+
coverage/
7+
8+
# Runtime files
9+
*.log
10+
npm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
14+
# OS generated files
15+
.DS_Store
16+
.DS_Store?
17+
._*
18+
.Spotlight-V100
19+
.Trashes
20+
ehthumbs.db
21+
Thumbs.db
22+
23+
# IDEs
24+
.vscode/
25+
.idea/
26+
*.swp
27+
*.swo
28+
*~
29+
30+
# Temporary files
31+
*.tmp
32+
*.temp
33+
34+
# Environment variables
35+
.env
36+
.env.local
37+
.env.*.local
38+
39+
# Test outputs
40+
junit.xml

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"semi": true,
3+
"trailingComma": "es5",
4+
"singleQuote": true,
5+
"printWidth": 100,
6+
"tabWidth": 2,
7+
"useTabs": false
8+
}

0 commit comments

Comments
 (0)