-
Notifications
You must be signed in to change notification settings - Fork 79
Description
Smells
Cross CI provider and cross arch has shown a few inconsistencies in content-type matching, which is clearly demonstrable here. Haven't thought of a solution just yet, but this at least highlights and allows us to test more combinations than before
Encountered in #444 (comment)
If you have code that looks like this, there is a definite code-smell
pact-js-core/test/consumer.integration.spec.ts
Lines 23 to 34 in facfef8
| const isWin = process.platform === 'win32'; | |
| const isLinux = process.platform === 'linux'; | |
| const isDarwinArm64 = process.platform === 'darwin' && process.arch === 'arm64'; | |
| const isDarwinX64 = process.platform === 'darwin' && process.arch === 'x64'; | |
| const isLinuxArm64 = process.platform === 'linux' && process.arch === 'arm64'; | |
| const isCirrusCi = process.env['CIRRUS_CI'] === 'true'; | |
| const usesOctetStream = | |
| isLinuxArm64 || | |
| isWin || | |
| isDarwinArm64 || | |
| (isCirrusCi && isLinux) || | |
| (isCirrusCi && isDarwinX64); |
The condition is used in these tests
pact-js-core/test/consumer.integration.spec.ts
Lines 77 to 87 in dac0e46
| it('generates a pact with success', () => | |
| axios | |
| .request({ | |
| baseURL: `http://${HOST}:${port}`, | |
| headers: { | |
| 'content-type': usesOctetStream | |
| ? 'application/octet-stream' | |
| : 'application/gzip', | |
| Accept: 'application/json', | |
| 'x-special-header': 'header', | |
| }, |
pact-js-core/test/message.integration.spec.ts
Lines 94 to 109 in dac0e46
| // 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 | |
| // Linux: has magic mime matcher, sniffs content | |
| describe('with binary data', () => { | |
| it('generates a pact with success', () => { | |
| const message = pact.newAsynchronousMessage(''); | |
| message.expectsToReceive('a binary event'); | |
| message.given('some state'); | |
| message.givenWithParam('some state 2', 'state2 key', 'state2 val'); | |
| message.withBinaryContents( | |
| bytes, | |
| usesOctetStream ? 'application/octet-stream' : 'application/gzip' | |
| ); | |
| message.withMetadata('meta-key', 'meta-val'); |
See pact-foundation/pact-reference#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
Linux: has magic mime matcher, sniffs content
So based on our compat table of
| OS | Amd64 | Arm64 |
|---|---|---|
| Linux (glibc) | ✅ | ✅ |
| Mac | ✅ | ✅ |
| Windows | ✅ | ❌ |
| Linux (alpine) | ❌ | ❌ |
✅ = supported
❌ = not supported
We have a few different ways we can test to cover different arch combinations
- Locally
- Locally with GitHub Actions / Act
- GitHub Actions
- Locally with Cirrus CLI
- Cirrus CI
| OS | Amd64 | Arm64 | Amd64 (GH) | Amd64 (GH Act) | Amd64 (Cirrus) | Arm64 (Cirrus CI) | Amd64 (Cirrus CLI) | Arm64 (Cirrus CLI) |
|---|---|---|---|---|---|---|---|---|
| Linux (glibc) | ❓ | ❓ | ❓ | ❓ | ❓ | ❓ | ❓ | ❓ |
| Mac | ❓ | ❓ | ❓ | ❌ | ❓ | ❓ | ❓ | ❓ |
| Windows | ❓ | ❌ | ❓ | ❌ | ❓ | ❌ | ❓ | ❌ |
| Linux (alpine) | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
❓ = needs test evidence
❌ = not supported, or untestable on platform