From 1fd30caede63db82974357ab4ce6249660eeca91 Mon Sep 17 00:00:00 2001 From: Alex Matthews Date: Sun, 22 Dec 2024 16:57:29 -0600 Subject: [PATCH] Makes some changes for github workflows --- .github/workflows/ci.yml | 14 ++++++++++- Makefile | 4 +++ package.json | 1 + test/node_compatibility/README.md | 5 ++++ test/node_compatibility/index.js | 42 +++++++++++++++++++++++++++++++ vitest.config.js | 3 +++ 6 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 test/node_compatibility/README.md create mode 100644 test/node_compatibility/index.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e1387026..04aff577 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/Makefile b/Makefile index 30bc1a2c..d4afde09 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/package.json b/package.json index 7c1bec6a..54a2a89c 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/test/node_compatibility/README.md b/test/node_compatibility/README.md new file mode 100644 index 00000000..30e22552 --- /dev/null +++ b/test/node_compatibility/README.md @@ -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. diff --git a/test/node_compatibility/index.js b/test/node_compatibility/index.js new file mode 100644 index 00000000..d2d992c6 --- /dev/null +++ b/test/node_compatibility/index.js @@ -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(); diff --git a/vitest.config.js b/vitest.config.js index a3f98b10..58a3d56b 100644 --- a/vitest.config.js +++ b/vitest.config.js @@ -11,6 +11,9 @@ export default defineConfig({ coverage: { provider: 'istanbul', include: ['src/**/*.{js,ts}'], + thresholds: { + lines: 90, + }, }, }, });