Skip to content

Commit

Permalink
ci: test docker - debian (arm64) / alpine (arm64/amd64)
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Jun 21, 2024
1 parent c841b75 commit 782d60d
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 91 deletions.
154 changes: 63 additions & 91 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,58 @@ 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]
include:
- 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: true
arch: amd64
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: amd64
node-version: 20
- os: ubuntu-latest
docker: true
alpine: true
arch: arm64
node-version: 18
- os: ubuntu-latest
docker: true
alpine: true
arch: amd64
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
Expand All @@ -29,97 +76,22 @@ jobs:
uses: actions/setup-node@v3
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 arm64
run: |
docker build --platform linux/${{ matrix.arch }} --build-arg=NODE_VERSION=${{ matrix.node-version }} -f Dockerfile.debian -t pact-js:${{ matrix.node-version }}-debian .
docker run --platform linux/${{ matrix.arch }} -v $PWD:/home -w /home --rm pact-js:${{ matrix.node-version }}-debian
# 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 }}
name: test linux amd64 musl
run: |
docker build --platform linux/${{ matrix.arch }} --build-arg=NODE_VERSION=${{ matrix.node-version }} -f Dockerfile.alpine -t pact-js:${{ matrix.node-version }}-alpine .
docker run --platform linux/${{ matrix.arch }} -v $PWD:/home -w /home --rm pact-js:${{ matrix.node-version }}-alpine
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=latest
FROM node:${NODE_VERSION}-alpine

RUN apk add bash curl git file libc6-compat gcompat
# 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" ]
6 changes: 6 additions & 0 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ARG NODE_VERSION=latest
FROM node:${NODE_VERSION}-slim

RUN apt-get -y update && apt-get -y install curl git

ENTRYPOINT [ "bash", "-c", "scripts/ci/build-and-test.sh" ]

0 comments on commit 782d60d

Please sign in to comment.