forked from toolchainlabs/toolchain-oss
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (130 loc) · 4.77 KB
/
node-js-ci.yml
File metadata and controls
130 lines (130 loc) · 4.77 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Node JS CI
on:
push:
branches:
- master
- 'auto-updates/**'
pull_request: {}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
check_for_changes:
name: Check JS Changes
runs-on: ubuntu-24.04
outputs:
js_changes: ${{ steps.changed-files.outputs.any_modified }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
lfs: false
- name: Get changed files
id: changed-files
# tj-actions/changed-files - pinned it a git hash for maximum safety, managed by dependabot
uses: tj-actions/changed-files@f7a56405a89ea095c6230f10e7f1c49daab13b35
with:
files: |
src/node/**
.github/**
nodes_js_ci:
name: Node/JS CI
runs-on: ubuntu-24.04
needs: check_for_changes
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
with:
lfs: false
- name: Use Node.js
uses: actions/setup-node@v3
if: needs.check_for_changes.outputs.js_changes == 'true'
with:
node-version-file: 'src/node/.nvmrc'
cache: 'yarn'
cache-dependency-path: src/node/yarn.lock
- name: Cache node_modules
uses: actions/cache@v3
if: needs.check_for_changes.outputs.js_changes == 'true'
with:
key: node-js-yarn-cache-v1-${{ runner.os }}-${{ hashFiles('src/node/yarn.lock') }}
path: |
'src/node/node_modules/'
'src/node/toolchain/frontend/node_modules/'
'src/node/toolchain/pants-demo-site/node_modules/'
- name: Install dependencies
if: needs.check_for_changes.outputs.js_changes == 'true'
working-directory: src/node
run: |
yarn install --dev
# Emit the versions so we know what things ran against.
echo "Node version: $(node --version)"
echo "Yarn version: $(yarn --version)"
echo "Yarn cache dir: $(yarn cache dir)"
yarn check --integrity
- name: Lint Frontend SPA
if: needs.check_for_changes.outputs.js_changes == 'true'
working-directory: src/node/toolchain/frontend
run: yarn lint && yarn prettier-check
- name: Lint Pants demo site SPA
if: needs.check_for_changes.outputs.js_changes == 'true'
working-directory: src/node/toolchain/pants-demo-site
run: yarn lint && yarn prettier-check
- name: Test Frontend SPA
if: needs.check_for_changes.outputs.js_changes == 'true'
working-directory: src/node/toolchain/frontend
env:
NODE_OPTIONS: --max_old_space_size=6144
run: yarn test-ci
- name: Upload Frontend SPA tests coverage
uses: codecov/codecov-action@v3.1.0
if: needs.check_for_changes.outputs.js_changes == 'true'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: dist/node_coverage/frontend/clover.xml
flags: node,frontend
name: spa_js_upload
- name: Test Pants demo site SPA
if: needs.check_for_changes.outputs.js_changes == 'true'
working-directory: src/node/toolchain/pants-demo-site
run: yarn test-ci
- name: Upload Pants demo site SPA tests coverage
uses: codecov/codecov-action@v3.1.0
if: needs.check_for_changes.outputs.js_changes == 'true'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: src/node/toolchain/pants-demo-site/coverage/clover.xml
flags: node,demosite
name: demosite_js_upload
- name: Bundle Toolchain frontend SPA
if: needs.check_for_changes.outputs.js_changes == 'true'
working-directory: src/node/toolchain/frontend
run: yarn build
- name: Bundle Pants demo site SPA
if: needs.check_for_changes.outputs.js_changes == 'true'
working-directory: src/node/toolchain/pants-demo-site
run: yarn build
cypress-run:
name: Cypress tests
runs-on: ubuntu-24.04
needs: check_for_changes
if: needs.check_for_changes.outputs.js_changes == 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
cache: 'yarn'
cache-dependency-path: src/node/yarn.lock
node-version-file: 'src/node/toolchain/pants-demo-site/.nvmrc'
# Install NPM dependencies, cache them correctly
# and run all Cypress tests
- name: Cypress run
uses: cypress-io/github-action@v5
with:
working-directory: src/node/toolchain/pants-demo-site
browser: chrome
start: yarn run start
wait-on: 'http://localhost:3000'
command: yarn run cypress run