Skip to content

Commit 9435912

Browse files
authored
Merge pull request asgardeo#24 from brionmario/ci-pr-builder
ci: add pr builder
2 parents fb09345 + d316bad commit 9435912

2 files changed

Lines changed: 219 additions & 0 deletions

File tree

.github/workflows/pr-builder.yml

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
# This workflow will build PRs submitted to the main branch.
2+
3+
name: 👷 PR Builder
4+
5+
on:
6+
pull_request:
7+
branches: [main]
8+
paths-ignore:
9+
- "**.md"
10+
- "LICENSE"
11+
workflow_dispatch:
12+
13+
env:
14+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
16+
jobs:
17+
lint:
18+
name: ⬣ ESLint (STATIC ANALYSIS)
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
node-version: [lts/*]
23+
steps:
24+
- name: ⬇️ Checkout
25+
id: checkout
26+
uses: actions/[email protected]
27+
with:
28+
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
29+
fetch-depth: 0
30+
31+
- name: 🟢 Setup node
32+
id: setup-node
33+
uses: actions/setup-node@v2
34+
with:
35+
node-version: ${{ matrix.node-version }}
36+
37+
- name: 🐳 Set SHAs for Nx
38+
id: set-shas
39+
uses: nrwl/nx-set-shas@v3
40+
with:
41+
main-branch-name: "main"
42+
43+
- name: 🥡 Setup pnpm
44+
id: setup-pnpm
45+
uses: pnpm/[email protected]
46+
with:
47+
version: latest
48+
run_install: false
49+
50+
- name: 🎈 Get pnpm store directory
51+
id: get-pnpm-cache-dir
52+
run: |
53+
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
54+
55+
- name: 🔆 Cache pnpm modules
56+
uses: actions/cache@v3
57+
id: pnpm-cache
58+
with:
59+
path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }}
60+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
61+
restore-keys: |
62+
${{ runner.os }}-pnpm-store-
63+
64+
- name: 🧩 Install Dependencies
65+
id: install-dependencies
66+
run: pnpm install
67+
68+
- name: 🦄 Lint All Files
69+
id: lint-with-eslint
70+
run: pnpm nx affected --target=lint --parallel=3 --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }}
71+
72+
typecheck:
73+
name: ʦ Typecheck (STATIC ANALYSIS)
74+
runs-on: ubuntu-latest
75+
strategy:
76+
matrix:
77+
node-version: [lts/*]
78+
steps:
79+
- name: ⬇️ Checkout
80+
id: checkout
81+
uses: actions/[email protected]
82+
with:
83+
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
84+
fetch-depth: 0
85+
86+
- name: 🟢 Setup node
87+
id: setup-node
88+
uses: actions/setup-node@v2
89+
with:
90+
node-version: ${{ matrix.node-version }}
91+
92+
- name: 🐳 Set SHAs for Nx
93+
id: set-shas
94+
uses: nrwl/nx-set-shas@v3
95+
with:
96+
main-branch-name: "main"
97+
98+
- name: 🥡 Setup pnpm
99+
uses: pnpm/[email protected]
100+
with:
101+
version: latest
102+
run_install: false
103+
104+
- name: 🎈 Get pnpm store directory
105+
id: get-pnpm-cache-dir
106+
run: |
107+
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
108+
109+
- name: 🔆 Cache pnpm modules
110+
uses: actions/cache@v3
111+
id: pnpm-cache
112+
with:
113+
path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }}
114+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
115+
restore-keys: |
116+
${{ runner.os }}-pnpm-store-
117+
118+
- name: 🧩 Install Dependencies
119+
id: install-dependencies
120+
run: pnpm install
121+
122+
- name: ☄️ Check Type Errors
123+
run: pnpm nx affected --target=typecheck --parallel=3 --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }}
124+
125+
test:
126+
name: 👾 Unit Test (TESTING)
127+
needs: [lint, typecheck]
128+
runs-on: ubuntu-latest
129+
strategy:
130+
matrix:
131+
node-version: [lts/*]
132+
steps:
133+
- name: ⬇️ Checkout
134+
id: checkout
135+
uses: actions/[email protected]
136+
with:
137+
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
138+
fetch-depth: 0
139+
140+
- name: 🟢 Setup node
141+
id: setup-node
142+
uses: actions/setup-node@v2
143+
with:
144+
node-version: ${{ matrix.node-version }}
145+
146+
- name: 🥡 Setup pnpm
147+
uses: pnpm/[email protected]
148+
with:
149+
version: latest
150+
run_install: false
151+
152+
- name: 🎈 Get pnpm store directory
153+
id: get-pnpm-cache-dir
154+
run: |
155+
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
156+
157+
- name: 🔆 Cache pnpm modules
158+
uses: actions/cache@v3
159+
id: pnpm-cache
160+
with:
161+
path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }}
162+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
163+
restore-keys: |
164+
${{ runner.os }}-pnpm-store-
165+
166+
- name: 🧩 Install Dependencies
167+
id: install-dependencies
168+
run: pnpm install
169+
170+
- name: 🃏 Run Jest & Collect Coverage
171+
id: run-jest-test-and-coverage
172+
run: pnpm test
173+
174+
build:
175+
name: 🚧 Build
176+
needs: [ lint, typecheck, test ]
177+
runs-on: ubuntu-latest
178+
strategy:
179+
matrix:
180+
node-version: [lts/*]
181+
steps:
182+
- name: ⬇️ Checkout
183+
id: checkout
184+
uses: actions/[email protected]
185+
186+
- name: 🟢 Setup node
187+
id: setup-node
188+
uses: actions/setup-node@v2
189+
with:
190+
node-version: ${{ matrix.node-version }}
191+
192+
- name: 🥡 Setup pnpm
193+
uses: pnpm/[email protected]
194+
with:
195+
version: latest
196+
run_install: false
197+
198+
- name: 🎈 Get pnpm store directory
199+
id: get-pnpm-cache-dir
200+
run: |
201+
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
202+
203+
- name: 🔆 Cache pnpm modules
204+
uses: actions/cache@v3
205+
id: pnpm-cache
206+
with:
207+
path: ${{ steps.get-pnpm-cache-dir.outputs.pnpm_cache_dir }}
208+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
209+
restore-keys: |
210+
${{ runner.os }}-pnpm-store-
211+
212+
- name: 🧩 Install Dependencies
213+
id: install-dependencies
214+
run: pnpm install
215+
216+
- name: 🏗️ Build
217+
id: build
218+
run: pnpm build

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"lint": "nx run-many --target=lint --parallel",
2525
"publish:packages": "changeset publish",
2626
"test": "nx run-many --target=test --parallel",
27+
"typecheck": "nx run-many --target=typecheck --parallel",
2728
"version:packages": "changeset version && pnpm install --lockfile-only"
2829
},
2930
"devDependencies": {

0 commit comments

Comments
 (0)