Skip to content

Commit fc155b7

Browse files
committed
wip
1 parent 78f155e commit fc155b7

11 files changed

Lines changed: 226 additions & 1 deletion

File tree

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
build/
3+
dist/
4+
coverage/
5+
*.config.ts
6+
*.config.js

.eslintrc.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"ecmaVersion": 2022,
6+
"sourceType": "module",
7+
"project": "./tsconfig.json"
8+
},
9+
"plugins": ["@typescript-eslint"],
10+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
11+
"env": {
12+
"node": true,
13+
"es2022": true
14+
},
15+
"rules": {
16+
"@typescript-eslint/no-unused-vars": [
17+
"error",
18+
{ "argsIgnorePattern": "^_" }
19+
],
20+
"@typescript-eslint/explicit-function-return-type": "off",
21+
"@typescript-eslint/no-explicit-any": "warn"
22+
}
23+
}

.github/workflows/pull-request.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: PR
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
9+
cancel-in-progress: true
10+
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
jobs:
16+
ci:
17+
name: CI
18+
uses: getdevopspro/github-actions/.github/workflows/pull-request.yml@v1.0.1
19+
with:
20+
version-package: package.json
21+
version-package-lock: package-lock.json
22+
pre-lint-command: npm ci --ignore-scripts; npm run lint
23+
pre-test-unit-command: npm ci --ignore-scripts; npm run test

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules/
2+
build/
3+
dist/
4+
.npm/
5+
*.log
6+
.env
7+
.env.local
8+
.DS_Store
9+
coverage/

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# GitHub Actions Nodejs Test
2+
3+
A minimal Node.js/Express application for testing GitHub Actions, Docker builds, and docker-bake workflows.
4+
5+
## Quick Start
6+
7+
### Install Dependencies
8+
9+
```bash
10+
npm install
11+
```
12+
13+
### Local Development
14+
15+
```bash
16+
npm run dev
17+
```
18+
19+
### Build
20+
21+
```bash
22+
npm run build
23+
npm start
24+
```
25+
26+
### Lint
27+
28+
```bash
29+
npm run lint # Check for linting errors
30+
npm run lint:fix # Auto-fix linting errors
31+
```
32+
33+
### Test
34+
35+
```bash
36+
npm test # Run tests once
37+
npm run test:watch # Run tests in watch mode
38+
```
39+
40+
### Docker Build
41+
42+
```bash
43+
docker buildx bake --load
44+
docker run -p 3000:3000 github-actions-test
45+
```
46+
47+
## Endpoints
48+
49+
- `GET /` - Main endpoint with app info
50+
- `GET /health` - Health check endpoint
51+
52+
## Testing
53+
54+
Visit http://localhost:3000 to see the app running.

package.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
{
22
"name": "github-actions-test",
3-
"version": "0.0.15"
3+
"version": "0.0.15",
4+
"type": "module",
5+
"scripts": {
6+
"build": "tsc",
7+
"start": "node build/index.js",
8+
"dev": "tsx watch src/index.ts",
9+
"lint": "eslint src/**/*.ts",
10+
"lint:fix": "eslint src/**/*.ts --fix",
11+
"test": "vitest run",
12+
"test:watch": "vitest"
13+
},
14+
"dependencies": {
15+
"express": "^4.18.2",
16+
"dotenv": "^16.3.1"
17+
},
18+
"devDependencies": {
19+
"@types/express": "^4.17.21",
20+
"@types/node": "^20.10.0",
21+
"@typescript-eslint/eslint-plugin": "^6.15.0",
22+
"@typescript-eslint/parser": "^6.15.0",
23+
"eslint": "^8.56.0",
24+
"typescript": "^5.3.3",
25+
"tsx": "^4.7.0",
26+
"vitest": "^1.1.0"
27+
}
428
}

src/index.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { describe, it, expect } from "vitest";
2+
3+
describe("Basic Tests", () => {
4+
it("should pass a simple test", () => {
5+
expect(true).toBe(true);
6+
});
7+
8+
it("should perform basic math", () => {
9+
expect(2 + 2).toBe(4);
10+
});
11+
12+
it("should handle strings", () => {
13+
const message = "Hello from GitHub Actions Test!";
14+
expect(message).toContain("GitHub Actions");
15+
});
16+
17+
it("should check environment", () => {
18+
expect(process.env.NODE_ENV).toBeDefined();
19+
});
20+
});

src/index.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import express from "express";
2+
3+
const app = express();
4+
const PORT = process.env.PORT || 3000;
5+
6+
app.get("/", (req, res) => {
7+
res.json({
8+
message: "Hello from GitHub Actions Test!",
9+
version: process.env.npm_package_version || "0.0.15",
10+
timestamp: new Date().toISOString(),
11+
platform: process.platform,
12+
arch: process.arch,
13+
});
14+
});
15+
16+
app.get("/health", (req, res) => {
17+
res.json({ status: "healthy", uptime: process.uptime() });
18+
});
19+
20+
app.listen(PORT, () => {
21+
console.log(`Server is running on port ${PORT}`);
22+
console.log(`Environment: ${process.env.NODE_ENV || "development"}`);
23+
});

static/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>GitHub Actions Test</title>
7+
</head>
8+
<body>
9+
<h1>GitHub Actions Test App</h1>
10+
<p>
11+
This is a test application for GitHub Actions, Docker, and Bake workflows.
12+
</p>
13+
</body>
14+
</html>

tsconfig.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "ES2022",
5+
"lib": ["ES2022"],
6+
"moduleResolution": "node",
7+
"outDir": "./build",
8+
"rootDir": "./src",
9+
"strict": true,
10+
"esModuleInterop": true,
11+
"skipLibCheck": true,
12+
"forceConsistentCasingInFileNames": true,
13+
"resolveJsonModule": true
14+
},
15+
"include": ["src/**/*"],
16+
"exclude": ["node_modules", "build"]
17+
}

0 commit comments

Comments
 (0)