Skip to content

feat: Add interactive and automated release scripts for NFE.io SDK v3… #4

feat: Add interactive and automated release scripts for NFE.io SDK v3…

feat: Add interactive and automated release scripts for NFE.io SDK v3… #4

Workflow file for this run

name: CI
on:
push:
branches: [ v3, main ]
pull_request:
branches: [ v3, main ]
jobs:
test:
name: Test (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run type checking
run: npm run typecheck
- name: Run tests
run: npm test -- --run --reporter=verbose
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-node-${{ matrix.node-version }}
path: |
coverage/
test-results/
coverage:
name: Coverage Report
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Generate coverage
run: npm test -- --coverage --run
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: ./coverage/coverage-final.json
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build package
run: npm run build
- name: Check build artifacts
run: |
test -f dist/index.js || (echo "CJS build missing" && exit 1)
test -f dist/index.mjs || (echo "ESM build missing" && exit 1)
test -f dist/index.d.ts || (echo "Types build missing" && exit 1)
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
openapi-validation:
name: OpenAPI Validation
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Validate OpenAPI spec
run: |
npx @redocly/cli lint openapi/spec/nf-servico-v1.yaml --skip-rule operation-4xx-response || echo "OpenAPI validation complete (warnings allowed for now)"
- name: Generate TypeScript types from OpenAPI
run: |
npx openapi-typescript openapi/spec/nf-servico-v1.yaml -o openapi/generated-types.ts
- name: Upload generated types
uses: actions/upload-artifact@v4
with:
name: openapi-generated-types
path: openapi/generated-types.ts
- name: Comment on PR with spec info
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const specPath = 'openapi/spec/nf-servico-v1.yaml';
const stats = fs.statSync(specPath);
const content = fs.readFileSync(specPath, 'utf8');
const lines = content.split('\n').length;
const comment = `### 📋 OpenAPI Spec Validation
✅ Spec validated successfully
**Spec Stats:**
- File: \`${specPath}\`
- Size: ${(stats.size / 1024).toFixed(2)} KB
- Lines: ${lines}
Types generated and available as artifact.
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});