Skip to content

Commit da6c996

Browse files
authored
feat(ci): improve composite action (#409)
1 parent fbefa33 commit da6c996

File tree

6 files changed

+54
-46
lines changed

6 files changed

+54
-46
lines changed

Diff for: .github/actions/setup-asdf-tools/action.yml

-19
This file was deleted.

Diff for: .github/actions/setup-environment/action.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: setup-environment
2+
description: Composite action to setup environment and install dependencies
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: 🤹‍♂️ Install asdf
8+
uses: asdf-vm/actions/setup@v2
9+
10+
- name: 🗂️ Cache asdf
11+
id: cache-asdf
12+
uses: actions/cache@v3
13+
env:
14+
cache-name: cache-asdf
15+
with:
16+
path: ~/.asdf
17+
key: ${{ runner.os }}-se-${{ env.cache-name }}-${{ hashFiles('**/.tool-versions') }}
18+
restore-keys: |
19+
${{ runner.os }}-se-${{ env.cache-name }}-
20+
21+
- name: 🛠️ Install tools from .tool-versions
22+
if: ${{ steps.cache-asdf.outputs.cache-hit != 'true' }}
23+
continue-on-error: true
24+
uses: asdf-vm/actions/install@v2
25+
26+
- name: 🗂️ Cache npm dependencies
27+
id: cache-npm
28+
uses: actions/cache@v3
29+
env:
30+
cache-name: cache-npm
31+
with:
32+
path: ~/.npm
33+
key: ${{ runner.os }}-se-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
34+
restore-keys: |
35+
${{ runner.os }}-se-${{ env.cache-name }}-
36+
37+
- name: 📥 Install dependencies
38+
shell: bash
39+
run: npm ci
40+
41+
- name: 💎 Generate Prisma models
42+
shell: bash
43+
run: npm run prisma:generate

Diff for: .github/workflows/cd.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: CD
33
on:
44
push:
55
tags:
6-
- 'v*'
6+
- v*
77

88
permissions:
99
contents: write

Diff for: .github/workflows/ci.yml

+6-24
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,8 @@ jobs:
1919
- name: ⬇️ Checkout project
2020
uses: actions/checkout@v4
2121

22-
- name: 🛠️ Setup asdf tools
23-
uses: ./.github/actions/setup-asdf-tools
24-
25-
- name: 📥 Install dependencies
26-
run: npm ci
27-
28-
- name: 💎 Generate Prisma models
29-
run: npm run prisma:generate
22+
- name: 🧙‍♂️ Setup environment
23+
uses: ./.github/actions/setup-environment
3024

3125
- name: 🖍️ Check types
3226
run: npm run check:types
@@ -55,14 +49,8 @@ jobs:
5549
- name: ⬇️ Checkout project
5650
uses: actions/checkout@v4
5751

58-
- name: 🛠️ Setup asdf tools
59-
uses: ./.github/actions/setup-asdf-tools
60-
61-
- name: 📥 Install dependencies
62-
run: npm ci
63-
64-
- name: 💎 Generate Prisma models
65-
run: npm run prisma:generate
52+
- name: 🧙‍♂️ Setup environment
53+
uses: ./.github/actions/setup-environment
6654

6755
- name: 🧪 Run tests
6856
run: npm run test:coverage
@@ -76,14 +64,8 @@ jobs:
7664
- name: ⬇️ Checkout project
7765
uses: actions/checkout@v4
7866

79-
- name: 🛠️ Setup asdf tools
80-
uses: ./.github/actions/setup-asdf-tools
81-
82-
- name: 📥 Install dependencies
83-
run: npm ci
84-
85-
- name: 💎 Generate Prisma models
86-
run: npm run prisma:generate
67+
- name: 🧙‍♂️ Setup environment
68+
uses: ./.github/actions/setup-environment
8769

8870
- name: ⚒️ Build project
8971
run: npm run build

Diff for: package-lock.json

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"reset-hard": "git clean -dfx && git reset --hard && npm install",
6060
"prepare-release": "run-s reset-hard version",
6161
"update-deps": "npm-check-updates -u",
62-
"prepare": "husky install"
62+
"prepare": "cross-env is-ci || husky install"
6363
},
6464
"dependencies": {
6565
"@ngneat/falso": "^7.1.1",
@@ -175,6 +175,7 @@
175175
"http-server": "^14.1.1",
176176
"husky": "^8.0.3",
177177
"ioredis-mock": "^8.9.0",
178+
"is-ci": "^3.0.1",
178179
"jest": "^29.7.0",
179180
"jest-extended": "^4.0.2",
180181
"jest-mock-extended": "^3.0.5",

0 commit comments

Comments
 (0)