Skip to content

Commit

Permalink
ci: improve (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
danilowoz authored Apr 12, 2022
1 parent 45db2f2 commit c2864b7
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 111 deletions.
File renamed without changes.
248 changes: 205 additions & 43 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: CI
on: [pull_request, push]

jobs:
integration:
name: Integration tests
install:
name: Install
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
Expand All @@ -13,101 +13,263 @@ jobs:
- name: Setup | Node.js
uses: actions/setup-node@v2
with:
node-version: "14.16.1"
node-version-file: .nvmrc

- name: Setup | Cache
uses: c-hive/gha-yarn-cache@v2

- name: Setup | Install dependencies
run: yarn install --frozen-lockfile

- name: Setup | Cache node_modules
uses: actions/cache@v3
id: cache-node-modules
with:
path: |
node_modules
packages/*/node_modules
key: modules-${{ hashFiles('yarn.lock') }}

build:
name: Build
runs-on: ubuntu-18.04
timeout-minutes: 10
needs: install
steps:
- name: Setup | Checkout
uses: actions/checkout@v1

- name: Cypress run
uses: cypress-io/github-action@v2
- name: Setup | Node.js
uses: actions/setup-node@v2
with:
build: yarn build
start: yarn dev:react
config: video=false
node-version-file: .nvmrc

- name: Setup | Cache
uses: c-hive/gha-yarn-cache@v2

test:
name: Unit tests
- name: Setup | Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: yarn run build

- name: Cache react build
uses: actions/cache@v3
with:
path: sandpack-react/dist
key: sandpack-react-${{ github.run_id }}
restore-keys: sandpack-react-

- name: Cache client build
uses: actions/cache@v3
with:
path: sandpack-client/dist
key: sandpack-client-${{ github.run_id }}
restore-keys: sandpack-client-

sizebot:
name: Sizebot
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [install, build]
steps:
- name: Setup | Checkout
uses: actions/checkout@v1

- name: Setup | Node.js
uses: actions/setup-node@v2
with:
node-version: "14.16.1"

- name: Install dependencies and cache
uses: bahmutov/npm-install@v1
node-version-file: .nvmrc

- name: Setup | Cache node_modules
uses: actions/cache@v3
with:
path: |
node_modules
packages/*/node_modules
key: modules-${{ hashFiles('yarn.lock') }}

- name: Setup | Restore react build
uses: actions/cache@v3
with:
useLockFile: true
path: sandpack-react/dist
key: sandpack-react-${{ github.run_id }}

- name: Setup | Restore client build
uses: actions/cache@v3
with:
path: sandpack-client/dist
key: sandpack-client-${{ github.run_id }}

- name: Setup | Build
run: yarn run build
- name: Bot script
run: node scripts/sizebot/index.js
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

chromatic-deployment:
name: Chromatic deployment
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [install, build]
steps:
- name: Setup | Checkout
uses: actions/checkout@v1

- name: Test | Jest
run: yarn run test
- name: Setup | Node.js
uses: actions/setup-node@v2
with:
node-version-file: .nvmrc

- name: Setup | Cache node_modules
uses: actions/cache@v3
with:
path: |
node_modules
packages/*/node_modules
key: modules-${{ hashFiles('yarn.lock') }}

- name: Setup | Restore react build
uses: actions/cache@v3
with:
path: sandpack-react/dist
key: sandpack-react-${{ github.run_id }}

- name: Setup | Restore client build
uses: actions/cache@v3
with:
path: sandpack-client/dist
key: sandpack-client-${{ github.run_id }}

lint:
name: Lint
- name: Publish to Chromatic
uses: chromaui/action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
buildScriptName: "chromatic:react"

integration:
name: Integration tests
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [install, build]
steps:
- name: Setup | Checkout
uses: actions/checkout@v1

- name: Setup | Node.js
uses: actions/setup-node@v2
with:
node-version: "14.16.1"

- name: Install dependencies and cache
uses: bahmutov/npm-install@v1
node-version-file: .nvmrc
- name: Setup | Cache node_modules
uses: actions/cache@v3
with:
useLockFile: true
path: |
node_modules
packages/*/node_modules
key: modules-${{ hashFiles('yarn.lock') }}

- name: Setup | Restore react build
uses: actions/cache@v3
with:
path: sandpack-react/dist
key: sandpack-react-${{ github.run_id }}

- name: Setup | Restore client build
uses: actions/cache@v3
with:
path: sandpack-client/dist
key: sandpack-client-${{ github.run_id }}

- name: Lint | Eslint
run: yarn run lint
- name: Cypress run
uses: cypress-io/github-action@v2
with:
start: yarn dev:react
config: video=false

build:
name: Build
runs-on: ubuntu-18.04
test:
name: Unit tests
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [install, build]
steps:
- name: Setup | Checkout
uses: actions/checkout@v1

- name: Setup | Node.js
uses: actions/setup-node@v2
with:
node-version: "14.16.1"
node-version-file: .nvmrc

- name: Setup | Cache node_modules
uses: actions/cache@v3
with:
path: |
node_modules
packages/*/node_modules
key: modules-${{ hashFiles('yarn.lock') }}

- name: Setup | Restore react build
uses: actions/cache@v3
with:
path: sandpack-react/dist
key: sandpack-react-${{ github.run_id }}

- name: Setup | Restore client build
uses: actions/cache@v3
with:
path: sandpack-client/dist
key: sandpack-client-${{ github.run_id }}

- name: Test | Jest
run: yarn run test

lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 10
needs: install
steps:
- name: Setup | Checkout
uses: actions/checkout@v1

- name: Install dependencies and cache
uses: bahmutov/npm-install@v1
- name: Setup | Node.js
uses: actions/setup-node@v2
with:
node-version-file: .nvmrc

- name: Setup | Cache node_modules
uses: actions/cache@v3
with:
useLockFile: true
path: |
node_modules
packages/*/node_modules
key: modules-${{ hashFiles('yarn.lock') }}

- name: Build
run: yarn run build
- name: Lint | Eslint
run: yarn run lint

format:
name: Format
runs-on: ubuntu-18.04
timeout-minutes: 10
needs: install
steps:
- name: Setup | Checkout
uses: actions/checkout@v1

- name: Setup | Node.js
uses: actions/setup-node@v2
with:
node-version: "14.16.1"

- name: Install dependencies and cache
uses: bahmutov/npm-install@v1
node-version-file: .nvmrc
- name: Setup | Cache node_modules
uses: actions/cache@v3
with:
useLockFile: true
path: |
node_modules
packages/*/node_modules
key: modules-${{ hashFiles('yarn.lock') }}

- name: Build
- name: Format
run: yarn run format:check
32 changes: 0 additions & 32 deletions .github/workflows/chromatic.yml

This file was deleted.

File renamed without changes.
35 changes: 0 additions & 35 deletions .github/workflows/sizebot.yml

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const HTML: React.FC = () => (
</SandpackProvider>
);

export const JavaScript: React.FC = () => (
export const Javascript: React.FC = () => (
<SandpackProvider>
<CodeEditor
code={`
Expand Down

0 comments on commit c2864b7

Please sign in to comment.