Skip to content

Commit

Permalink
ci: fix pull request workflows (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocavue authored Nov 28, 2024
1 parent 73af320 commit 1705a84
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 62 deletions.
30 changes: 30 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Setup
description: Setup the environment

inputs:
node-version:
description: The version of node.js
required: false
default: '20'

runs:
using: composite
steps:
- uses: pnpm/[email protected]
with:
run_install: false

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: pnpm
registry-url: 'https://registry.npmjs.org'

- name: Install
run: pnpm install
shell: bash

- name: Build packages
run: pnpm build
shell: bash
71 changes: 11 additions & 60 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,32 @@ name: ci

on:
push:
branches: main
branches: [main]
pull_request:
branches: main
branches: [main]

env:
CI: true
jobs:
release:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: setup node.js
uses: actions/setup-node@v4
with:
node-version: 20.11.0

- uses: pnpm/[email protected]
with:
run_install: false

- name: get pnpm store directory
id: pnpm-cache
run: echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: load cache
uses: actions/cache@v4
with:
path: |
~/.cache/Cypress
${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}

- name: install dependencies
run: pnpm install
- uses: ./.github/actions/setup

- name: build packs
run: pnpm build
- name: Lint
run: pnpm run lint

- name: run lint test
run: pnpm lint
- name: Install cypress
run: pnpm run install:cypress

- name: setup firefox
- name: Setup firefox
uses: browser-actions/setup-firefox@latest
with:
firefox-version: latest-esr

- name: run e2e test on chrome
- name: Run e2e test on chrome
uses: cypress-io/github-action@v6
env:
CYPRESS_SERVER_PORT: 7000
Expand All @@ -63,7 +39,7 @@ jobs:
wait-on: 'http://localhost:7000'
browser: chrome

- name: run e2e test on firefox
- name: Run e2e test on firefox
uses: cypress-io/github-action@v6
env:
CYPRESS_SERVER_PORT: 7001
Expand All @@ -74,28 +50,3 @@ jobs:
start: pnpm exec vite preview --port 7001 --host
wait-on: 'http://localhost:7001'
browser: firefox

- name: create versions or publish to npm registry
uses: changesets/action@v1
with:
publish: pnpm release
commit: 'ci(changeset): release prosemirror-adapter'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: export screenshots (on failure only)
uses: actions/[email protected]
if: ${{ failure() }}
with:
name: cypress-screenshots
path: e2e/cypress/screenshots
retention-days: 7

- name: export screen recordings (on failure only)
uses: actions/[email protected]
if: ${{ failure() }}
with:
name: cypress-videos
path: e2e/cypress/videos
retention-days: 7
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: release

on:
push:
branches: [main]

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: ./.github/actions/setup

- name: Create versions or publish to npm registry
uses: changesets/action@v1
with:
publish: pnpm release
commit: 'ci(changeset): release prosemirror-adapter'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Export screenshots (on failure only)
uses: actions/[email protected]
if: ${{ failure() }}
with:
name: cypress-screenshots
path: e2e/cypress/screenshots
retention-days: 7

- name: Export screen recordings (on failure only)
uses: actions/[email protected]
if: ${{ failure() }}
with:
name: cypress-videos
path: e2e/cypress/videos
retention-days: 7
3 changes: 2 additions & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"test": "cross-env CYPRESS_SERVER_PORT=7001 cypress run",
"test:verbose": "cross-env CYPRESS_SERVER_PORT=7001 cypress open",
"start:test": "cross-env CYPRESS_SERVER_PORT=7001 start-test setup :7001 test",
"start:test:verbose": "cross-env CYPRESS_SERVER_PORT=7001 start-test start :7001 test:verbose"
"start:test:verbose": "cross-env CYPRESS_SERVER_PORT=7001 start-test start :7001 test:verbose",
"install:cypress": "cypress install"
},
"devDependencies": {
"@lit-labs/context": "^0.5.0",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"changeset": "changeset",
"lint": "eslint .",
"release": "changeset publish",
"prepare": "husky"
"prepare": "husky",
"install:cypress": "pnpm --filter=e2e install:cypress"
},
"dependencies": {
"@antfu/eslint-config": "^3.0.0",
Expand Down

0 comments on commit 1705a84

Please sign in to comment.