Skip to content

Commit

Permalink
feat: ARM64 Linux/MacOS Pact Ruby Standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed May 12, 2023
1 parent dac0e46 commit aceee37
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 144 deletions.
57 changes: 36 additions & 21 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,17 @@ BUILD_TEST_TASK_TEMPLATE: &BUILD_TEST_TASK_TEMPLATE
- 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 - 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_arm64_task:
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:
env:
Expand All @@ -37,8 +32,7 @@ linux_amd64_task:
- apt update --yes && apt install --yes curl python3 make build-essential g++ unzip zip
<< : *BUILD_TEST_TASK_TEMPLATE


mac_task:
mac_arm64_task:
macos_instance:
image: ghcr.io/cirruslabs/macos-ventura-base:latest
env:
Expand All @@ -49,10 +43,31 @@ mac_task:
- NODE_VERSION: 16
- NODE_VERSION: 18
- NODE_VERSION: 20
install_script: # we need to install rosetta as v1.x of pact-ruby-standalone doesn't support arm64
- softwareupdate --install-rosetta --agree-to-license
install_script:
- brew install nvm
- source $(brew --prefix nvm)/nvm.sh
- nvm install $NODE_VERSION
- nvm use $NODE_VERSION
<< : *BUILD_TEST_TASK_TEMPLATE
<< : *BUILD_TEST_TASK_TEMPLATE

mac_rosetta_task:
macos_instance:
image: ghcr.io/cirruslabs/macos-ventura-base:latest
env:
NVS_HOME: ${HOME}/.nvs
PATH: ${NVS_HOME}:${PATH}
matrix:
- NODE_VERSION: 16
- NODE_VERSION: 18
- NODE_VERSION: 20
install nvs_script: |
git clone https://github.com/jasongin/nvs "$NVS_HOME"
. "$NVS_HOME/nvs.sh" install
install_rosetta_script: softwareupdate --install-rosetta --agree-to-license
install_x64_script: |
. "$NVS_HOME/nvs.sh"
nvs add $NODE_VERSION/x64
nvs use $NODE_VERSION/x64
file $(which node) | grep -e 'x64'
node --version
<< : *BUILD_TEST_TASK_TEMPLATE
192 changes: 76 additions & 116 deletions src/pact-standalone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,122 +38,82 @@ describe('Pact Standalone', function forMocha() {

describe('Check if OS specific files are there', () => {
if (!process.env['ONLY_DOWNLOAD_PACT_FOR_WINDOWS']) {
describe('OSX', () => {
beforeEach(() => {
pact = standalone('darwin');
});

it('broker relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.brokerPath))).to.be
.true;
});

it('broker full path', () => {
expect(fs.existsSync(pact.brokerFullPath)).to.be.true;
});

it('mock service relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.mockServicePath))).to
.be.true;
});

it('mock service full path', () => {
expect(fs.existsSync(pact.mockServiceFullPath)).to.be.true;
});

it('stub relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.stubPath))).to.be
.true;
});

it('stub full path', () => {
expect(fs.existsSync(pact.stubFullPath)).to.be.true;
});

it('provider verifier relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.verifierPath))).to.be
.true;
});

it('provider verifier full path', () => {
expect(fs.existsSync(pact.verifierFullPath)).to.be.true;
});

it('pact relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.pactPath))).to.be
.true;
});

it('pact full path', () => {
expect(fs.existsSync(pact.pactFullPath)).to.be.true;
});
it('pactflow relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.pactflowPath))).to.be
.true;
});

it('pactflow full path', () => {
expect(fs.existsSync(pact.pactflowFullPath)).to.be.true;
});
});

describe('Linux X64', () => {
beforeEach(() => {
pact = standalone('linux', 'x64');
});

it('broker relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.brokerPath))).to.be
.true;
});

it('broker full path', () => {
expect(fs.existsSync(pact.brokerFullPath)).to.be.true;
});

it('mock service relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.mockServicePath))).to
.be.true;
});

it('mock service full path', () => {
expect(fs.existsSync(pact.mockServiceFullPath)).to.be.true;
});

it('stub relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.stubPath))).to.be
.true;
});

it('stub full path', () => {
expect(fs.existsSync(pact.stubFullPath)).to.be.true;
});

it('provider verifier relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.verifierPath))).to.be
.true;
});

it('provider verifier full path', () => {
expect(fs.existsSync(pact.verifierFullPath)).to.be.true;
});

it('pact relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.pactPath))).to.be
.true;
});

it('pact full path', () => {
expect(fs.existsSync(pact.pactFullPath)).to.be.true;
});

it('pactflow relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.pactflowPath))).to.be
.true;
});

it('pactflow full path', () => {
expect(fs.existsSync(pact.pactflowFullPath)).to.be.true;
const binaries = [
{
platform: 'darwin',
arch: 'x64',
},
{
platform: 'darwin',
arch: 'arm64',
},
{
platform: 'linux',
arch: 'x64',
},
{
platform: 'linux',
arch: 'arm64',
},
];
binaries.forEach((binary) => {
describe(`Testing binary for ${binary.arch} ${binary.platform}`, () => {
beforeEach(() => {
pact = standalone(binary.platform, binary.arch);
});

it('broker relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.brokerPath))).to.be
.true;
});

it('broker full path', () => {
expect(fs.existsSync(pact.brokerFullPath)).to.be.true;
});

it('mock service relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.mockServicePath)))
.to.be.true;
});

it('mock service full path', () => {
expect(fs.existsSync(pact.mockServiceFullPath)).to.be.true;
});

it('stub relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.stubPath))).to.be
.true;
});

it('stub full path', () => {
expect(fs.existsSync(pact.stubFullPath)).to.be.true;
});

it('provider verifier relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.verifierPath))).to
.be.true;
});

it('provider verifier full path', () => {
expect(fs.existsSync(pact.verifierFullPath)).to.be.true;
});

it('pact relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.pactPath))).to.be
.true;
});

it('pact full path', () => {
expect(fs.existsSync(pact.pactFullPath)).to.be.true;
});
it('pactflow relative path', () => {
expect(fs.existsSync(path.resolve(basePath, pact.pactflowPath))).to
.be.true;
});

it('pactflow full path', () => {
expect(fs.existsSync(pact.pactflowFullPath)).to.be.true;
});
});
});
}
Expand Down
29 changes: 22 additions & 7 deletions standalone/install.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk = require('chalk');

// Get latest version from https://github.com/pact-foundation/pact-ruby-standalone/releases
export const PACT_STANDALONE_VERSION = '1.92.0';
export const PACT_STANDALONE_VERSION = '2.2.1';

function makeError(msg: string): Error {
return new Error(chalk.red(`Error while locating pact binary: ${msg}`));
Expand All @@ -14,15 +14,23 @@ export function createConfig(): Config {
binaries: [
{
platform: 'win32',
binary: `pact-${PACT_STANDALONE_VERSION}-win32.zip`,
binaryChecksum: `pact-${PACT_STANDALONE_VERSION}-win32.zip${CHECKSUM_SUFFIX}`,
folderName: `win32-${PACT_STANDALONE_VERSION}`,
binary: `pact-${PACT_STANDALONE_VERSION}-windows-x86_64.zip`,
binaryChecksum: `pact-${PACT_STANDALONE_VERSION}-windows-x86_64.zip${CHECKSUM_SUFFIX}`,
folderName: `windows-x64-${PACT_STANDALONE_VERSION}`,
},
{
platform: 'darwin',
binary: `pact-${PACT_STANDALONE_VERSION}-osx.tar.gz`,
binaryChecksum: `pact-${PACT_STANDALONE_VERSION}-osx.tar.gz${CHECKSUM_SUFFIX}`,
folderName: `darwin-${PACT_STANDALONE_VERSION}`,
arch: 'x64',
binary: `pact-${PACT_STANDALONE_VERSION}-osx-x86_64.tar.gz`,
binaryChecksum: `pact-${PACT_STANDALONE_VERSION}-osx-x86_64.tar.gz${CHECKSUM_SUFFIX}`,
folderName: `darwin-x64-${PACT_STANDALONE_VERSION}`,
},
{
platform: 'darwin',
arch: 'arm64',
binary: `pact-${PACT_STANDALONE_VERSION}-osx-arm64.tar.gz`,
binaryChecksum: `pact-${PACT_STANDALONE_VERSION}-osx-arm64.tar.gz${CHECKSUM_SUFFIX}`,
folderName: `darwin-arm64-${PACT_STANDALONE_VERSION}`,
},
{
platform: 'linux',
Expand All @@ -31,6 +39,13 @@ export function createConfig(): Config {
binaryChecksum: `pact-${PACT_STANDALONE_VERSION}-linux-x86_64.tar.gz${CHECKSUM_SUFFIX}`,
folderName: `linux-x64-${PACT_STANDALONE_VERSION}`,
},
{
platform: 'linux',
arch: 'arm64',
binary: `pact-${PACT_STANDALONE_VERSION}-linux-arm64.tar.gz`,
binaryChecksum: `pact-${PACT_STANDALONE_VERSION}-linux-arm64.tar.gz${CHECKSUM_SUFFIX}`,
folderName: `linux-arm64-${PACT_STANDALONE_VERSION}`,
},
],
};
}
Expand Down

0 comments on commit aceee37

Please sign in to comment.