Merge pull request #2676 from udecode/changeset-release/main #770
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Jest tests | |
on: | |
push: | |
branches: | |
- main | |
- next | |
paths: | |
- 'packages/**' | |
- '.github/workflows/test.yml' | |
- '.yarnrc.yml' | |
- 'yarn.lock' | |
- '.prettier*' | |
- '.eslint*' | |
- 'jest.config.js' | |
- 'tsconfig.json' | |
- 'turbo.json' | |
- 'config' | |
- 'scripts' | |
- 'patches' | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
paths: | |
- 'packages/**' | |
- '.github/workflows/test.yml' | |
- '.yarnrc.yml' | |
- 'yarn.lock' | |
- '.prettier*' | |
- '.eslint*' | |
- 'jest.config.js' | |
- 'tsconfig.json' | |
- 'turbo.json' | |
- 'config' | |
- 'scripts' | |
- 'patches' | |
workflow_dispatch: | |
jobs: | |
test: | |
name: ${{ matrix.command }} | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v3 | |
with: | |
# Fetch all git history so that yarn workspaces --since can compare with the correct commits | |
# @link https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches | |
fetch-depth: 0 | |
- name: Use Node.js 16.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16.x | |
# Why not using setup-node 2.2+ cache option (yet) ? | |
# see https://github.com/belgattitude/nextjs-monorepo-example/pull/369 | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn config get cacheFolder)" | |
- name: Restore yarn cache | |
uses: actions/cache@v3 | |
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: yarn-cache-folder-${{ hashFiles('**/yarn.lock', '.yarnrc.yml') }} | |
restore-keys: | | |
yarn-cache-folder- | |
- name: Restore packages cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{ github.workspace }}/.cache | |
${{ github.workspace }}/**/tsconfig.tsbuildinfo | |
key: ${{ runner.os }}-packages-cache-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('packages/**.[jt]sx?', 'packages/**.json') }} | |
restore-keys: | | |
${{ runner.os }}-packages-cache-${{ hashFiles('**/yarn.lock') }}- | |
- name: Install | |
run: YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install | |
# Build packages that have changed (--include & --since), assuming that | |
# apps build are done already. Otherwise --from & --since | |
- name: Build | |
run: yarn build | |
# Test packages that have changed (--include & --since) | |
- name: Test | |
run: yarn test | |
env: | |
CI: true | |
notify-test-failure: | |
name: Discord Notification | |
runs-on: ubuntu-20.04 | |
needs: | |
- test | |
if: ${{ github.event_name == 'push' && failure() }} | |
steps: | |
- name: Notify | |
uses: nobrayner/discord-webhook@v1 | |
with: | |
github-token: ${{ secrets.X_GITHUB_READ_ACTIONS_TOKEN }} | |
discord-webhook: ${{ secrets.DISCORD_CI_WEBHOOK }} | |
description: ${{ github.event.number && format('https://github.com/udecode/plate/pull/{0}', github.event.number) || 'Push' }} |