ToolJet/.github/workflows/ci.yml
Akshay 51075205b9
Chore: Run ci only when label is added (#1796)
* run ci only when label 'run-ci' is added

* add labeled type

* fix label
2022-01-12 08:22:49 +05:30

159 lines
5 KiB
YAML

name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the develop branch
push:
branches: [develop, main]
pull_request:
types: [ labeled ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main') && github.run_number || github.ref }}
cancel-in-progress: true
env:
FORCE_COLOR: true
NODE_OPTIONS: "--max-old-space-size=4096"
LOCKBOX_MASTER_KEY: lockbox-master-key
SECRET_KEY_BASE: secrret-key-base
NODE_ENV: test
PG_HOST: postgres
PG_PORT: 5432
PG_USER: postgres
PG_PASS: postgres
PG_DB: tooljet_test
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.event.label.name == 'run-ci' }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Use Node.js 14.17.3
uses: actions/setup-node@v2
with:
node-version: 14.17.3
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: npm i -g npm@7.20.0
- run: npm run build
lint:
runs-on: ubuntu-latest
if: ${{ github.event.label.name == 'run-ci' }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Use Node.js 14.17.3
uses: actions/setup-node@v2
with:
node-version: 14.17.3
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: npm i -g npm@7.20.0
- run: npm --prefix frontend ci && npm --prefix server ci
- run: npm --prefix server run lint && npm --prefix frontend run lint
unit-test:
runs-on: ubuntu-latest
needs: build
container: node:14.17.3-buster
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: apt update && apt install -y postgresql
- run: npm i -g npm@7.20.0
- run: npm --prefix server ci
- run: npm --prefix server run db:create
- run: npm --prefix server run db:migrate
- run: npm --prefix server run test
e2e-test:
runs-on: ubuntu-latest
needs: build
container: node:14.17.3-buster
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: apt update && apt install -y postgresql
- run: npm i -g npm@7.20.0
- run: npm --prefix server ci
- run: npm --prefix server run db:create
- run: npm --prefix server run db:migrate
- run: npm --prefix server run test:e2e -- --silent