Skip to content

Commit f9455dd

Browse files
committed
feat(ci): add a GitHub Actions pipeline for Canvas UI PRs
1 parent ce372c7 commit f9455dd

File tree

3 files changed

+55
-6
lines changed

3 files changed

+55
-6
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Canvas UI PR Pipeline
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- "ui/**"
9+
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
env:
14+
# Disable sending data to IBM telemetry
15+
IBM_TELEMETRY_DISABLED: true
16+
CARBON_TELEMETRY_DISABLED: 1
17+
18+
jobs:
19+
ui_code_check:
20+
runs-on: ubuntu-latest
21+
defaults:
22+
run:
23+
working-directory: ./ui
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Set up Node
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: 20
32+
cache: "npm"
33+
cache-dependency-path: "./ui/package-lock.json"
34+
35+
- name: Install dependencies
36+
run: npm ci
37+
38+
- name: Run unit tests
39+
run: npm test
40+
41+
- name: Check Linting
42+
run: npm run lint
43+
44+
- name: Check Formatting
45+
run: npm run check-format
46+
47+
- name: Test Build
48+
run: npm run build -- --base /keip-canvas/

ui/git-hooks/pre-commit

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
#!/bin/sh
22
#
33
# An example hook script to verify what is about to be committed.
4-
# Called by "git commit" with no arguments. The hook should
4+
# Called by "git commit" with no arguments. The hook should
55
# exit with non-zero status after issuing an appropriate message if
66
# it wants to stop the commit.
77
#
8-
# To enable this hook, rename this file to "pre-commit".
8+
# To enable this hook, create this file at ".git/hooks/pre-commit" with execute permissions.
99

1010
UI_DIR_PATTERN='^ui/src/'
1111

1212
git diff --cached --name-only | grep ${UI_DIR_PATTERN} --quiet
1313
IS_UI_CHANGED=$?
1414

1515
if [ ${IS_UI_CHANGED} -ne 0 ]; then
16-
echo "[pre-commit hook] No UI code changes detected. Skip linting."
16+
echo "[pre-commit hook] No UI code changes detected. Skip precommit check."
1717
exit 0
1818
fi
1919

20-
LINT_CMD='npm --prefix ./ui run lint -- --color'
20+
PRECOMMIT_CMD='npm --prefix ./ui run precommit'
2121

22-
echo "[pre-commit hook] Linting...\n"
22+
echo "[pre-commit hook] Lint and check formatting...\n"
2323

24-
if output=$(${LINT_CMD}); then
24+
if output=$(${PRECOMMIT_CMD}); then
2525
exit 0
2626
else
2727
echo "$output" >&2

ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"format": "prettier --write ./src",
1212
"lint": "eslint .",
1313
"preview": "vite preview",
14+
"precommit": "npm run lint -- --color && npm run check-format",
1415
"test": "vitest run --silent"
1516
},
1617
"engines": {

0 commit comments

Comments
 (0)