Skip to content

Commit 91db3ea

Browse files
committed
Extract test-lint into custom action, run it before all workflows
Use on-push / on-release triggers for (pre)release workflows for lib Should close #18
1 parent fdeb40d commit 91db3ea

File tree

5 files changed

+49
-41
lines changed

5 files changed

+49
-41
lines changed

.github/actions/test-lint.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 'Test and lint code'
2+
description: 'Performs tests and linting of all the components in the repo'
3+
runs:
4+
using: 'composite'
5+
steps:
6+
# install bun
7+
- name: Install bun for deployment
8+
uses: oven-sh/setup-bun@v2
9+
with:
10+
bun-version: latest
11+
# install deps
12+
- name: Install lib deps
13+
working-directory: ./packages/litlytics
14+
run: bun install --frozen-lockfile
15+
- name: Install app deps
16+
run: bun install --frozen-lockfile
17+
# lib lint/check/test
18+
- name: Run lib typecheck
19+
working-directory: ./packages/litlytics
20+
run: bun run typecheck
21+
- name: Run lib tests
22+
working-directory: ./packages/litlytics
23+
run: bun run test:ci
24+
25+
# main app lint/check/test
26+
- name: Run app eslint
27+
run: bun run lint
28+
- name: Run app typecheck
29+
run: bun run typecheck
30+
- name: Run app test
31+
run: bun run test:ci

.github/workflows/docker-image.yml

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ jobs:
2727
- name: Checkout repository
2828
uses: actions/checkout@v4
2929

30+
# run test-lint
31+
- name: Test and lint
32+
uses: ./.github/actions/test-lint
33+
3034
- name: Install bun for deployment
3135
uses: oven-sh/setup-bun@v2
3236
with:

.github/workflows/prerelease-lib.yml

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
name: Prerelease litlytics library
22

33
on:
4-
workflow_run:
5-
# Run after "Test and lint" workflow
6-
workflows: ['Test and lint']
7-
types:
8-
- completed # Only when it's completed
9-
branches:
10-
- main # Only run the publish workflow for pushes to main
4+
push:
5+
branches: ['main'] # Only run the publish workflow for pushes to main
116

127
jobs:
138
publish-lib-prerelease:
@@ -25,6 +20,10 @@ jobs:
2520
with:
2621
fetch-depth: 2
2722

23+
# run test-lint
24+
- name: Test and lint
25+
uses: ./.github/actions/test-lint
26+
2827
# Check for changes in ./packages/litlytics
2928
- name: Check if changed
3029
id: changes

.github/workflows/release-lib.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
name: Release litlytics library
22

33
on:
4-
workflow_run:
5-
# Run after "Test and lint" workflow
6-
workflows: ['Test and lint']
4+
release:
75
types:
8-
- completed # Only when it's completed
6+
- published # run on new published releases
97

108
jobs:
119
publish-lib:
@@ -23,6 +21,10 @@ jobs:
2321
with:
2422
fetch-depth: 2
2523

24+
# run test-lint
25+
- name: Test and lint
26+
uses: ./.github/actions/test-lint
27+
2628
# Check for changes in ./packages/litlytics
2729
- name: Check if changed
2830
id: changes

.github/workflows/test-lint.yml

+2-30
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,5 @@ jobs:
2121
- name: Checkout repository
2222
uses: actions/checkout@v4
2323

24-
- name: Install bun for deployment
25-
uses: oven-sh/setup-bun@v2
26-
with:
27-
bun-version: latest
28-
29-
# install deps
30-
- name: Install lib deps
31-
working-directory: ./packages/litlytics
32-
run: bun install --frozen-lockfile
33-
- name: Install app deps
34-
run: bun install --frozen-lockfile
35-
36-
# lib lint/check/test
37-
- name: Run lib typecheck
38-
working-directory: ./packages/litlytics
39-
run: bun run typecheck
40-
41-
- name: Run lib tests
42-
working-directory: ./packages/litlytics
43-
run: bun run test:ci
44-
45-
# main app lint/check/test
46-
- name: Run app eslint
47-
run: bun run lint
48-
49-
- name: Run app typecheck
50-
run: bun run typecheck
51-
52-
- name: Run app test
53-
run: bun run test:ci
24+
- name: Test and lint
25+
uses: ./.github/actions/test-lint

0 commit comments

Comments
 (0)