Skip to content

Commit abdcf36

Browse files
authored
🚀 release: v2.1.0 - Merge pull request #16 from wgtechlabs/dev
2 parents 0177b7c + 19cd9d8 commit abdcf36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+13265
-5014
lines changed

.github/workflows/scan.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Security & Linting
2+
3+
on:
4+
push:
5+
branches: [main, dev]
6+
pull_request:
7+
branches: [main, dev]
8+
9+
jobs:
10+
security-lint:
11+
name: Security & Code Quality Scan
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
23+
- name: Verify Node.js version meets requirements
24+
run: |
25+
echo "Node.js version:"
26+
node --version
27+
echo "npm version:"
28+
npm --version
29+
echo "Checking Node.js version compatibility..."
30+
node -e "
31+
const version = process.version;
32+
const major = parseInt(version.slice(1).split('.')[0]);
33+
const required = 16;
34+
console.log(\`Node.js \${version} (major: \${major})\`);
35+
if (major < required) {
36+
console.error(\`❌ Node.js \${major} is below minimum required version \${required}\`);
37+
process.exit(1);
38+
} else {
39+
console.log(\`✅ Node.js \${major} meets minimum requirement \${required}\`);
40+
}
41+
"
42+
43+
- name: Enable Corepack for Yarn v4
44+
run: |
45+
echo "Current Node.js version:"
46+
node --version
47+
echo "Enabling Corepack..."
48+
corepack enable
49+
echo "Preparing Yarn 4.9.2..."
50+
corepack prepare [email protected] --activate
51+
echo "Yarn setup complete"
52+
53+
- name: Verify Yarn version
54+
run: |
55+
echo "Yarn version:"
56+
yarn --version
57+
echo "Checking package manager field..."
58+
node -e "console.log('packageManager:', require('./package.json').packageManager)"
59+
60+
- name: Install dependencies
61+
run: |
62+
echo "Installing dependencies with Yarn v4..."
63+
echo "Current working directory: $(pwd)"
64+
echo "Files in directory:"
65+
ls -la
66+
echo "Installing..."
67+
yarn install --immutable
68+
echo "Dependencies installed successfully"
69+
70+
- name: Verify installation
71+
run: |
72+
echo "Checking node_modules..."
73+
ls -la node_modules/ | head -10
74+
echo "Checking TypeScript installation..."
75+
76+
# Check TypeScript
77+
if yarn tsc --version > /dev/null 2>&1; then
78+
echo "✅ TypeScript: $(yarn tsc --version)"
79+
elif npx tsc --version > /dev/null 2>&1; then
80+
echo "✅ TypeScript: $(npx tsc --version)"
81+
else
82+
echo "⚠️ TypeScript: Not accessible via yarn/npx, checking package.json..."
83+
TS_VERSION=$(node -e "const pkg = require('./package.json'); console.log(pkg.devDependencies?.typescript || '')")
84+
if [ -n "$TS_VERSION" ] && [ "$TS_VERSION" != "undefined" ]; then
85+
echo " ✅ TypeScript is listed in devDependencies: $TS_VERSION"
86+
else
87+
echo " ❌ TypeScript may not be installed"
88+
fi
89+
fi
90+
91+
echo "✅ Dependency verification completed"
92+
93+
- name: TypeScript compilation check
94+
run: |
95+
echo "Running TypeScript compilation check..."
96+
yarn tsc --noEmit
97+
echo "✅ TypeScript compilation successful"
98+
99+
- name: Run ESLint with security rules
100+
run: |
101+
echo "Running standard ESLint checks..."
102+
yarn lint
103+
echo "✅ Standard linting passed"
104+
105+
- name: Run security-focused ESLint
106+
run: |
107+
echo "Running security-focused ESLint..."
108+
yarn lint:security
109+
echo "✅ Security linting passed"
110+
111+
- name: Audit dependencies for vulnerabilities
112+
run: |
113+
echo "Running dependency audit..."
114+
if yarn npm audit --severity high; then
115+
echo "✅ Dependency audit passed - no high/critical vulnerabilities found"
116+
fi
117+
118+
- name: Check for known security issues
119+
run: |
120+
echo "Generating detailed security audit..."
121+
# Use || true here to ensure JSON output is captured even if vulnerabilities are found
122+
# This step is for reporting/analysis, not for failing the build
123+
yarn npm audit --json --severity moderate > audit.json || true
124+
if [ -f audit.json ]; then
125+
vulnerabilities=$(cat audit.json | jq -r '.data.vulnerabilities // {} | length // 0' 2>/dev/null || echo "0")
126+
echo "Found $vulnerabilities vulnerabilities"
127+
echo "✅ Security audit completed"
128+
else
129+
echo "No audit data available"
130+
fi

.github/workflows/support.yml

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
name: Node.js Support Matrix
2+
3+
on:
4+
push:
5+
branches: [main, dev]
6+
pull_request:
7+
branches: [main, dev]
8+
9+
jobs:
10+
node-support-matrix:
11+
name: Node.js ${{ matrix.node-version }} Compatibility
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
# NOTE: Node.js versions are automatically extracted by the compatibility-summary job
17+
# The summary report will dynamically reflect any changes made to this list
18+
node-version: ['18', '20']
19+
fail-fast: false
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js ${{ matrix.node-version }}
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: ${{ matrix.node-version }}
29+
30+
- name: Verify Node.js version meets requirements
31+
run: |
32+
echo "Node.js version:"
33+
node --version
34+
echo "npm version:"
35+
npm --version
36+
echo "Checking Node.js version compatibility..."
37+
node -e "
38+
const version = process.version;
39+
const major = parseInt(version.slice(1).split('.')[0]);
40+
const required = 16;
41+
console.log(\`Node.js \${version} (major: \${major})\`);
42+
if (major < required) {
43+
console.error(\`❌ Node.js \${major} is below minimum required version \${required}\`);
44+
process.exit(1);
45+
} else {
46+
console.log(\`✅ Node.js \${major} meets minimum requirement \${required}\`);
47+
}
48+
"
49+
50+
- name: Enable Corepack for Yarn v4
51+
run: |
52+
echo "Current Node.js version:"
53+
node --version
54+
echo "Enabling Corepack..."
55+
corepack enable
56+
echo "Preparing Yarn 4.9.2..."
57+
corepack prepare [email protected] --activate
58+
echo "Yarn setup complete"
59+
60+
- name: Verify Yarn version
61+
run: |
62+
echo "Yarn version:"
63+
yarn --version
64+
echo "Checking package manager field..."
65+
node -e "console.log('packageManager:', require('./package.json').packageManager)"
66+
67+
- name: Install dependencies
68+
run: |
69+
echo "Installing dependencies with Yarn v4..."
70+
echo "Current working directory: $(pwd)"
71+
echo "Files in directory:"
72+
ls -la
73+
echo "Installing..."
74+
yarn install --immutable
75+
echo "Dependencies installed successfully"
76+
77+
- name: Verify installation
78+
run: |
79+
echo "Checking node_modules..."
80+
ls -la node_modules/ | head -10
81+
echo "Checking TypeScript installation..."
82+
yarn tsc --version
83+
84+
- name: TypeScript compilation check
85+
run: |
86+
echo "Running TypeScript compilation check..."
87+
yarn tsc --noEmit
88+
echo "✅ TypeScript compilation successful"
89+
90+
- name: Run test suite (no coverage for compatibility test)
91+
run: |
92+
echo "Running test suite for Node.js ${{ matrix.node-version }}..."
93+
yarn test --watchAll=false --verbose=false --coverage=false
94+
echo "✅ Test suite passed"
95+
96+
- name: Basic linting check
97+
run: |
98+
echo "Running ESLint checks..."
99+
yarn lint
100+
echo "✅ Linting passed"
101+
102+
- name: Build verification
103+
run: |
104+
echo "Building project..."
105+
yarn build
106+
echo "Checking build output..."
107+
ls -la dist/
108+
echo "✅ Build successful"
109+
110+
compatibility-summary:
111+
name: Node.js Compatibility Summary
112+
runs-on: ubuntu-latest
113+
needs: node-support-matrix
114+
if: always()
115+
116+
steps:
117+
- name: Checkout code (for extracting matrix versions)
118+
uses: actions/checkout@v4
119+
120+
- name: Node.js Compatibility Report
121+
run: |
122+
echo "=== Node.js Compatibility Test Results ==="
123+
echo "Matrix job result: ${{ needs.node-support-matrix.result }}"
124+
echo ""
125+
126+
# Extract Node.js versions from the workflow file dynamically
127+
echo "Extracting tested Node.js versions from workflow..."
128+
NODE_VERSIONS=($(grep "node-version: \[" .github/workflows/support.yml | sed "s/.*\[\(.*\)\].*/\1/" | tr "," "\n" | sed "s/[' ]//g" | sort -n))
129+
echo "Detected versions: ${NODE_VERSIONS[*]}"
130+
echo ""
131+
132+
if [[ "${{ needs.node-support-matrix.result }}" == "success" ]]; then
133+
echo "🎉 SUCCESS: All Node.js versions are fully compatible!"
134+
echo ""
135+
136+
# Dynamically generate compatibility lines
137+
for version in "${NODE_VERSIONS[@]}"; do
138+
echo "✅ Node.js $version - Compatible"
139+
done
140+
141+
echo ""
142+
echo "The log-engine library works correctly across all supported Node.js versions."
143+
144+
# Generate minimum version requirement dynamically
145+
min_version=${NODE_VERSIONS[0]}
146+
echo "Users can safely install and use this package with Node.js ${min_version}+ environments."
147+
148+
elif [[ "${{ needs.node-support-matrix.result }}" == "failure" ]]; then
149+
echo "❌ FAILURE: Some Node.js versions failed compatibility tests"
150+
echo ""
151+
echo "Tested versions:"
152+
for version in "${NODE_VERSIONS[@]}"; do
153+
echo " - Node.js $version"
154+
done
155+
echo ""
156+
echo "Please check the individual job logs above to see which versions failed and why."
157+
echo "Common issues:"
158+
echo "- Yarn/Corepack setup problems"
159+
echo "- TypeScript compilation issues"
160+
echo "- Test failures specific to Node.js version"
161+
echo "- Dependency compatibility problems"
162+
exit 1
163+
else
164+
echo "⚠️ PARTIAL: Some tests were cancelled or skipped"
165+
echo "Result status: ${{ needs.node-support-matrix.result }}"
166+
echo ""
167+
echo "Tested versions:"
168+
for version in "${NODE_VERSIONS[@]}"; do
169+
echo " - Node.js $version"
170+
done
171+
exit 1
172+
fi

0 commit comments

Comments
 (0)