-
-
Notifications
You must be signed in to change notification settings - Fork 376
49 lines (42 loc) · 2.22 KB
/
tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: Unit Tests
on:
push:
branches:
- 'main'
tags-ignore:
- '*.*.*'
pull_request:
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
npm install
- name: Transpile for Node.js ${{ matrix.node-version }}
run: |
./node_modules/.bin/lerna exec --bail --concurrency 2 -- ../../node_modules/.bin/swc --config-file ../../swc.cjs.config.json --source-maps false index.js --out-file index.cjs
./node_modules/.bin/lerna exec --bail --concurrency 2 -- sed -i.bak 's/exports,\ \"default\"/module,\ \"exports\"/g' index.cjs # Fix CommonJS default import
sed -i.bak 's/awsEmbeddedMetrics.default.createMetricsLogger/awsEmbeddedMetrics.createMetricsLogger/g' packages/cloudwatch-metrics/index.cjs # Fix CommonJS default import
./node_modules/.bin/lerna exec --bail --concurrency 2 -- ../../node_modules/.bin/swc --config-file ../../swc.esm.config.json --source-maps false index.js --out-file index.js
./node_modules/.bin/swc --config-file ./swc.cjs.config.json --source-maps false packages/validator/transpile.js --out-file packages/validator/transpile.cjs
sed -i.bak 's/exports,\ \"default\"/module,\ \"exports\"/g' packages/validator/transpile.cjs # Fix CommonJS default import
./node_modules/.bin/swc --config-file ./swc.esm.config.json --source-maps false packages/validator/transpile.js --out-file packages/validator/transpile.js
- name: Unit tests
run: |
npm run test:packages:unit
- name: Test cjs can be required
run: |
node -e 'const middy = require("./packages/core/index.cjs"); middy()'
node -e 'const httpRouterHandler = require("./packages/http-router/index.cjs"); httpRouterHandler([])'
node -e 'const {transpileSchema, transpileLocale} = require("./packages/validator/transpile.cjs"); transpileSchema({}); transpileLocale("")'