From 850f1e9d567b6c4c83b970b4386bee271e0a8eb4 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Tue, 2 May 2023 18:00:38 +0100 Subject: [PATCH 01/13] chore(dx): add developer notes, test across 16,18,20 --- .github/workflows/build-and-test.yml | 62 ++++++++++------------------ DEVELOPER.md | 8 +++- script/lib/download-ffi.sh | 2 +- 3 files changed, 30 insertions(+), 42 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 9e4e16a8..fe7be872 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -8,64 +8,46 @@ on: jobs: build-and-test-osx: - runs-on: macos-latest + runs-on: [macos-latest,ubuntu-latest,windows-latest] + defaults: + run: + shell: bash strategy: matrix: - node-version: [16.x] + node-version: [16,18,20] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - run: script/ci/build-and-test.sh + if: runner != 'Windows' env: NODE_VERSION: ${{ matrix.node-version }} PACT_BROKER_FEATURES: publish_pacts_using_old_api + - run: script/ci/build-and-test.sh + if: runner == 'Windows' + env: + NODE_VERSION: ${{ matrix.node-version }} + PACT_BROKER_FEATURES: publish_pacts_using_old_api + ONLY_DOWNLOAD_PACT_FOR_WINDOWS: true - build-and-test-ubuntu: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [16.x] - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - name: Set MSVS version run: npm config set msvs_version 2017 - run: script/ci/build-and-test.sh + if: runner != 'Windows' env: NODE_VERSION: ${{ matrix.node-version }} PACT_BROKER_FEATURES: publish_pacts_using_old_api - - build-and-test-windows: - runs-on: windows-latest - strategy: - matrix: - node-version: [16.x] - - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: Fix node-gyp - run: |- - npm install --global node-gyp@latest - npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"} - shell: pwsh - - run: bash script/ci/build-and-test.sh - shell: bash + - run: script/ci/build-and-test.sh + if: runner == 'Windows' + # The windows build agent has trouble unpacking the tar for + # linux, so we only download windows binaries. This means + # we cannot release from Windows in CI. + # maybe we just need to install gunzip? env: NODE_VERSION: ${{ matrix.node-version }} - # The windows build agent has trouble unpacking the tar for - # linux, so we only download windows binaries. This means - # we cannot release from Windows in CI. - ONLY_DOWNLOAD_PACT_FOR_WINDOWS: true PACT_BROKER_FEATURES: publish_pacts_using_old_api + ONLY_DOWNLOAD_PACT_FOR_WINDOWS: true diff --git a/DEVELOPER.md b/DEVELOPER.md index 4c5d6d7e..df705af3 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -3,6 +3,12 @@ Do this and you should be 👌👌👌: ``` +bash script/download-libs.sh npm ci npm test -``` \ No newline at end of file +``` + + +_notes_ - As a developer you need you download the FFI libraries prior to running `npm install` / `npm ci` as the libraries will be expected to be there, and you won't have any `node_modules` installed yet. + +For end users, the `ffi` folder is populated, as part of the npm publishing step. \ No newline at end of file diff --git a/script/lib/download-ffi.sh b/script/lib/download-ffi.sh index f4bc48a3..b0b37461 100755 --- a/script/lib/download-ffi.sh +++ b/script/lib/download-ffi.sh @@ -17,7 +17,7 @@ if [[ $(find "${FFI_DIR}" -name "${FFI_VERSION}*") ]]; then fi warn "Cleaning ffi directory $FFI_DIR" -rm -rf "${FFI_DIR:?}/*" +rm -rf "${FFI_DIR:?}" mkdir -p "$FFI_DIR/osxaarch64" mkdir -p "$FFI_DIR/linuxaarch64" From dcebb2aec93c4b4d7c969e0f6d23bc72978f3dd9 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Tue, 2 May 2023 18:06:20 +0100 Subject: [PATCH 02/13] ci: give it a real runner label: --- .github/workflows/build-and-test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index fe7be872..ac395a84 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -8,13 +8,14 @@ on: jobs: build-and-test-osx: - runs-on: [macos-latest,ubuntu-latest,windows-latest] + runs-on: ${{ matrix.os }} defaults: run: shell: bash strategy: matrix: node-version: [16,18,20] + os: [macos-latest,ubuntu-latest,windows-latest] steps: - uses: actions/checkout@v3 From d1d20cd917a541bf5718506d4653b4a375a24545 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Tue, 2 May 2023 18:09:08 +0100 Subject: [PATCH 03/13] ci: fail fast: --- .github/workflows/build-and-test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index ac395a84..42d596bd 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -13,6 +13,7 @@ jobs: run: shell: bash strategy: + fail-fast: false matrix: node-version: [16,18,20] os: [macos-latest,ubuntu-latest,windows-latest] @@ -38,12 +39,12 @@ jobs: - name: Set MSVS version run: npm config set msvs_version 2017 - run: script/ci/build-and-test.sh - if: runner != 'Windows' + if: runner.os != 'Windows' env: NODE_VERSION: ${{ matrix.node-version }} PACT_BROKER_FEATURES: publish_pacts_using_old_api - run: script/ci/build-and-test.sh - if: runner == 'Windows' + if: runner.os == 'Windows' # The windows build agent has trouble unpacking the tar for # linux, so we only download windows binaries. This means # we cannot release from Windows in CI. From 7d36abeb8e10c6bf2dba772f25941b29073a7350 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Tue, 2 May 2023 18:17:55 +0100 Subject: [PATCH 04/13] ci: ensure correct runner logic: --- .github/workflows/build-and-test.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 42d596bd..6110a456 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -24,20 +24,6 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - - run: script/ci/build-and-test.sh - if: runner != 'Windows' - env: - NODE_VERSION: ${{ matrix.node-version }} - PACT_BROKER_FEATURES: publish_pacts_using_old_api - - run: script/ci/build-and-test.sh - if: runner == 'Windows' - env: - NODE_VERSION: ${{ matrix.node-version }} - PACT_BROKER_FEATURES: publish_pacts_using_old_api - ONLY_DOWNLOAD_PACT_FOR_WINDOWS: true - - - name: Set MSVS version - run: npm config set msvs_version 2017 - run: script/ci/build-and-test.sh if: runner.os != 'Windows' env: @@ -45,10 +31,6 @@ jobs: PACT_BROKER_FEATURES: publish_pacts_using_old_api - run: script/ci/build-and-test.sh if: runner.os == 'Windows' - # The windows build agent has trouble unpacking the tar for - # linux, so we only download windows binaries. This means - # we cannot release from Windows in CI. - # maybe we just need to install gunzip? env: NODE_VERSION: ${{ matrix.node-version }} PACT_BROKER_FEATURES: publish_pacts_using_old_api From 1c28edb4cfe2645b2acc46f84b709214cc4cf82f Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Tue, 2 May 2023 19:14:06 +0100 Subject: [PATCH 05/13] ci(test): add arm64 macos test, prep arm64 linux test --- .cirrus.yml | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .cirrus.yml diff --git a/.cirrus.yml b/.cirrus.yml new file mode 100644 index 00000000..8bdc34a4 --- /dev/null +++ b/.cirrus.yml @@ -0,0 +1,58 @@ +env: + PACT_BROKER_FEATURES: publish_pacts_using_old_api + +BUILD_TEST_TASK_TEMPLATE: &BUILD_TEST_TASK_TEMPLATE + arch_check_script: + - uname -am + test_script: + - node --version + - script/ci/build-and-test.sh + +# These are probably expected to fail in the post install script +# until we are packing v2.0.0 of pact-ruby-standalone that supports +# arm64 linux +linux_arm64_task: + skip: "!changesInclude('.github/**')" + env: + matrix: + - IMAGE: node:16-slim + - IMAGE: node:18-slim + - IMAGE: node:20-slim + arm_container: + image: $IMAGE + install_script: + - apt update --yes && apt install --yes curl python3 make build-essential g++ + << : *BUILD_TEST_TASK_TEMPLATE + +linux_amd64_task: + skip: "!changesInclude('.github/**')" + env: + matrix: + - IMAGE: node:16-slim + - IMAGE: node:18-slim + - IMAGE: node:20-slim + container: + image: $IMAGE + install_script: + - apt update --yes && apt install --yes curl python3 make build-essential g++ + << : *BUILD_TEST_TASK_TEMPLATE + + +mac_task: + skip: "!changesInclude('.github/**')" + macos_instance: + image: ghcr.io/cirruslabs/macos-ventura-base:latest + env: + PACT_BROKER_FEATURES: publish_pacts_using_old_api + NVS_HOME: ${HOME}/.nvs + PATH: ${NVS_HOME}:${PATH} + matrix: + - NODE_VERSION: 16 + - NODE_VERSION: 18 + - NODE_VERSION: 20 + install_script: + - brew install nvm + - source $(brew --prefix nvm)/nvm.sh + - nvm install $NODE_VERSION + - nvm use $NODE_VERSION + << : *BUILD_TEST_TASK_TEMPLATE \ No newline at end of file From 56e9b61200e511898186798efe63ee80fd755152 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Tue, 2 May 2023 19:14:44 +0100 Subject: [PATCH 06/13] ci: test arm64 cirrus: --- .cirrus.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 8bdc34a4..c7d1fa10 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -12,7 +12,7 @@ BUILD_TEST_TASK_TEMPLATE: &BUILD_TEST_TASK_TEMPLATE # until we are packing v2.0.0 of pact-ruby-standalone that supports # arm64 linux linux_arm64_task: - skip: "!changesInclude('.github/**')" + skip: "changesInclude('.github/**')" env: matrix: - IMAGE: node:16-slim @@ -25,7 +25,7 @@ linux_arm64_task: << : *BUILD_TEST_TASK_TEMPLATE linux_amd64_task: - skip: "!changesInclude('.github/**')" + skip: "changesInclude('.github/**')" env: matrix: - IMAGE: node:16-slim From 21d96b0146588d4b0b8085467dca72b1012ed0d0 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Tue, 2 May 2023 19:16:18 +0100 Subject: [PATCH 07/13] ci: test arm64 cirrus: --- .cirrus.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index c7d1fa10..10f05aa6 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -21,7 +21,7 @@ linux_arm64_task: arm_container: image: $IMAGE install_script: - - apt update --yes && apt install --yes curl python3 make build-essential g++ + - apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip << : *BUILD_TEST_TASK_TEMPLATE linux_amd64_task: @@ -34,12 +34,12 @@ linux_amd64_task: container: image: $IMAGE install_script: - - apt update --yes && apt install --yes curl python3 make build-essential g++ + - apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip << : *BUILD_TEST_TASK_TEMPLATE mac_task: - skip: "!changesInclude('.github/**')" + skip: "changesInclude('.github/**')" macos_instance: image: ghcr.io/cirruslabs/macos-ventura-base:latest env: From 8c14e321a52e9068dae0b5c8986e46c6a7002b37 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Tue, 2 May 2023 19:32:29 +0100 Subject: [PATCH 08/13] ci(test): arm64 platforms need octet-stream content-type --- .cirrus.yml | 3 ++- test/consumer.integration.spec.ts | 11 ++++++++--- test/message.integration.spec.ts | 7 ++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 10f05aa6..5c6214ac 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -50,7 +50,8 @@ mac_task: - NODE_VERSION: 16 - NODE_VERSION: 18 - NODE_VERSION: 20 - install_script: + install_script: # we need to install rosetta as v1.x of pact-ruby-standalone doesn't support arm64 + - softwareupdate --install-rosetta --agree-to-license - brew install nvm - source $(brew --prefix nvm)/nvm.sh - nvm install $NODE_VERSION diff --git a/test/consumer.integration.spec.ts b/test/consumer.integration.spec.ts index 46f2ddc2..ab2103de 100644 --- a/test/consumer.integration.spec.ts +++ b/test/consumer.integration.spec.ts @@ -21,6 +21,9 @@ const { expect } = chai; const HOST = '127.0.0.1'; const isWin = process.platform === 'win32'; +const isDarwinArm64 = process.platform === 'darwin' && process.arch === 'arm64' +const isLinuxArm64 = process.platform === 'linux' && process.arch === 'arm64' +const usesOctetStream = isLinuxArm64 || isWin || isDarwinArm64 describe('FFI integration test for the HTTP Consumer API', () => { setLogLevel('trace'); @@ -73,7 +76,9 @@ describe('FFI integration test for the HTTP Consumer API', () => { .request({ baseURL: `http://${HOST}:${port}`, headers: { - 'content-type': 'application/octet-stream', + 'content-type': usesOctetStream + ? 'application/octet-stream' + : 'application/gzip', Accept: 'application/json', 'x-special-header': 'header', }, @@ -188,7 +193,7 @@ describe('FFI integration test for the HTTP Consumer API', () => { interaction.withQuery('someParam', 0, 'someValue'); interaction.withRequestBinaryBody( bytes, - isWin ? 'application/octet-stream' : 'application/gzip' + usesOctetStream ? 'application/octet-stream' : 'application/gzip' ); interaction.withResponseBody( JSON.stringify({ @@ -211,7 +216,7 @@ describe('FFI integration test for the HTTP Consumer API', () => { .request({ baseURL: `http://${HOST}:${port}`, headers: { - 'content-type': isWin + 'content-type': usesOctetStream ? 'application/octet-stream' : 'application/gzip', Accept: 'application/json', diff --git a/test/message.integration.spec.ts b/test/message.integration.spec.ts index dc0a41c4..0b73ef06 100644 --- a/test/message.integration.spec.ts +++ b/test/message.integration.spec.ts @@ -14,8 +14,9 @@ chai.use(chaiAsPromised); const { expect } = chai; const isWin = process.platform === 'win32'; -const isOSX = process.platform === 'darwin'; -const isCI = process.env['CI'] === 'true'; +const isDarwinArm64 = process.platform === 'darwin' && process.arch === 'arm64' +const isLinuxArm64 = process.platform === 'linux' && process.arch === 'arm64' +const usesOctetStream = isLinuxArm64 || isWin || isDarwinArm64 const getFeature = async (address: string, protoFile: string) => { const def = await load(protoFile); @@ -100,7 +101,7 @@ describe('FFI integration test for the Message Consumer API', () => { message.givenWithParam('some state 2', 'state2 key', 'state2 val'); message.withBinaryContents( bytes, - isWin || (isOSX && isCI) + usesOctetStream ? 'application/octet-stream' : 'application/gzip' ); From d5cf22d667d5ba6eccef2093ff527f336c0844e2 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Tue, 2 May 2023 19:34:17 +0100 Subject: [PATCH 09/13] ci: linting: --- test/consumer.integration.spec.ts | 10 +++++----- test/message.integration.spec.ts | 10 ++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/test/consumer.integration.spec.ts b/test/consumer.integration.spec.ts index ab2103de..ac49dfd1 100644 --- a/test/consumer.integration.spec.ts +++ b/test/consumer.integration.spec.ts @@ -21,9 +21,9 @@ const { expect } = chai; const HOST = '127.0.0.1'; const isWin = process.platform === 'win32'; -const isDarwinArm64 = process.platform === 'darwin' && process.arch === 'arm64' -const isLinuxArm64 = process.platform === 'linux' && process.arch === 'arm64' -const usesOctetStream = isLinuxArm64 || isWin || isDarwinArm64 +const isDarwinArm64 = process.platform === 'darwin' && process.arch === 'arm64'; +const isLinuxArm64 = process.platform === 'linux' && process.arch === 'arm64'; +const usesOctetStream = isLinuxArm64 || isWin || isDarwinArm64; describe('FFI integration test for the HTTP Consumer API', () => { setLogLevel('trace'); @@ -77,8 +77,8 @@ describe('FFI integration test for the HTTP Consumer API', () => { baseURL: `http://${HOST}:${port}`, headers: { 'content-type': usesOctetStream - ? 'application/octet-stream' - : 'application/gzip', + ? 'application/octet-stream' + : 'application/gzip', Accept: 'application/json', 'x-special-header': 'header', }, diff --git a/test/message.integration.spec.ts b/test/message.integration.spec.ts index 0b73ef06..e28ddb47 100644 --- a/test/message.integration.spec.ts +++ b/test/message.integration.spec.ts @@ -14,9 +14,9 @@ chai.use(chaiAsPromised); const { expect } = chai; const isWin = process.platform === 'win32'; -const isDarwinArm64 = process.platform === 'darwin' && process.arch === 'arm64' -const isLinuxArm64 = process.platform === 'linux' && process.arch === 'arm64' -const usesOctetStream = isLinuxArm64 || isWin || isDarwinArm64 +const isDarwinArm64 = process.platform === 'darwin' && process.arch === 'arm64'; +const isLinuxArm64 = process.platform === 'linux' && process.arch === 'arm64'; +const usesOctetStream = isLinuxArm64 || isWin || isDarwinArm64; const getFeature = async (address: string, protoFile: string) => { const def = await load(protoFile); @@ -101,9 +101,7 @@ describe('FFI integration test for the Message Consumer API', () => { message.givenWithParam('some state 2', 'state2 key', 'state2 val'); message.withBinaryContents( bytes, - usesOctetStream - ? 'application/octet-stream' - : 'application/gzip' + usesOctetStream ? 'application/octet-stream' : 'application/gzip' ); message.withMetadata('meta-key', 'meta-val'); From 1246fb31a0be35a17fe4e21b55839d53675c1f9f Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Tue, 2 May 2023 19:49:23 +0100 Subject: [PATCH 10/13] ci(test): content type differences across amd64 linux in ci providers --- .cirrus.yml | 51 ++++++++++++++++--------------- test/consumer.integration.spec.ts | 10 ++++-- test/message.integration.spec.ts | 4 ++- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 5c6214ac..2516bd9d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -10,32 +10,33 @@ BUILD_TEST_TASK_TEMPLATE: &BUILD_TEST_TASK_TEMPLATE # These are probably expected to fail in the post install script # until we are packing v2.0.0 of pact-ruby-standalone that supports -# arm64 linux -linux_arm64_task: - skip: "changesInclude('.github/**')" - env: - matrix: - - IMAGE: node:16-slim - - IMAGE: node:18-slim - - IMAGE: node:20-slim - arm_container: - image: $IMAGE - install_script: - - apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip - << : *BUILD_TEST_TASK_TEMPLATE +# arm64 linux - as per https://github.com/pact-foundation/pact-js-core/issues/416 +# Error: Error while locating pact binary: Cannot find binary for platform 'linux' with architecture 'arm64'. +# linux_arm64_task: +# skip: "changesInclude('.github/**')" +# env: +# matrix: +# - IMAGE: node:16-slim +# - IMAGE: node:18-slim +# - IMAGE: node:20-slim +# arm_container: +# image: $IMAGE +# install_script: +# - apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip +# << : *BUILD_TEST_TASK_TEMPLATE -linux_amd64_task: - skip: "changesInclude('.github/**')" - env: - matrix: - - IMAGE: node:16-slim - - IMAGE: node:18-slim - - IMAGE: node:20-slim - container: - image: $IMAGE - install_script: - - apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip - << : *BUILD_TEST_TASK_TEMPLATE +# linux_amd64_task: +# skip: "changesInclude('.github/**')" +# env: +# matrix: +# - IMAGE: node:16-slim +# - IMAGE: node:18-slim +# - IMAGE: node:20-slim +# container: +# image: $IMAGE +# install_script: +# - apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip +# << : *BUILD_TEST_TASK_TEMPLATE mac_task: diff --git a/test/consumer.integration.spec.ts b/test/consumer.integration.spec.ts index ac49dfd1..bb297282 100644 --- a/test/consumer.integration.spec.ts +++ b/test/consumer.integration.spec.ts @@ -21,9 +21,11 @@ const { expect } = chai; const HOST = '127.0.0.1'; const isWin = process.platform === 'win32'; +const isLinux = process.platform === 'linux'; const isDarwinArm64 = process.platform === 'darwin' && process.arch === 'arm64'; const isLinuxArm64 = process.platform === 'linux' && process.arch === 'arm64'; -const usesOctetStream = isLinuxArm64 || isWin || isDarwinArm64; +const isCirrusCi = process.env["CIRRUS_CI"] === "true" +const usesOctetStream = isLinuxArm64 || isWin || isDarwinArm64 || (isCirrusCi && isLinux); describe('FFI integration test for the HTTP Consumer API', () => { setLogLevel('trace'); @@ -173,9 +175,11 @@ describe('FFI integration test for the HTTP Consumer API', () => { // See https://github.com/pact-foundation/pact-reference/issues/171 for why we have an OS switch here // Windows: does not have magic mime matcher, uses content-type - // OSX on CI: does not magic mime matcher, uses content-type - // OSX: has magic mime matcher, sniffs content + // OSX arm64: does not magic mime matcher, uses content-type + // OSX x86_64: has magic mime matcher, sniffs content + // OSX x86_64 - CI GitHub Actions: has magic mime matcher, sniffs content // Linux: has magic mime matcher, sniffs content + // Linux - CI Cirrus: does not have magic mime matcher, uses content-type describe('with binary data', () => { beforeEach(() => { pact = makeConsumerPact( diff --git a/test/message.integration.spec.ts b/test/message.integration.spec.ts index e28ddb47..4d3169f8 100644 --- a/test/message.integration.spec.ts +++ b/test/message.integration.spec.ts @@ -14,9 +14,11 @@ chai.use(chaiAsPromised); const { expect } = chai; const isWin = process.platform === 'win32'; +const isLinux = process.platform === 'linux'; const isDarwinArm64 = process.platform === 'darwin' && process.arch === 'arm64'; const isLinuxArm64 = process.platform === 'linux' && process.arch === 'arm64'; -const usesOctetStream = isLinuxArm64 || isWin || isDarwinArm64; +const isCirrusCi = process.env["CIRRUS_CI"] === "true" +const usesOctetStream = isLinuxArm64 || isWin || isDarwinArm64 || (isCirrusCi && isLinux); const getFeature = async (address: string, protoFile: string) => { const def = await load(protoFile); From 793e68199c4565140cabf6f4bf8fd238ee7af6bb Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Tue, 2 May 2023 19:51:39 +0100 Subject: [PATCH 11/13] ci: linting: --- .cirrus.yml | 24 ++++++++++++------------ test/consumer.integration.spec.ts | 5 +++-- test/message.integration.spec.ts | 5 +++-- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 2516bd9d..6045bc41 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -25,18 +25,18 @@ BUILD_TEST_TASK_TEMPLATE: &BUILD_TEST_TASK_TEMPLATE # - apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip # << : *BUILD_TEST_TASK_TEMPLATE -# linux_amd64_task: -# skip: "changesInclude('.github/**')" -# env: -# matrix: -# - IMAGE: node:16-slim -# - IMAGE: node:18-slim -# - IMAGE: node:20-slim -# container: -# image: $IMAGE -# install_script: -# - apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip -# << : *BUILD_TEST_TASK_TEMPLATE +linux_amd64_task: + skip: "changesInclude('.github/**')" + env: + matrix: + - IMAGE: node:16-slim + - IMAGE: node:18-slim + - IMAGE: node:20-slim + container: + image: $IMAGE + install_script: + - apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip + << : *BUILD_TEST_TASK_TEMPLATE mac_task: diff --git a/test/consumer.integration.spec.ts b/test/consumer.integration.spec.ts index bb297282..f41dedb3 100644 --- a/test/consumer.integration.spec.ts +++ b/test/consumer.integration.spec.ts @@ -24,8 +24,9 @@ const isWin = process.platform === 'win32'; const isLinux = process.platform === 'linux'; const isDarwinArm64 = process.platform === 'darwin' && process.arch === 'arm64'; const isLinuxArm64 = process.platform === 'linux' && process.arch === 'arm64'; -const isCirrusCi = process.env["CIRRUS_CI"] === "true" -const usesOctetStream = isLinuxArm64 || isWin || isDarwinArm64 || (isCirrusCi && isLinux); +const isCirrusCi = process.env['CIRRUS_CI'] === 'true'; +const usesOctetStream = + isLinuxArm64 || isWin || isDarwinArm64 || (isCirrusCi && isLinux); describe('FFI integration test for the HTTP Consumer API', () => { setLogLevel('trace'); diff --git a/test/message.integration.spec.ts b/test/message.integration.spec.ts index 4d3169f8..484d3607 100644 --- a/test/message.integration.spec.ts +++ b/test/message.integration.spec.ts @@ -17,8 +17,9 @@ const isWin = process.platform === 'win32'; const isLinux = process.platform === 'linux'; const isDarwinArm64 = process.platform === 'darwin' && process.arch === 'arm64'; const isLinuxArm64 = process.platform === 'linux' && process.arch === 'arm64'; -const isCirrusCi = process.env["CIRRUS_CI"] === "true" -const usesOctetStream = isLinuxArm64 || isWin || isDarwinArm64 || (isCirrusCi && isLinux); +const isCirrusCi = process.env['CIRRUS_CI'] === 'true'; +const usesOctetStream = + isLinuxArm64 || isWin || isDarwinArm64 || (isCirrusCi && isLinux); const getFeature = async (address: string, protoFile: string) => { const def = await load(protoFile); From 8675e28c2bc42d853c1f144a82791b05f741bb70 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Fri, 12 May 2023 13:29:07 +0100 Subject: [PATCH 12/13] chore: address review feedback -set e -set u + dx docs --- DEVELOPER.md | 2 +- script/ci/build-and-test.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/DEVELOPER.md b/DEVELOPER.md index df705af3..280479e7 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -9,6 +9,6 @@ npm test ``` -_notes_ - As a developer you need you download the FFI libraries prior to running `npm install` / `npm ci` as the libraries will be expected to be there, and you won't have any `node_modules` installed yet. +_notes_ - As a developer, you need to run `bash script/download-libs.sh` to download the FFI libraries prior to running `npm install` / `npm ci` as the libraries will be expected to be there, and you won't have any `node_modules` installed yet. For end users, the `ffi` folder is populated, as part of the npm publishing step. \ No newline at end of file diff --git a/script/ci/build-and-test.sh b/script/ci/build-and-test.sh index 62ad4e0b..7d5e330c 100755 --- a/script/ci/build-and-test.sh +++ b/script/ci/build-and-test.sh @@ -1,5 +1,6 @@ #!/bin/bash -eu -set -eu # This needs to be here for windows bash, which doesn't read the #! line above +set -e # This needs to be here for windows bash, which doesn't read the #! line above +set -u SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" # Figure out where the script is running . "$SCRIPT_DIR"/../lib/robust-bash.sh From 85547805f9ec2be8c24710b78dea7ea3b2fe2d32 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Fri, 12 May 2023 13:52:57 +0100 Subject: [PATCH 13/13] chore(ci): remove cirrus skip --- .cirrus.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 6045bc41..a9a02372 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -26,7 +26,6 @@ BUILD_TEST_TASK_TEMPLATE: &BUILD_TEST_TASK_TEMPLATE # << : *BUILD_TEST_TASK_TEMPLATE linux_amd64_task: - skip: "changesInclude('.github/**')" env: matrix: - IMAGE: node:16-slim @@ -40,7 +39,6 @@ linux_amd64_task: mac_task: - skip: "changesInclude('.github/**')" macos_instance: image: ghcr.io/cirruslabs/macos-ventura-base:latest env: