generated from finos/software-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 114
90 lines (86 loc) · 3.37 KB
/
check-code.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Check Code
on:
push:
branches:
- master
- 'release/**'
pull_request:
branches:
- '**'
# Cancel running jobs from previous pipelines of the same workflow on PR to save resource when commits are pushed quickly
# NOTE: we don't want this behavior on default branch
# See https://stackoverflow.com/a/68422069
concurrency:
group: ${{ github.ref == 'refs/heads/master' && format('ci-default-branch-{0}-{1}', github.sha, github.workflow) || format('ci-pr-{0}-{1}', github.ref, github.workflow) }}
cancel-in-progress: true
jobs:
check-code:
name: Run Code Checks
# Disable usage of large runner on default branch of forks
# NOTE: temporarily disable large runner
# runs-on: ${{ (github.repository != 'finos/legend-studio' && github.ref == 'refs/heads/master') && 'ubuntu-latest' || 'ubuntu-latest-4-cores' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Setup Yarn cache
uses: actions/[email protected]
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- name: Setup Node
uses: actions/[email protected]
with:
node-version: 16
- name: Install dependencies
run: yarn
# NOTE: we need this step to build the code before linting
- name: Check typings
run: yarn check:ts
- name: Run lint
run: yarn lint:ci
check-codebase-maintenance:
name: Run Codebase Maintenance Checks
# Disable usage of large runner on default branch of forks
# NOTE: temporarily disable large runners
# runs-on: ${{ (github.repository != 'finos/legend-studio' && github.ref == 'refs/heads/master') && 'ubuntu-latest' || 'ubuntu-latest-4-cores' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Setup Yarn cache
uses: actions/[email protected]
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- name: Setup Node
uses: actions/[email protected]
with:
node-version: 16
- name: Install dependencies
run: yarn
- name: Check package manifests
run: yarn check:pkg
- name: Check code formatting
run: yarn check:format
- name: Check copyright headers
run: yarn check:copyright
- name: Check code documentation
# We don't need this check when running the CI in the default branch
# since we already build the website there
if: github.ref != 'refs/heads/master' || github.repository != 'finos/legend-studio'
env:
# Typedoc build could consume a large amount of memory
# See https://github.com/TypeStrong/typedoc/issues/1606
NODE_OPTIONS: '--max_old_space_size=4096'
run: yarn build:ts && yarn build:doc