Skip to content

Commit

Permalink
feat: add yarn 1 (classic) examples (#828)
Browse files Browse the repository at this point in the history
* add workflow for yarn classic

* Update .gitignore for yarn

* modify update script for yarn classic

* add yarn classic to readme

* create yarn-classic examples

---------

Co-authored-by: Bill Glesias <[email protected]>
  • Loading branch information
MikeMcC399 and AtofStryker authored Mar 17, 2023
1 parent d89e86b commit e77704d
Show file tree
Hide file tree
Showing 14 changed files with 2,458 additions and 2 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/example-yarn-classic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: example-yarn-classic
on:
push:
branches:
- 'master'
pull_request:
workflow_dispatch:

jobs:

# ~~~~~~~~~~~~~~~~~~ Cypress v9 and below (using Legacy configuration) ~~~~~~~~~~~~~~~~~~~ #

yarn-classic-v9:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Test with Yarn Classic
uses: ./
with:
working-directory: examples/v9/yarn-classic

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Cypress v10 and higher ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #

yarn-classic:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Test with Yarn Classic
uses: ./
with:
working-directory: examples/yarn-classic
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,21 @@ examples/**/cypress/screenshots
examples/**/cypress/downloads
results.json
.vscode/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# For Yarn Classic and Yarn Modern without Zero-Installs
# see https://yarnpkg.com/getting-started/qa/#which-files-should-be-gitignored

examples/**/.pnp.*
examples/**/.yarn/*
!examples/**/.yarn/patches
!examples/**/.yarn/plugins
!examples/**/.yarn/releases
!examples/**/.yarn/sdks
!examples/**/.yarn/versions
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
- pass [custom build id](#custom-build-id) when recording to Cypress Cloud
- generate a [robust custom build id](#robust-custom-build-id) to allow re-running the workflow
- use different [working-directory](#working-directory)
- use [Yarn Classic](#yarn-classic)
- use [Yarn workspaces](#yarn-workspaces)
- use [custom cache key](#custom-cache-key)
- run tests on multiple [Node versions](#node-versions)
- split [install and tests](#split-install-and-tests) into separate jobs
Expand Down Expand Up @@ -993,6 +995,31 @@ jobs:

See [cypress-gh-action-subfolders](https://github.com/bahmutov/cypress-gh-action-subfolders) (legacy) for example.

### Yarn Classic

If a `yarn.lock` file is found, the action uses the [Yarn 1 (Classic)](https://classic.yarnpkg.com/) command `yarn --frozen-lockfile` by default to install dependencies.

```yaml
name: example-yarn-classic
on: push
jobs:
yarn-classic:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cypress run
uses: cypress-io/github-action@v5
with:
working-directory: examples/yarn-classic
```

See [example-yarn-classic.yml](.github/workflows/example-yarn-classic.yml) for an example.

[![Yarn classic example](https://github.com/cypress-io/github-action/workflows/example-yarn-classic/badge.svg?branch=master)](.github/workflows/example-yarn-classic.yml)

See below under [Yarn Modern](#yarn-modern) (version 2 and later) for instructions on installing dependencies using this later version.

### Yarn workspaces

This action should discover the Yarn workspaces correctly. For example, see folder [examples/start-and-yarn-workspaces](examples/start-and-yarn-workspaces) and workflow file [example-start-and-yarn-workspaces.yml](.github/workflows/example-start-and-yarn-workspaces.yml)
Expand Down Expand Up @@ -1175,15 +1202,19 @@ See [cypress-gh-action-example](https://github.com/bahmutov/cypress-gh-action-ex

This action installs local dependencies using lock files. If `yarn.lock` file is found, the install uses `yarn --frozen-lockfile` command. Otherwise it expects to find `package-lock.json` and install using `npm ci` command.

The above default `yarn` installation command can be replaced for [Yarn Berry](https://yarnpkg.com/) (Yarn 2 and later) using the `install-command` parameter, for example:
#### Yarn Modern

The above default `yarn` installation command can be replaced for [Yarn Modern](https://yarnpkg.com/) (Yarn 2 and later) using the `install-command` parameter, for example:

```yml
- uses: cypress-io/github-action@v5
with:
install-command: yarn install
```

This action uses several production dependencies. The minimum Node version required to run this action depends on the minimum Node required by the dependencies.
#### Minimum Node.js

This action uses several production dependencies. The minimum Node version required to run this action depends on the minimum Node version required by the dependencies.

## Debugging

Expand Down
3 changes: 3 additions & 0 deletions examples/v9/yarn-classic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# example: yarn-classic

This example demonstrates installing dependencies using [Yarn 1 (Classic)](https://classic.yarnpkg.com/lang/en/).
6 changes: 6 additions & 0 deletions examples/v9/yarn-classic/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"fixturesFolder": false,
"supportFile": false,
"pluginsFile": false,
"baseUrl": "https://example.cypress.io/"
}
7 changes: 7 additions & 0 deletions examples/v9/yarn-classic/cypress/integration/spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// <reference types="cypress" />
describe('example: yarn-classic', () => {
it('loads the deployed site', () => {
cy.visit('/')
cy.contains('h1', 'Kitchen Sink')
})
})
13 changes: 13 additions & 0 deletions examples/v9/yarn-classic/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "example-yarn-classic",
"version": "1.0.0",
"description": "Install dependencies using Yarn",
"scripts": {
"test": "cypress run"
},
"license": "MIT",
"private": true,
"devDependencies": {
"cypress": "9.7.0"
}
}
Loading

0 comments on commit e77704d

Please sign in to comment.