2023-11-10 11:06:18 -06:00
|
|
|
# This file contains the main workflow for the create-react-ssr project. It defines the steps and actions to be taken when the workflow is triggered.
|
|
|
|
# Name of the workflow
|
|
|
|
name: Main Workflow
|
2022-07-28 21:22:02 -06:00
|
|
|
|
2023-11-10 11:06:18 -06:00
|
|
|
# Define the events that trigger the workflow
|
2022-07-28 21:22:02 -06:00
|
|
|
on:
|
2023-11-10 11:06:18 -06:00
|
|
|
push:
|
|
|
|
branches: [ master ]
|
2022-07-28 21:22:02 -06:00
|
|
|
pull_request:
|
|
|
|
branches: ['*']
|
2023-11-10 11:06:18 -06:00
|
|
|
|
|
|
|
# Define the jobs that run as part of the workflow
|
2022-07-28 21:22:02 -06:00
|
|
|
jobs:
|
2023-11-20 11:13:08 -06:00
|
|
|
# Job to run unit tests
|
|
|
|
unit-front-end-testing:
|
2022-07-28 21:22:02 -06:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
node-version: [16.x]
|
|
|
|
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Use Node.js 16
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version: 16
|
|
|
|
cache: 'npm'
|
2022-08-01 09:02:40 -06:00
|
|
|
registry-url: https://registry.npmjs.org/
|
2024-11-13 09:09:14 -06:00
|
|
|
- run: npm ci
|
2022-08-01 09:02:40 -06:00
|
|
|
- run: npm test
|
2023-11-10 11:06:18 -06:00
|
|
|
|
2023-11-20 11:13:08 -06:00
|
|
|
# Job to run Cypress component tests
|
|
|
|
cypress-components-testing:
|
2023-03-02 07:57:42 -06:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
# Install NPM dependencies, cache them correctly
|
|
|
|
# and run all Cypress tests
|
2024-02-13 15:24:08 -06:00
|
|
|
- name: Install dependencies
|
2024-11-13 09:09:14 -06:00
|
|
|
run: npm ci
|
2023-03-02 07:57:42 -06:00
|
|
|
- name: Cypress run
|
2024-02-13 16:30:03 -06:00
|
|
|
uses: cypress-io/github-action@v6 # use the explicit version number
|
2023-03-02 07:57:42 -06:00
|
|
|
with:
|
2023-11-20 11:13:08 -06:00
|
|
|
component: true
|
2024-02-13 15:31:09 -06:00
|
|
|
install: false
|
2023-11-20 11:13:08 -06:00
|
|
|
|
|
|
|
# Job to run Cypress End to End tests
|
|
|
|
end-to-end-testing:
|
2023-03-07 11:03:19 -06:00
|
|
|
runs-on: ubuntu-latest
|
2023-11-20 11:13:08 -06:00
|
|
|
env:
|
|
|
|
PORT: 3000
|
2023-03-07 11:03:19 -06:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
# Install NPM dependencies, cache them correctly
|
|
|
|
# and run all Cypress tests
|
2024-02-13 15:24:08 -06:00
|
|
|
- name: Install dependencies
|
2024-11-13 09:09:14 -06:00
|
|
|
run: npm ci
|
2023-03-07 11:03:19 -06:00
|
|
|
- name: Cypress run
|
2024-02-13 16:30:03 -06:00
|
|
|
uses: cypress-io/github-action@v6 # use the explicit version number
|
2023-03-07 11:03:19 -06:00
|
|
|
with:
|
2024-02-13 15:31:09 -06:00
|
|
|
install: false
|
2023-11-20 11:13:08 -06:00
|
|
|
build: npm run build
|
|
|
|
start: npm start
|
2023-11-10 11:06:18 -06:00
|
|
|
|
|
|
|
# Job to build the package
|
2022-08-01 09:02:40 -06:00
|
|
|
test-build-package:
|
2023-11-10 11:06:18 -06:00
|
|
|
if: github.ref != 'refs/heads/master'
|
2023-11-20 11:13:08 -06:00
|
|
|
needs: [ unit-front-end-testing, cypress-components-testing, end-to-end-testing ]
|
2023-11-10 11:06:18 -06:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version: 16
|
|
|
|
registry-url: https://registry.npmjs.org/
|
2024-11-13 09:09:14 -06:00
|
|
|
- run: npm ci
|
2023-11-10 11:06:18 -06:00
|
|
|
- run: npm run build
|
|
|
|
|
|
|
|
# Job to publish the package to NPM
|
|
|
|
publish-npm:
|
|
|
|
if: github.ref == 'refs/heads/master'
|
2023-11-20 11:13:08 -06:00
|
|
|
needs: [ unit-front-end-testing, cypress-components-testing, end-to-end-testing ]
|
2022-08-01 09:02:40 -06:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version: 16
|
|
|
|
registry-url: https://registry.npmjs.org/
|
2024-11-13 09:09:14 -06:00
|
|
|
- run: npm ci
|
2023-11-10 11:06:18 -06:00
|
|
|
- run: npm publish --access=public
|
|
|
|
env:
|
2024-02-13 18:58:02 -06:00
|
|
|
NPM_PERSONAL_TOKEN: ${{secrets.npm_token}}
|