Skip to content

Commit

Permalink
Makes some changes for github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexmatthews committed Dec 22, 2024
1 parent 77d76c5 commit 1fd30ca
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 1 deletion.
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,28 @@ on:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 make install install-styleguide build test
node-compatibility:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 13.x, 14.x, 15.x, 16.x, 17.x, 18.x, 19.x, 20.x, 21.x, 22.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 make install install-styleguide build
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 make install install-styleguide build test
- run: EASYPOST_TEST_API_KEY=123 EASYPOST_PROD_API_KEY=123 make test-node-compatibility
lint:
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ scan:
test:
npm run test

## test - Test the project
test-node-compatibility:
npm run test:node-compatibility

## update - Update dependencies (Unix only)
update: | update-examples-submodule
npm update
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"repl": "./repl.js --local ./dist/easypost.js",
"scan": "npx audit-ci -m --config ./audit-ci.jsonc",
"test": "cross-env NODE_ENV=test vitest run",
"test:node-compatibility": "cross-env NODE_ENV=test node ./test/node_compatibility",
"watch": "vite build --watch"
},
"dependencies": {
Expand Down
5 changes: 5 additions & 0 deletions test/node_compatibility/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Node Compatibility

This library supports very old versions of node when importing and using the library. However, we do not support developing this library with very old versions of node.

Thats where this folder comes in. We will run the full test suite on a modern version of Node, but will check that the library still "works" with older versions of Node using this folder. You can run this file with your API key and if it succeeds, then your version of node is compatible. Otherwise, it is not.
42 changes: 42 additions & 0 deletions test/node_compatibility/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const EasyPostClient = require('../..');

const test = async () => {
const apiKey = 'EZTK0e95f038c18f432fbc50f84855dc20c61QV0fkCenM1PlD8dAvgo0A';
const client = new EasyPostClient(apiKey);

const shipment = await client.Shipment.create({
from_address: {
street1: '417 MONTGOMERY ST',
street2: 'FLOOR 5',
city: 'SAN FRANCISCO',
state: 'CA',
zip: '94104',
country: 'US',
company: 'EasyPost',
phone: '415-123-4567',
},
to_address: {
name: 'Dr. Steve Brule',
street1: '179 N Harbor Dr',
city: 'Redondo Beach',
state: 'CA',
zip: '90277',
country: 'US',
phone: '4155559999',
},
parcel: {
length: 8,
width: 5,
height: 5,
weight: 5,
},
});

const boughtShipment = await client.Shipment.buy(shipment.id, shipment.lowestRate());

if (!boughtShipment) {
process.exit(1);
}
};

test();
3 changes: 3 additions & 0 deletions vitest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export default defineConfig({
coverage: {
provider: 'istanbul',
include: ['src/**/*.{js,ts}'],
thresholds: {
lines: 90,
},
},
},
});

0 comments on commit 1fd30ca

Please sign in to comment.