-
Notifications
You must be signed in to change notification settings - Fork 1
131 lines (124 loc) · 4.36 KB
/
main.yml
File metadata and controls
131 lines (124 loc) · 4.36 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
131
name: CI
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main, '**workflows?**' ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test:
if: >-
${{ !((github.event_name == 'pull_request'
&& contains(github.event.pull_request.title, '[ci-skip]'))
|| (github.event_name == 'push'
&& contains(github.event.head_commit.message, '[ci-skip]'))) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: ./package-lock.json
- run: npm install
- name: Fix Chrome sandbox issues
run: echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
- name: Run tests
id: run_tests
run: npm test -- --colors
- name: Check if need to upload diff
if: ${{ always() }}
id: check_output
run: |
echo "After test"
if test -e ./test/e2e/__image_snapshots__/__diff_output__ && test -n "$(ls -A ./test/e2e/__image_snapshots__/__diff_output__)" ; then
HAS_DIFF=1
else
HAS_DIFF=0
fi
echo $HAS_DIFF
echo "HAS_IMG_DIFF=$HAS_DIFF" >> "$GITHUB_OUTPUT"
- name: Upload image diff
uses: actions/upload-artifact@v4
if: ${{ failure() && steps.check_output.outputs.HAS_IMG_DIFF == 1 }}
with:
name: image-snapshot-diff
path: test/e2e/__image_snapshots__/__diff_output__
linter:
runs-on: ubuntu-latest
if: >-
${{ !((github.event_name == 'pull_request'
&& contains(github.event.pull_request.title, '[ci-skip]'))
|| (github.event_name == 'push'
&& contains(github.event.head_commit.message, '[ci-skip]'))) }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: ./package-lock.json
- name: Install npm pacakges
run: npm ci
# see https://www.npmjs.com/package/eslint#installation-and-usage
- name: Run eslint
run: ./node_modules/.bin/eslint --max-warnings 0 ./
- name: Run custom linters
run: node ./scripts/lint/find_bad_import.js
check_formatted:
runs-on: ubuntu-latest
if: >-
${{ !((github.event_name == 'pull_request'
&& contains(github.event.pull_request.title, '[ci-skip]'))
|| (github.event_name == 'push'
&& contains(github.event.head_commit.message, '[ci-skip]'))) }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: ./package-lock.json
- name: Install npm pacakges
run: npm ci
- name: Check that code is formatted
id: check_format
run: npm run format_check
- name: Report files that would be changed
if: always() && steps.check_format.outcome == 'failure'
run: |
npm run format
echo Error: formatter would change these files:
git diff HEAD --color
build:
runs-on: ubuntu-latest
if: >-
${{ !((github.event_name == 'pull_request'
&& contains(github.event.pull_request.title, '[ci-skip]'))
|| (github.event_name == 'push'
&& contains(github.event.head_commit.message, '[ci-skip]'))) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: ./package-lock.json
- name: Install npm pacakges
run: npm ci
- name: Build libs
run: npm run build:libs
- name: Build `.ts` files
run: npm run build:ts
- name: Generate texture atlas
run: npm run build:atlas
- name: Commit texture atlas
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "ci: Commit built files [generated]"