Skip to content
Merged
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
54 changes: 54 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Checks

on:
pull_request:
push:
branches: [master]

permissions:
contents: read

jobs:
sdk:
runs-on: ubuntu-24.04
timeout-minutes: 10
strategy:
matrix:
node: ["18", "22", "24"]
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
persist-credentials: false
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: ${{ matrix.node }}
cache: npm
cache-dependency-path: |
package-lock.json
packages/types/package-lock.json
- run: npm ci --ignore-scripts
- run: npm ci --ignore-scripts
working-directory: packages/types
- run: npm run typecheck
- run: npm run typecheck:types
# Vitest requires Node 20+; both package builds and imports are checked on Node 18.
- run: npm test
if: matrix.node != '18'
- run: npm run build
- run: npm run build:types
- run: node scripts/check-packages.cjs
- run: npm pack --dry-run --ignore-scripts
- run: npm pack --dry-run --ignore-scripts
working-directory: packages/types
- name: Check SDK dependencies
if: matrix.node == '24'
run: |
npm audit --audit-level=low
npm audit --omit=dev --audit-level=low
- name: Check types package dependencies
if: matrix.node == '24'
working-directory: packages/types
run: |
npm audit --audit-level=low
npm audit --omit=dev --audit-level=low
- run: git diff --exit-code -- package.json package-lock.json packages/types/package.json packages/types/package-lock.json
134 changes: 67 additions & 67 deletions package-lock.json

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

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@
},
"devDependencies": {
"@types/node": "^24.5.2",
"@vitest/coverage-v8": "^4.1.11",
"@vitest/coverage-v8": "^4.1.12",
"tsup": "^8.5.0",
"typescript": "^5.9.2",
"vitest": "^4.1.11"
"vitest": "^4.1.12"
},
"overrides": {
"esbuild": "^0.28.1"
"esbuild": "^0.28.1",
"source-map-js": "^1.2.2",
"vite": "^7.3.7"
}
}
40 changes: 40 additions & 0 deletions scripts/check-packages.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const assert = require('node:assert/strict');
const { access } = require('node:fs/promises');
const { createRequire } = require('node:module');
const path = require('node:path');
const { pathToFileURL } = require('node:url');
const pkg = require('../package.json');

async function main() {
const esm = await import(pkg.name);
const cjs = require(pkg.name);
assert.deepEqual(Object.keys(esm).sort(), Object.keys(cjs).sort());
assert.equal(esm.getVersion(), cjs.getVersion());
await access(path.resolve(__dirname, '..', pkg.types));
await access(path.resolve(__dirname, '..', 'dist/index.d.cts'));

for (const sdk of [esm, cjs]) {
const config = new sdk.IpGeolocationClientConfig({ apiKey: 'package-test' });
assert.equal(config.baseUrl, 'https://api.ipgeolocation.io');
assert.equal(Object.isFrozen(config), true);
const request = new sdk.LookupIpGeolocationRequest({ ip: '2001:db8::1' });
assert.equal(request.ip, '2001:db8::1');
assert.equal(request.output, sdk.ResponseFormat.JSON);
const client = new sdk.IpGeolocationClient(config);
assert.equal(typeof client.bulkLookupIpGeolocationRaw, 'function');
await client.close();
}

const typesRoot = path.resolve(__dirname, '../packages/types');
const typesManifest = path.join(typesRoot, 'package.json');
const typesPkg = require(typesManifest);
const typesCjs = createRequire(typesManifest)(typesPkg.name);
const typesEsm = await import(pathToFileURL(path.join(typesRoot, typesPkg.exports['.'].import)).href);
assert.deepEqual(Object.keys(typesEsm), []);
assert.deepEqual(Object.keys(typesCjs), []);
await access(path.join(typesRoot, typesPkg.types));
await access(path.join(typesRoot, 'dist/index.d.cts'));
console.log(`SDK and types package ESM, CommonJS and declarations checked on ${process.version}`);
}

main().catch((error) => { console.error(error); process.exitCode = 1; });