pact-foundation/pact-js

View on GitHub
.github/workflows/build-and-test.yml

Summary

Maintainability
Test Coverage
name: Build, test, test all examples

on:
  push:
  pull_request:
    branches: [master, 9.x.x]
  workflow_dispatch:

env:
  GIT_COMMIT: ${{ github.sha }}
  GIT_REF: ${{ github.ref }}
  GIT_BRANCH: ${{ github.head_ref || github.ref_name }}
  LOG_LEVEL: info

jobs:
  build-and-test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        node-version: [16.x, 18.x, 20.x]
        os: [macos-latest, ubuntu-latest, windows-latest]

    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Use Node.js ${{ matrix.node-version }}
        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

      #  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: Upload dist folder
      #   if: runner.os == 'Linux'
      #   uses: actions/upload-artifact@v3
      #   with:
      #     path: dist

  # 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 }}

  #   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 }}