Skip to content

Commit

Permalink
add multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcC399 committed Mar 6, 2024
1 parent 9b7c20f commit 4f9f6fd
Showing 1 changed file with 66 additions and 42 deletions.
108 changes: 66 additions & 42 deletions .github/workflows/example-start-and-pnpm-workspaces.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ jobs:
# examples/start-and-pnpm-workspaces

single-ws:

# This job installs pnpm into the runner
# Installs all dependencies
# Caches the pnpm store
# Caches the Cypress binary cache
# This job installs pnpm,
# installs all dependencies,
# caches the pnpm store,
# caches the Cypress binary cache,
# then runs Cypress tests in
# the single workspace of
# the subfolder "packages/workspace-1"
# the subfolder "packages/workspace-1".
runs-on: ubuntu-22.04
name: Install dependencies
name: Single workspace
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -35,9 +34,8 @@ jobs:
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
# cypress github-action does not cache pnpm dependencies by default
# cache the dependencies for following jobs in this workflow
# and for future runs of the workflow
# Cypress github-action does not cache pnpm dependencies by default.
# Cache the dependencies.
- name: Setup pnpm cache
uses: actions/cache@v4
with:
Expand All @@ -46,23 +44,25 @@ jobs:
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies with Cypress GitHub Action
# calling the Cypress GitHub Action causes all dependencies from
- name: Install dependencies
# with Cypress GitHub Action.
# Calling the Cypress GitHub Action causes all dependencies from
# the root of the pnpm workspace examples/start-and-pnpm-workspaces
# to be installed
# AND it automatically caches the Cypress binary.
#
# If you copy this workflow to another repository replace the following with
# uses: cypress-io/github-action@v6
# The notation ./ is a special usage only used here.
# It causes the version of the action in whatever branch it is launched in to be used.
# Do not try to use this outside of this repository!
uses: ./ # equivalent to using cypress-io/github-action@v6
# It causes the version of the action code from whatever branch it is launched in to be used.
# Do not try to use the ./ notation this outside of this repository!
uses: ./ # approximately equivalent to using cypress-io/github-action@v6
with:
working-directory: examples/start-and-pnpm-workspaces
runTests: false

- name: Single workspace
- name: Cypress test Single
# Run Cypress in examples/start-and-pnpm-workspaces/packages/workspace-1 only
uses: ./ # equivalent to using cypress-io/github-action@v6
with:
# Do not attempt to install dependencies in the workspace using the action.
Expand All @@ -75,30 +75,54 @@ jobs:
start: pnpm start
wait-on: 'http://localhost:5000'

# multiple:
# # example with web application build,
# # server start and waiting for the server
# # to respond before running tests
# # in each Yarn workspaces subfolder
# runs-on: ubuntu-22.04
# strategy:
# # when one test fails, DO NOT cancel the other
# # containers, because this will kill Cypress processes
# # leaving the Cypress Cloud hanging ...
# # https://github.com/cypress-io/github-action/issues/48
# fail-fast: false
# matrix:
# cypress:
# - working_directory: examples/start-and-pnpm-workspaces/workspace-1
# - working_directory: examples/start-and-pnpm-workspaces/workspace-2
# steps:
# - name: Checkout
# uses: actions/checkout@v4
multiple-ws:
# This job installs pnpm,
# installs all dependencies,
# caches the pnpm store,
# caches the Cypress binary cache,
# then runs Cypress tests in each of the workspaces.
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
cypress:
- working_directory: examples/start-and-pnpm-workspaces/packages/workspace-1
- working_directory: examples/start-and-pnpm-workspaces/packages/workspace-2
name: Multiple workspace
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install pnpm
run: npm install -g pnpm@8

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('examples/basic-pnpm/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
uses: ./ # approximately equivalent to using cypress-io/github-action@v6
with:
working-directory: examples/start-and-pnpm-workspaces
runTests: false

# - name: Cypress tests
# uses: ./
# with:
# working-directory: ${{ matrix.cypress.working_directory }}
# build: pnpm run build
# start: pnpm start
# wait-on: 'http://localhost:5000'
- name: Cypress test Multiple
# Run Cypress in
# examples/start-and-pnpm-workspaces/packages/workspace-1 and
# examples/start-and-pnpm-workspaces/packages/workspace-2
uses: ./ # equivalent to using cypress-io/github-action@v6
with:
install: false
working-directory: ${{ matrix.cypress.working_directory }}
build: pnpm run build
start: pnpm start
wait-on: 'http://localhost:5000'

0 comments on commit 4f9f6fd

Please sign in to comment.