Skip to content

Commit

Permalink
Merge pull request #1225 from pact-foundation/feat/support_alpine
Browse files Browse the repository at this point in the history
Feat/support alpine
  • Loading branch information
YOU54F authored Jun 24, 2024
2 parents 4d78c65 + 6dbfb22 commit 6107a35
Show file tree
Hide file tree
Showing 34 changed files with 326 additions and 380 deletions.
179 changes: 86 additions & 93 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,111 +15,104 @@ env:
jobs:
build-and-test:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [16, 18, 20, 22]
os: [macos-14, macos-12, ubuntu-latest, windows-latest]
docker: [false]
alpine: [false]
include:
- os: ubuntu-latest
docker: true
alpine: true
arch: amd64
node-version: 22
- os: ubuntu-latest
docker: true
alpine: true
arch: amd64
node-version: 20
- os: ubuntu-latest
docker: true
alpine: true
arch: amd64
node-version: 18
# ARM64 Builds under Qemu
- os: ubuntu-latest
docker: true
alpine: false
arch: arm64
node-version: 22
- os: ubuntu-latest
docker: true
alpine: true
arch: arm64
node-version: 22
- os: ubuntu-latest
docker: true
alpine: false
arch: arm64
node-version: 20
- os: ubuntu-latest
docker: true
alpine: true
arch: arm64
node-version: 20
- os: ubuntu-latest
docker: true
alpine: true
arch: arm64
node-version: 18
name: Test ${{ matrix.docker == true && matrix.alpine == true && 'linux-musl' || matrix.docker == true && matrix.alpine == false && 'linux' || matrix.os }}-${{ matrix.arch }}-node-${{ matrix.node-version }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: bash scripts/ci/build-and-test.sh
shell: bash
env:
SKIP_EXAMPLES: true
- run: scripts/ci/test-examples.sh
shell: bash
env:
SETUP_DIST_ONLY: true

## require jest-pact and mocha-pact to update peer deps
# - name: example_mocha
# run: cd examples/mocha && npm install --ignore-scripts && npm test
# - name: example_jest
# run: cd examples/jest && npm install --ignore-scripts && npm test
- run: scripts/ci/build-and-test.sh
if: ${{ matrix.docker != true }}

# passing
- name: example_e2e
run: cd examples/e2e && npm install --ignore-scripts && npm test
- name: example_graphql
run: cd examples/graphql && npm install --ignore-scripts && npm test
- name: example_messages
run: cd examples/messages && npm install --ignore-scripts && npm test
- name: example_serverless
run: cd examples/serverless && npm install --ignore-scripts && npm test
- name: example_typescript
run: cd examples/typescript && npm install --ignore-scripts && npm test
- name: example_v3_e2e
run: cd examples/v3/e2e && npm install --ignore-scripts && npm test
- name: example_v3_provider-state-injected
run: cd examples/v3/provider-state-injected && npm install --ignore-scripts && npm test
- name: example_v3_run-specific-verifications
run: cd examples/v3/run-specific-verifications && npm install --ignore-scripts && npm test
- name: example_v3_todo-consumer
run: cd examples/v3/todo-consumer && npm install --ignore-scripts && npm test
- name: example_v3_typescript
run: cd examples/v3/typescript && npm install --ignore-scripts && npm test
- name: example_v4_plugins
run: cd examples/v4/plugins && npm install --ignore-scripts && npm test
- name: example_v4_matchers
run: cd examples/v4/matchers && npm install --ignore-scripts && npm test
# - name: Upload dist folder
# if: runner.os == 'Linux'
# uses: actions/upload-artifact@v3
# with:
# path: dist
- name: Set up QEMU
if: ${{ matrix.docker == true && matrix.arch == 'arm64' }}
uses: docker/setup-qemu-action@v3

# examples:
# needs: [build-and-test]
# strategy:
# matrix:
# node-version: [16,18,20]
# os: [macos-latest, ubuntu-latest, windows-latest]
# example:
# [
# e2e,
# graphql,
# jest, # requires jest-pact updating
# messages,
# mocha, # requires mocha-pact updating
# serverless,
# typescript,
# v3/e2e,
# v3/provider-state-injected,
# v3/run-specific-verifications,
# v3/todo-consumer,
# v3/typescript,
# v4/plugins,
# ]
# fail-fast: false
# runs-on: ${{ matrix.os }}
- if: ${{ matrix.docker == true && matrix.alpine != true && matrix.arch == 'arm64' }}
name: test linux ${{ matrix.arch }} glibc
run: |
npm run docker:debian:build
npm run docker:debian:run
env:
DOCKER_DEFAULT_PLATFORM: linux/${{ matrix.arch }}
NODE_VERSION: ${{ matrix.node-version }}
GITHUB_ACTIONS: ${{ env.GITHUB_ACTIONS }}
SKIP_EXAMPLES: true

# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - name: Download dist folder
# uses: actions/download-artifact@v3
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v3
# with:
# node-version: ${{ matrix.node-version }}
# - run: scripts/ci/test-examples.sh
# shell: bash
# env:
# SETUP_DIST_ONLY: true
# if: matrix.example != 'jest' || matrix.example != 'mocha'
# - run: bash scripts/install-plugins.sh
# if: matrix.example == 'v4/plugins'
# - name: run example ${{ matrix.example }}
# run: |
# npm install --ignore-scripts
# npm test
# shell: bash
# working-directory: examples/${{ matrix.example }}
- if: ${{ matrix.docker == true && matrix.alpine == true && matrix.arch == 'amd64' }}
name: test linux ${{ matrix.arch }} musl
run: |
npm run docker:alpine:build
npm run docker:alpine:run
env:
DOCKER_DEFAULT_PLATFORM: linux/${{ matrix.arch }}
NODE_VERSION: ${{ matrix.node-version }}
GITHUB_ACTIONS: ${{ env.GITHUB_ACTIONS }}

- if: ${{ matrix.docker == true && matrix.alpine == true && matrix.arch == 'arm64' }}
name: test linux ${{ matrix.arch }} musl
run: |
npm run docker:alpine:build
npm run docker:alpine:run
env:
DOCKER_DEFAULT_PLATFORM: linux/${{ matrix.arch }}
NODE_VERSION: ${{ matrix.node-version }}
GITHUB_ACTIONS: ${{ env.GITHUB_ACTIONS }}
SKIP_EXAMPLES: true
4 changes: 2 additions & 2 deletions .github/workflows/publish-9x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: 9.x.x
fetch-depth: 0
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 14
registry-url: 'https://registry.npmjs.org'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
outputs:
version: v${{ steps.publish.outputs.version }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: master
fetch-depth: 0
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ARG NODE_VERSION=current
FROM node:${NODE_VERSION}-alpine

RUN apk add bash curl git file libc6-compat gcompat jq
# libc6-compat gcompat required for @pact-foundation/pact-cli ruby runtime
# all other dependencies just used for @pact-foundation/pact testing
# so you don't need to use those in your own projects

ENTRYPOINT [ "bash", "-c", "scripts/ci/build-and-test.sh" ]
8 changes: 8 additions & 0 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ARG NODE_VERSION=latest
FROM node:${NODE_VERSION}-slim

RUN apt-get -y update && apt-get -y install curl git jq
# dependencies just used for @pact-foundation/pact testing
# so you don't need to use those in your own projects

ENTRYPOINT [ "bash", "-c", "scripts/ci/build-and-test.sh" ]
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,32 @@ It's best to run Pact verification tests as part of your unit testing suite, so

<details><summary>Specification Compatibility</summary>

| Version | Stable | [Spec] Compatibility | Install |
| ------- | ------ | -------------------- | ------------------ |
| 11.x.x | Yes | 2, 3, 4 | See [installation] |
| 10.x.x | Yes | 2, 3, 4 | See [installation] |
| 9.x.x | Yes | 2, 3\* | [9xx] |
| Version | Stable | [Spec] Compatibility | Install |
| ------- | ------ | -------------------- | ------------------ |
| 11.x.x + | Yes | 2, 3, 4 | See [installation] |
| 10.x.x | Yes | 2, 3, 4 | See [installation] |
| 9.x.x | Yes | 2, 3\* | [9xx] |

_\*_ v3 support is limited to the subset of functionality required to enable language inter-operable [Message support].

</details>

<details><summary>Supported Platforms</summary>

| OS | Architecture | Supported | Pact-JS Version |
| ------------- | ------------ | --------- | ---------------- |
| MacOS | x86_64 || All |
| MacOS | arm64 || 9.x + |
| Linux (libc) | x86_64 || All |
| Linux (libc) | arm64 || 10.x + |
| Linux (musl) | x86_64 || 13.x + |
| Linux (musl) | arm64 || 13.x + |
| Windows | x86_64 || All |
| Windows | x86 || 9.x - |
| Windows | arm64 || - |

</details>

## Roadmap

The [roadmap](https://docs.pact.io/roadmap/) for Pact and Pact JS is outlined on our main website.
Expand Down
24 changes: 12 additions & 12 deletions examples/e2e/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion examples/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Pact JS E2E Example",
"scripts": {
"test": "npm run test:consumer && npm run test:publish && npm run test:provider",
"test:no:publish": "npm run test:consumer && npm run test:provider",
"test:consumer": "mocha test/consumer.spec.js",
"test:publish": "pact-broker publish ./pacts --consumer-app-version=\"$(npx absolute-version)\" --auto-detect-version-properties --broker-base-url=https://test.pactflow.io --broker-username dXfltyFMgNOFZAxr8io9wJ37iUpY42M --broker-password O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1",
"test:provider": "mocha test/provider.spec.js",
Expand All @@ -19,7 +20,7 @@
"devDependencies": {
"absolute-version": "1.0.1",
"@pact-foundation/pact": "file:../../dist",
"@pact-foundation/pact-cli": "^15.0.1",
"@pact-foundation/pact-cli": "^15.0.2",
"body-parser": "^1.20.0",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
Expand Down
Loading

0 comments on commit 6107a35

Please sign in to comment.