Skip to content

Commit 9f95266

Browse files
committed
Merge branch 'x-plat_test'
2 parents 7974072 + f25b580 commit 9f95266

File tree

11 files changed

+161
-23
lines changed

11 files changed

+161
-23
lines changed

.cirrus.yml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
BUILD_TEST_TASK_TEMPLATE: &BUILD_TEST_TASK_TEMPLATE
2+
arch_check_script: uname -am
3+
test_script: chmod +x ./scripts/ci/test.sh && ./scripts/ci/test.sh
4+
5+
# These are probably expected to fail in the post install script
6+
# as we are packing v2.0.0 of pact-ruby-standalone that supports
7+
# arm64 linux
8+
# linux_arm64_task:
9+
# skip: "!changesInclude('.github/**')"
10+
# env:
11+
# matrix:
12+
# - IMAGE: node:15-slim
13+
# - IMAGE: node:16-slim
14+
# - IMAGE: node:17-slim
15+
# - IMAGE: node:18-slim
16+
# - IMAGE: node:19-slim
17+
# - IMAGE: node:20-slim
18+
# arm_container:
19+
# image: $IMAGE
20+
# install_script:
21+
# - apt update --yes && apt install --yes curl python3 make build-essential g++ jq
22+
# << : *BUILD_TEST_TASK_TEMPLATE
23+
24+
linux_amd64_task:
25+
skip: "!changesInclude('.github/**')"
26+
env:
27+
matrix:
28+
- IMAGE: node:16-slim
29+
- IMAGE: node:17-slim
30+
- IMAGE: node:18-slim
31+
- IMAGE: node:19-slim
32+
- IMAGE: node:20-slim
33+
container:
34+
image: $IMAGE
35+
install_script:
36+
- apt update --yes && apt install --yes curl python3 make build-essential g++ jq
37+
<< : *BUILD_TEST_TASK_TEMPLATE
38+
39+
40+
mac_task:
41+
skip: "!changesInclude('.github/**')"
42+
macos_instance:
43+
image: ghcr.io/cirruslabs/macos-ventura-base:latest
44+
env:
45+
NVS_HOME: ${HOME}/.nvs
46+
PATH: ${NVS_HOME}:${PATH}
47+
matrix:
48+
- NODE_VERSION: 16
49+
- NODE_VERSION: 17
50+
- NODE_VERSION: 18
51+
- NODE_VERSION: 19
52+
- NODE_VERSION: 20
53+
install nvs_script: |
54+
git clone https://github.com/jasongin/nvs "$NVS_HOME"
55+
. "$NVS_HOME/nvs.sh" install
56+
install_test_arm64_script: |
57+
. "$NVS_HOME/nvs.sh"
58+
nvs add $NODE_VERSION
59+
nvs use $NODE_VERSION
60+
file $(which node) | grep -e 'arm64'
61+
node --version
62+
<< : *BUILD_TEST_TASK_TEMPLATE
63+
install_rosetta_script: softwareupdate --install-rosetta --agree-to-license
64+
install_test_x64_script: |
65+
rm -rf node_modules
66+
. "$NVS_HOME/nvs.sh"
67+
nvs add $NODE_VERSION/x64
68+
nvs use $NODE_VERSION/x64
69+
file $(which node) | grep -e 'x64'
70+
node --version
71+
arch -x86_64 npm run intro
72+
arch -x86_64 npm run test:consumer
73+
arch -x86_64 npm run pact:show
74+
arch -x86_64 npm run test:provider
75+
arch -x86_64 npm test
76+
arch -x86_64 npm run get:broker

.github/workflows/node.js.yml

+24-13
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,40 @@ name: Node.js CI
66
on:
77
workflow_dispatch:
88
push:
9-
branches: [ "main" ]
9+
paths:
10+
- '!.cirrus.yml'
11+
- '**'
1012
pull_request:
11-
branches: [ "main" ]
12-
13+
paths:
14+
- '!.cirrus.yml'
15+
- '**'
16+
1317
jobs:
1418
build:
1519

16-
runs-on: ubuntu-latest
17-
20+
runs-on: ${{ matrix.os }}
21+
defaults:
22+
run:
23+
shell: bash
1824
strategy:
25+
fail-fast: false
1926
matrix:
20-
node-version: [14.x, 16.x]
27+
node-version: [16,17,18,19,20]
28+
os: [ubuntu-latest,macos-latest,windows-latest]
2129
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
22-
2330
steps:
2431
- uses: actions/checkout@v3
2532
- name: Use Node.js ${{ matrix.node-version }}
2633
uses: actions/setup-node@v3
2734
with:
2835
node-version: ${{ matrix.node-version }}
29-
- run: npm run intro
30-
- run: npm run test:consumer
31-
- run: npm run pact:show
32-
- run: npm run test:provider
33-
- run: npm test
34-
- run: npm run get:broker
36+
# - run: | # https://github.com/nodejs/node-gyp/blob/main/docs/Updating-npm-bundled-node-gyp.md
37+
# npm -v
38+
# npm explore npm/node_modules/@npmcli/run-script -g -- npm_config_global=false npm install node-gyp@latest
39+
# if: matrix.node-version == '15' && runner.os == 'MacOS'
40+
# - run: |
41+
# npm -v
42+
# where node
43+
# cd "C:\\Program Files\nodejs\\"
44+
# npm install node-gyp@latest
45+
- run: ./scripts/ci/test.sh

.replit

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ POETRY_CACHE_DIR = "${HOME}/${REPL_SLUG}/.cache/pypoetry"
1616
XDG_CONFIG_HOME = "/home/runner/.config"
1717
PATH = "/home/runner/$REPL_SLUG/.config/npm/node_global/bin:/home/runner/$REPL_SLUG/node_modules/.bin:${VIRTUAL_ENV}/lib/python3.8/site-packages:${VIRTUAL_ENV}/bin"
1818
npm_config_prefix = "/home/runner/$REPL_SLUG/.config/npm/node_global"
19+
IS_REPL = "true"
1920

2021
[unitTest]
2122
language = "nodejs"

consumer/orderClient.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
const request = require("superagent");
22
const { Order } = require("./order");
33

4+
const hostname = "127.0.0.1"
5+
46
const fetchOrders = () => {
5-
return request.get(`http://127.0.0.1:${process.env.API_PORT}/orders`).then(
7+
return request.get(`http://${hostname}:${process.env.API_PORT}/orders`).then(
68
(res) => {
79
return res.body.reduce((acc, o) => {
810
acc.push(new Order(o.id, o.items));

package-lock.json

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
"test:provider": "node runProviderTest.js",
2020
"pact:publish": "./publish.sh",
2121
"pact:show": "cat pacts/GettingStartedOrderWeb-GettingStartedOrderApi.json | jq .",
22-
"test": "PACT_URL=$PWD/pacts/GettingStartedOrderWeb-GettingStartedOrderApi.json npm run test:consumer && npm run test:provider",
23-
"test:broker": "PACT_BROKER_BASE_URL=https://pactbroker.$REPL_OWNER.repl.co npm run test:consumer && npm run pact:publish && npm run test:provider",
22+
"test": "cross-env PACT_URL=$PWD/pacts/GettingStartedOrderWeb-GettingStartedOrderApi.json npm run test:consumer && npm run test:provider",
23+
"test:broker": "cross-env PACT_BROKER_BASE_URL=https://pactbroker.$REPL_OWNER.repl.co npm run test:consumer && npm run pact:publish && npm run test:provider",
2424
"get:broker": "echo 'fork a copy of https://replit.com/@pact/pactbroker and run npm test:broker when it has started'"
25+
},
26+
"devDependencies": {
27+
"cross-env": "^7.0.3"
2528
}
2629
}

pact.js

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const provider = new Pact({
1717
host: "127.0.0.1",
1818
consumer: consumerName,
1919
provider: providerName,
20+
host: "127.0.0.1"
2021
});
2122

2223
// used to kill any left over mock server instances in case of errors

provider/provider.spec.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ let port;
88
let opts;
99
let app;
1010

11+
const hostname = "127.0.0.1"
12+
1113
// Verify that the provider meets all consumer expectations
1214
describe("Pact Verification", () => {
1315
before(async () => {
@@ -18,7 +20,7 @@ describe("Pact Verification", () => {
1820
provider: providerName,
1921
// we need to where the provider will be running,
2022
// we are starting it locally and defined the port above
21-
providerBaseUrl: `http://127.0.0.1:${port}`,
23+
providerBaseUrl: `http://${hostname}:${port}`,
2224
// You can set the log level here, useful for debugging
2325
logLevel: "info"
2426
};

publish.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
GIT_COMMIT=$(git rev-parse HEAD)
23
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
34
pact-broker publish pacts \

replit.nix

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{ pkgs }: {
22
deps = [
3-
pkgs.python39Full
4-
pkgs.nodejs-16_x
5-
pkgs.nodePackages.typescript-language-server
6-
pkgs.yarn
7-
pkgs.replitPackages.jest
8-
pkgs.jq
3+
pkgs.python39Full
4+
pkgs.nodejs-16_x
5+
pkgs.nodePackages.typescript-language-server
6+
pkgs.yarn
7+
pkgs.replitPackages.jest
8+
pkgs.jq
99
];
1010
}

scripts/ci/test.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash -eu
2+
set -eu # This needs to be here for windows bash, which doesn't read the #! line above
3+
4+
5+
node --version
6+
npm run intro
7+
npm run test:consumer
8+
npm run pact:show
9+
npm run test:provider
10+
npm test
11+
npm run get:broker

0 commit comments

Comments
 (0)