Skip to content

Commit

Permalink
Makes changes to github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexmatthews committed Dec 22, 2024
1 parent eb5ecc0 commit 33fea3b
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 18 deletions.
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
8 changes: 8 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 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 Expand Up @@ -62,6 +63,7 @@
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.1",
"eslint-plugin-vitest-globals": "^1.5.0",
"jsdoc": "^4.0.2",
"prettier": "^2.8.8",
"typescript": "^4.9.5 || ~5.0.0",
Expand Down
17 changes: 2 additions & 15 deletions test/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
{
"extends": ["eslint:recommended", "prettier"],
"extends": ["eslint:recommended", "prettier", "plugin:vitest-globals/recommended"],

"env": {
"node": true,
"mocha": true
},

"settings": {
"import/resolver": {
"webpack": {
"config": "webpack.config.babel.js"
}
},
"import/extensions": ["", ".js", ".json"]
"vitest-globals/env": true
},

"rules": {
"import/no-extraneous-dependencies": 0,

// mocha syntax: expect(x).to.not.be.undefined
"no-unused-expressions": 0,

// @easypost/eslint-config-easypost-base assumes all tests are jest. so turn these rules off
"jest/consistent-test-it": 0,
"jest/valid-expect": 0,
Expand All @@ -30,7 +18,6 @@
"globals": {
"expect": true
},
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 13
}
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.
16 changes: 16 additions & 0 deletions test/node_compatibility/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const dotenv = require('dotenv');

dotenv.config();

const EasyPostClient = require('../..');

const test = async () => {
const apiKey = process.env.EASYPOST_TEST_API_KEY;
const client = new EasyPostClient(apiKey);

if (!client.baseUrl.includes('easypost.com')) {

Check failure

Code scanning / CodeQL

Incomplete URL substring sanitization High test

'
easypost.com
' can be anywhere in the URL, and arbitrary hosts may come before or after it.
process.exit(1);
}
};

test();
4 changes: 2 additions & 2 deletions test/services/easypost.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';

import EasyPost, { METHODS } from '../../src/easypost';
import EasyPostClient, { METHODS } from '../../src/easypost';
import MissingParameterError from '../../src/errors/general/missing_parameter_error';
import Fixture from '../helpers/fixture';
import * as setupPolly from '../helpers/setup_polly';
Expand All @@ -20,7 +20,7 @@ describe('EasyPost', function () {
});

it('throws an error when no API key is provided', async function () {
expect(() => new EasyPost()).to.throw(
expect(() => new EasyPostClient()).to.throw(
MissingParameterError,
'Missing required parameter: API Key.',
);
Expand Down
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 33fea3b

Please sign in to comment.