Skip to content

Commit a907e3f

Browse files
Add GitHub Actions workflow for automated testing (#15) (#29)
1 parent b5165d3 commit a907e3f

File tree

4 files changed

+71
-8
lines changed

4 files changed

+71
-8
lines changed

.github/workflows/test.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Test fastify-swc-server CLI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
token: ${{ secrets.GITHUB_TOKEN }}
18+
fetch-depth: 1
19+
20+
- name: Configure Git for HTTPS
21+
run: |
22+
git config --global url."https://github.com/".insteadOf "[email protected]:"
23+
24+
- name: Validate Git Connection
25+
run: git ls-remote https://github.com/${{ github.repository }} || (echo "HTTPS Git connection failed" && exit 1)
26+
27+
- name: Set up pnpm
28+
uses: pnpm/action-setup@v4
29+
with:
30+
version: "8.6.0"
31+
32+
- name: Set up Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: "lts/*"
36+
cache: pnpm
37+
38+
- name: Install dependencies (skip prepare script)
39+
run: pnpm install --ignore-scripts
40+
41+
- name: Pack and install CLI globally
42+
run: |
43+
npm pack
44+
sudo npm install -g $(ls fastify-swc-typescript-server-bootstrap-cli-*.tgz)
45+
fastify-swc-server || echo "CLI installation verified"
46+
47+
- name: Test CLI Functionality
48+
run: |
49+
fastify-swc-server test-fastify-project
50+
ls -la test-fastify-project
51+
cd test-fastify-project
52+
pnpm install
53+
pnpm run build
54+
pnpm dev &
55+
sleep 5
56+
curl -I http://localhost:3000 || echo "Server verification skipped"
57+
pkill -f "node"

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
A command-line tool for creating new server projects using [Fastify](https://fastify.dev/) with [SWC](https://swc.rs/) and [Jest](https://jestjs.io/).
66

7-
**Note: This module requires SSH access to GitHub to clone [this repository](https://github.com/mattfsourcecode/fastify-swc-typescript-server). If you do not already have SSH configured for GitHub, please follow the instructions on GitHub's [Connecting to GitHub with SSH](https://docs.github.com/en/authentication/connecting-to-github-with-ssh) documentation to set up SSH keys for your account.**
8-
97
## Install globally
108

119
```bash

init.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@ if (!projectName) {
1010
process.exit(1);
1111
}
1212

13-
// Clone the repository
14-
execSync(
15-
`git clone [email protected]:mattfsourcecode/fastify-swc-typescript-server.git ${projectName}`,
16-
{ stdio: "inherit" }
17-
);
13+
let gitUrl;
14+
15+
// Try cloning using SSH first
16+
try {
17+
console.log("Attempting to clone via SSH...");
18+
gitUrl = `[email protected]:mattfsourcecode/fastify-swc-typescript-server.git`;
19+
execSync(`git clone ${gitUrl} ${projectName}`, { stdio: "inherit" });
20+
} catch (sshError) {
21+
// If SSH fails, fall back to HTTPS
22+
console.error("SSH cloning failed, falling back to HTTPS...");
23+
gitUrl = `https://github.com/mattfsourcecode/fastify-swc-typescript-server.git`;
24+
execSync(`git clone ${gitUrl} ${projectName}`, { stdio: "inherit" });
25+
}
1826

1927
// Navigate to the cloned directory
2028
process.chdir(projectName);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "init.js",
66
"license": "MIT",
77
"engines": {
8-
"node": ">=18.0.0"
8+
"node": ">=20.0.0"
99
},
1010
"repository": {
1111
"type": "git",

0 commit comments

Comments
 (0)