Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: 📊 API Coverage Report

on:
pull_request:
branches: [ main ]

permissions:
pull-requests: write

jobs:
coverage:
runs-on: ubuntu-latest

steps:
- name: 🗂️ Checkout repository
uses: actions/checkout@v4

- name: ⚙️ Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'

- name: 🧩 Install dependencies
run: npm ci

- name: 🛠️ Build package
run: npm run build

- name: 📊 Generate & Post Table Report
if: always()
uses: actions/github-script@v7
env:
REPORT_FORMAT: 'plain'
with:
script: |
const fs = require('fs');
const cp = require('child_process');

const config = {
table: { flag: 'github-table', header: 'Table report'},
plain: { flag: 'github-plain', header: 'Plain report' }
}[process.env.REPORT_FORMAT];

cp.execSync(`npx test-coverage --format=${config.flag}`);
const body = fs.readFileSync('test-coverage-report.md', 'utf-8');

const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

const existing = comments.find(c =>
c.user.login === 'github-actions[bot]' &&
c.body.includes(config.header)
);

const commentPayload = {
owner: context.repo.owner,
repo: context.repo.repo,
body: body
};

if (existing) {
await github.rest.issues.updateComment({ ...commentPayload, comment_id: existing.id });
} else {
await github.rest.issues.createComment({ ...commentPayload, issue_number: context.issue.number });
}
59 changes: 59 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: 🚀 Publish Package

on:
push:
tags:
- '*'

permissions:
id-token: write
contents: read

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: 🗂️ Checkout repository
uses: actions/checkout@v4

- name: ⚙️ Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: https://registry.npmjs.org

- name: 🧩 Install dependencies
run: npm ci

- name: 🛠️ Build package
run: npm run build --if-present

- name: 🐳 Start BookHive API
run: |
git clone --depth 1 https://github.com/umutayb/book-hive.git /tmp/book-hive
cd /tmp/book-hive
docker compose up --build -d
cd $GITHUB_WORKSPACE

- name: ⏳ Wait for API readiness
run: |
for i in $(seq 1 30); do
if curl -s http://localhost:8080/api/health | grep -q '"healthy"'; then
echo "API is ready"
break
fi
echo "Waiting for API... ($i/30)"
sleep 2
done

- name: 🌱 Seed test data
run: curl -s -X POST http://localhost:8080/api/reset

- name: 🧪 Run All Tests
run: npx tsx tests/book-hive.test.ts

- name: 📦 Publish Package
run: npm publish --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
57 changes: 57 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: 🧪 Test, Verify & Coverage

on:
pull_request:
branches: [ main ]
push:
branches: [ main ]

permissions:
pull-requests: write

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: 🗂️ Checkout repository
uses: actions/checkout@v4

- name: ⚙️ Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'npm'

- name: 🧩 Install dependencies
run: npm ci

- name: 🛠️ Build package
run: npm run build

- name: 🐳 Start BookHive API
run: |
git clone --depth 1 https://github.com/umutayb/book-hive.git /tmp/book-hive
cd /tmp/book-hive
docker compose up --build -d
cd $GITHUB_WORKSPACE

- name: ⏳ Wait for API readiness
run: |
for i in $(seq 1 30); do
if curl -s http://localhost:8080/api/health | grep -q '"healthy"'; then
echo "API is ready"
break
fi
echo "Waiting for API... ($i/30)"
sleep 2
done

- name: 🌱 Seed test data
run: curl -s -X POST http://localhost:8080/api/reset

- name: 🧪 Run Integration Tests
run: npx tsx tests/book-hive.test.ts

- name: 📝 Check Types
run: npx tsc --noEmit
14 changes: 5 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
.idea/vcs.xml
/out/
/.idea/
POM-Framework.iml
*.iml
/dist
/node_modules
*.tgz
.DS_Store
/inbox/
src/test/resources/secret.properties
/target/
mongo-init.js
.env
.env.local
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading