diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..953b918 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -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/action-setup@v4.0.0 + 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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e33f792..8b6d66b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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/action-setup@v4.0.0 - 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 @@ -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 @@ -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/upload-artifact@v4.4.3 - if: ${{ failure() }} - with: - name: cypress-screenshots - path: e2e/cypress/screenshots - retention-days: 7 - - - name: export screen recordings (on failure only) - uses: actions/upload-artifact@v4.4.3 - if: ${{ failure() }} - with: - name: cypress-videos - path: e2e/cypress/videos - retention-days: 7 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7b74d19 --- /dev/null +++ b/.github/workflows/release.yml @@ -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/upload-artifact@v4.4.3 + if: ${{ failure() }} + with: + name: cypress-screenshots + path: e2e/cypress/screenshots + retention-days: 7 + + - name: Export screen recordings (on failure only) + uses: actions/upload-artifact@v4.4.3 + if: ${{ failure() }} + with: + name: cypress-videos + path: e2e/cypress/videos + retention-days: 7 diff --git a/e2e/package.json b/e2e/package.json index 2bb8261..ab0bd41 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -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", diff --git a/package.json b/package.json index 9c6cc47..335915b 100644 --- a/package.json +++ b/package.json @@ -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",