Skip to content

Commit 37a7f55

Browse files
authored
chore: update release and tests (#383)
* chore: update build * feat: add comprehensive serverless testing and lint-staged integration - Add 50+ new serverless architecture test cases covering: - Concurrent resource loading - Error handling and recovery - Locale fallback mechanisms - Performance and latency monitoring - Cache management strategies - Edge cases and validation - Integrate lint-staged with Husky for automated code quality - Run Biome checks and formatting on staged files - Ensure code consistency before commits - Update CHANGELOG with v1.6.0 features and improvements - Format scripts with Biome standards and Node.js protocol imports * chore: update build * chore: update build
1 parent c5221c8 commit 37a7f55

File tree

11 files changed

+721
-183
lines changed

11 files changed

+721
-183
lines changed

.github/workflows/ci.yml

Lines changed: 45 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ on:
88
- '__tests__/**'
99
- 'package.json'
1010
- 'yarn.lock'
11-
- 'release.config.js'
12-
- '.github/workflows/ci.yml'
1311
branches:
1412
- '*'
1513
- '**'
@@ -19,75 +17,90 @@ concurrency:
1917
group: ${{ github.workflow }}-${{ github.ref }}
2018
cancel-in-progress: true
2119

22-
2320
env:
2421
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2522
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2623
CI: true
2724

2825
jobs:
29-
CI:
26+
test:
27+
name: Test
3028
runs-on: ubuntu-latest
3129
timeout-minutes: 20
3230

3331
permissions:
34-
packages: write
3532
contents: write
33+
issues: write
34+
pull-requests: write
35+
id-token: write
36+
packages: write
3637

3738
steps:
38-
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
39-
40-
- uses: actions/checkout@v5
39+
- name: Checkout
40+
uses: actions/checkout@v5
4141
with:
42-
fetch-depth: 30
43-
44-
- uses: FranzDiebold/github-env-vars-action@v2
42+
fetch-depth: 0
43+
persist-credentials: false
4544

4645
- name: Setup Node.js
4746
uses: actions/setup-node@v4
4847
with:
4948
node-version: 24
49+
cache: 'yarn'
5050

51-
- name: Yarn
51+
- name: Install dependencies
5252
run: yarn install --frozen-lockfile
5353

54+
- name: Prepare Metadata
55+
run: yarn preparemetadata
56+
57+
- name: Verify dependency integrity
58+
run: yarn audit || true
59+
60+
- name: Lint
61+
run: yarn lint
62+
5463
- name: Test
55-
run: |
56-
yarn preparemetadata
57-
yarn test
64+
run: yarn test
5865

5966
- name: Build
6067
run: yarn build
6168

62-
- name: Release
69+
- name: Pre-release (develop branch only)
6370
id: semantic_release
64-
if: github.ref == 'refs/heads/develop'
71+
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
75+
GIT_AUTHOR_NAME: DEV.ME Team
76+
GIT_AUTHOR_EMAIL: [email protected]
77+
GIT_COMMITTER_NAME: DEV.ME Team
78+
GIT_COMMITTER_EMAIL: [email protected]
6579
run: |
66-
git config --global user.email "[email protected]"
67-
git config --global user.name "DEV.ME Team"
68-
npm i -g semantic-release @semantic-release/git @semantic-release/github conventional-changelog-conventionalcommits
69-
npx semantic-release --no-ci --debug 2>&1 | tee release-output.txt
70-
80+
# Install semantic-release and required plugins
81+
npm i -g semantic-release @semantic-release/git @semantic-release/github @semantic-release/changelog @semantic-release/npm @semantic-release/commit-analyzer
82+
83+
# Run semantic-release
84+
npx semantic-release --debug 2>&1 | tee release-output.txt
85+
7186
# Extract version and tag info from release output
7287
if grep -q "Published release" release-output.txt; then
7388
echo "release_published=true" >> $GITHUB_OUTPUT
74-
VERSION=$(grep -oP 'Published release \K[0-9]+\.[0-9]+\.[0-9]+' release-output.txt | head -1)
89+
VERSION=$(grep -oP 'Published release \K[0-9]+\.[0-9]+\.[0-9]+(-.+)?' release-output.txt | head -1)
7590
echo "version=$VERSION" >> $GITHUB_OUTPUT
7691
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
7792
else
7893
echo "release_published=false" >> $GITHUB_OUTPUT
7994
fi
8095
81-
- name: Add CI Summary
96+
- name: Add Release Summary
8297
if: always()
8398
run: |
84-
echo "## 🔬 CI Summary" >> $GITHUB_STEP_SUMMARY
99+
echo "## 📦 Release Summary" >> $GITHUB_STEP_SUMMARY
85100
echo "" >> $GITHUB_STEP_SUMMARY
86-
87-
# Check if release step was run (only on develop branch)
88-
if [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
101+
89102
if [[ "${{ steps.semantic_release.outputs.release_published }}" == "true" ]]; then
90-
echo "### ✅ Pre-release Published Successfully!" >> $GITHUB_STEP_SUMMARY
103+
echo "### ✅ Release Published Successfully!" >> $GITHUB_STEP_SUMMARY
91104
echo "" >> $GITHUB_STEP_SUMMARY
92105
echo "- **Version:** \`${{ steps.semantic_release.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
93106
echo "- **Tag:** \`${{ steps.semantic_release.outputs.tag }}\`" >> $GITHUB_STEP_SUMMARY
@@ -98,37 +111,18 @@ jobs:
98111
echo "- [NPM Package](https://www.npmjs.com/package/@devmehq/email-validator-js/v/${{ steps.semantic_release.outputs.version }})" >> $GITHUB_STEP_SUMMARY
99112
echo "- [GitHub Release](https://github.com/${{ github.repository }}/releases/tag/${{ steps.semantic_release.outputs.tag }})" >> $GITHUB_STEP_SUMMARY
100113
else
101-
echo "### ℹ️ No Pre-release Published" >> $GITHUB_STEP_SUMMARY
114+
echo "### ℹ️ No Release Published" >> $GITHUB_STEP_SUMMARY
102115
echo "" >> $GITHUB_STEP_SUMMARY
103-
echo "No pre-release was created. This could be because:" >> $GITHUB_STEP_SUMMARY
116+
echo "No release was created. This could be because:" >> $GITHUB_STEP_SUMMARY
104117
echo "- No relevant commits found for release" >> $GITHUB_STEP_SUMMARY
105118
echo "- Commits don't follow conventional commit format" >> $GITHUB_STEP_SUMMARY
106119
echo "- Release conditions not met" >> $GITHUB_STEP_SUMMARY
107120
fi
108-
else
109-
echo "### ✅ CI Tests Passed" >> $GITHUB_STEP_SUMMARY
110-
echo "" >> $GITHUB_STEP_SUMMARY
111-
echo "All tests completed successfully on branch \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
112-
echo "" >> $GITHUB_STEP_SUMMARY
113-
echo "ℹ️ **Note:** Releases are only created from the \`develop\` branch" >> $GITHUB_STEP_SUMMARY
114-
fi
115-
121+
116122
echo "" >> $GITHUB_STEP_SUMMARY
117123
echo "### 📊 Build Information" >> $GITHUB_STEP_SUMMARY
118124
echo "- **Workflow:** \`${{ github.workflow }}\`" >> $GITHUB_STEP_SUMMARY
119-
echo "- **Branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
120-
echo "- **Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
121125
echo "- **Run ID:** \`${{ github.run_id }}\`" >> $GITHUB_STEP_SUMMARY
122126
echo "- **Run Number:** \`${{ github.run_number }}\`" >> $GITHUB_STEP_SUMMARY
123127
echo "- **Actor:** \`${{ github.actor }}\`" >> $GITHUB_STEP_SUMMARY
124128
echo "- **Event:** \`${{ github.event_name }}\`" >> $GITHUB_STEP_SUMMARY
125-
126-
# Add PR information if available
127-
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
128-
echo "" >> $GITHUB_STEP_SUMMARY
129-
echo "### 🔀 Pull Request Information" >> $GITHUB_STEP_SUMMARY
130-
echo "- **PR Number:** #${{ github.event.pull_request.number }}" >> $GITHUB_STEP_SUMMARY
131-
echo "- **PR Title:** ${{ github.event.pull_request.title }}" >> $GITHUB_STEP_SUMMARY
132-
echo "- **Base Branch:** \`${{ github.event.pull_request.base.ref }}\`" >> $GITHUB_STEP_SUMMARY
133-
echo "- **Head Branch:** \`${{ github.event.pull_request.head.ref }}\`" >> $GITHUB_STEP_SUMMARY
134-
fi

.github/workflows/release.yml

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,65 @@ env:
1919
CI: true
2020

2121
jobs:
22-
Release:
22+
release:
23+
name: Release
2324
runs-on: ubuntu-latest
2425
timeout-minutes: 20
2526

2627
permissions:
27-
packages: write
2828
contents: write
29+
issues: write
30+
pull-requests: write
31+
id-token: write
32+
packages: write
2933

3034
steps:
31-
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
32-
33-
- uses: actions/checkout@v5
35+
- name: Checkout
36+
uses: actions/checkout@v5
3437
with:
35-
fetch-depth: 30
36-
37-
- uses: FranzDiebold/github-env-vars-action@v2
38+
fetch-depth: 0
39+
persist-credentials: false
3840

3941
- name: Setup Node.js
4042
uses: actions/setup-node@v4
4143
with:
4244
node-version: 24
45+
cache: 'yarn'
4346

44-
- name: Yarn
47+
- name: Install dependencies
4548
run: yarn install --frozen-lockfile
4649

50+
- name: Prepare Metadata
51+
run: yarn preparemetadata
52+
53+
- name: Verify dependency integrity
54+
run: yarn audit || true
55+
56+
- name: Lint
57+
run: yarn lint
58+
4759
- name: Test
48-
run: |
49-
yarn preparemetadata
50-
yarn test
60+
run: yarn test
5161

5262
- name: Build
5363
run: yarn build
5464

5565
- name: Release
5666
id: semantic_release
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
70+
GIT_AUTHOR_NAME: DEV.ME Team
71+
GIT_AUTHOR_EMAIL: [email protected]
72+
GIT_COMMITTER_NAME: DEV.ME Team
73+
GIT_COMMITTER_EMAIL: [email protected]
5774
run: |
58-
git config --global user.email "[email protected]"
59-
git config --global user.name "DEV.ME Team"
60-
npm i -g semantic-release @semantic-release/git @semantic-release/github conventional-changelog-conventionalcommits
61-
npx semantic-release --no-ci --debug 2>&1 | tee release-output.txt
62-
75+
# Install semantic-release and required plugins
76+
npm i -g semantic-release @semantic-release/git @semantic-release/github @semantic-release/changelog @semantic-release/npm @semantic-release/commit-analyzer
77+
78+
# Run semantic-release
79+
npx semantic-release --debug 2>&1 | tee release-output.txt
80+
6381
# Extract version and tag info from release output
6482
if grep -q "Published release" release-output.txt; then
6583
echo "release_published=true" >> $GITHUB_OUTPUT
@@ -75,7 +93,7 @@ jobs:
7593
run: |
7694
echo "## 📦 Release Summary" >> $GITHUB_STEP_SUMMARY
7795
echo "" >> $GITHUB_STEP_SUMMARY
78-
96+
7997
if [[ "${{ steps.semantic_release.outputs.release_published }}" == "true" ]]; then
8098
echo "### ✅ Release Published Successfully!" >> $GITHUB_STEP_SUMMARY
8199
echo "" >> $GITHUB_STEP_SUMMARY
@@ -95,7 +113,7 @@ jobs:
95113
echo "- Commits don't follow conventional commit format" >> $GITHUB_STEP_SUMMARY
96114
echo "- Release conditions not met" >> $GITHUB_STEP_SUMMARY
97115
fi
98-
116+
99117
echo "" >> $GITHUB_STEP_SUMMARY
100118
echo "### 📊 Build Information" >> $GITHUB_STEP_SUMMARY
101119
echo "- **Workflow:** \`${{ github.workflow }}\`" >> $GITHUB_STEP_SUMMARY

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/.bin/lint-staged

.releaserc.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"branches": [
3+
"+([0-9])?(.{+([0-9]),x}).x",
4+
"master",
5+
"main",
6+
"next",
7+
"next-major",
8+
{
9+
"name": "beta",
10+
"prerelease": true
11+
},
12+
{
13+
"name": "develop",
14+
"prerelease": "beta"
15+
},
16+
{
17+
"name": "alpha",
18+
"prerelease": true
19+
}
20+
],
21+
"plugins": [["@semantic-release/npm"], ["@semantic-release/github"]],
22+
"dryRun": false,
23+
"ci": true
24+
}

.scripts/prepare.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* This script loads the geocoder and carrier data from the libphonenumber repository,
33
* creates bson files from them and autogenerated the types in src/locales.ts
44
*/
5-
const { readdirSync, writeFileSync, lstatSync, createReadStream, mkdirSync } = require('fs')
6-
const { join, basename } = require('path')
7-
const { createInterface } = require('readline')
8-
const { execSync } = require('child_process')
5+
const { readdirSync, writeFileSync, lstatSync, createReadStream, mkdirSync } = require('node:fs')
6+
const { join, basename } = require('node:path')
7+
const { createInterface } = require('node:readline')
8+
const { execSync } = require('node:child_process')
99
const BSON = require('bson')
1010

1111
const isDir = (source) => lstatSync(source).isDirectory()
@@ -28,6 +28,7 @@ async function prepareLocale(localePath, locale, type) {
2828
// ('\r\n') in input.txt as a single line break.
2929
for await (const line of rl) {
3030
let m
31+
// biome-ignore lint/suspicious/noAssignInExpressions: ignore
3132
if ((m = lineRe.exec(line)) !== null) {
3233
const [_, nr, description] = m
3334
const prefix = nr.replace(ccRe, '')
@@ -68,6 +69,7 @@ async function prepareTimezones() {
6869
// ('\r\n') in input.txt as a single line break.
6970
for await (const line of rl) {
7071
let m
72+
// biome-ignore lint/suspicious/noAssignInExpressions: ignore
7173
if ((m = lineRe.exec(line)) !== null) {
7274
const [_, prefix, description] = m
7375
data[prefix] = description

CHANGELOG.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
# Changelog
22

3-
## v1.4.0 (Unreleased)
3+
## v1.6.0 (Unreleased)
4+
### Features
5+
- Add serverless architecture support with lazy resource loading
6+
- Add lint-staged for automated code quality checks on commit
7+
- Add comprehensive serverless test suite with 50+ new test cases
8+
- Add support for concurrent resource loading
9+
- Add locale fallback mechanism for international support
10+
11+
### Improvements
12+
- Enhanced error handling and recovery for resource loading failures
13+
- Improved cache management with LRU eviction strategy
14+
- Added performance monitoring for resource loading latency
15+
- Extended test coverage for edge cases and validation
16+
- Optimized memory usage in serverless environments
17+
18+
### Development
19+
- Integrated lint-staged with Husky for pre-commit hooks
20+
- Added Biome formatting and linting to staged files
21+
- Improved CI/CD pipeline with semantic-release integration
22+
23+
## v1.5.0
424
### Features
525
- Add high-performance LRU caching using tiny-lru library
626
- Add cache management API: `clearCache()`, `getCacheSize()`, `setCacheSize()`

__tests__/comprehensive.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {
22
carrier,
3-
geocoder,
4-
parsePhoneNumberFromString,
5-
timezones,
63
clearCache,
4+
geocoder,
75
getCacheSize,
6+
parsePhoneNumberFromString,
87
setCacheSize,
8+
timezones,
99
} from '../src'
1010

1111
describe('Comprehensive Phone Number Validation Tests', () => {

0 commit comments

Comments
 (0)