forked from StephenMP/ts-ioredis-pool
-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (109 loc) · 2.96 KB
/
CI.yaml
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
name: CI
on:
workflow_dispatch:
push:
branches:
- main
- release
pull_request:
branches:
- '*'
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
yarn-cache-dir: ${{ steps.set-outputs.outputs.yarn_cache_dir }}
steps:
# Checkout source files
- name: Checkout Source Files
uses: actions/checkout@v2
# Setup environment
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14
- name: Set Outputs
id: set-outputs
run: |
echo "::set-output name=yarn_cache_dir::$(yarn cache dir)"
- name: Read Yarn/Node Cache
uses: actions/cache@v2
id: read-yarn-cache
with:
key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
path: |
${{ steps.set-outputs.outputs.yarn_cache_dir }}
**/node_modules
- name: Read Build Cache
id: read-build-cache
uses: actions/cache@v2
with:
key: ${{ runner.os }}-build-${{ github.sha }}
path: |
**/dist
- name: Install Dependencies
if: steps.read-yarn-cache.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: Build
if: steps.read-build-cache.outputs.cache-hit != 'true'
run: yarn build
test:
name: Test
runs-on: ubuntu-latest
needs: [build]
strategy:
matrix:
node-version: [14.x, 16.x]
redis-version: [4, 5, 6]
env:
REDIS_URL: redis://:@localhost:6379
REDIS_HOST: localhost
REDIS_PORT: 6379
REDIS_PASS: ""
REDIS_TLS: false
steps:
# Checkout source files
- name: Checkout Source Files
uses: actions/checkout@v2
# Setup environment
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Start Redis
uses: supercharge/[email protected]
with:
redis-version: ${{ matrix.redis-version }}
# Read caches
- name: Read Yarn/Node Cache
uses: actions/cache@v2
id: read-yarn-cache
with:
key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
path: |
${{ needs.build.outputs.yarn-cache-dir }}
**/node_modules
- name: Read Build Cache
id: read-build-cache
uses: actions/cache@v2
with:
key: ${{ runner.os }}-build-${{ github.sha }}
path: |
**/dist
- name: Test
run: |
yarn link
yarn test
publish-packages:
name: Publish Packages
runs-on: ubuntu-latest
needs: [build, test]
if: github.ref == 'refs/heads/release'
steps:
- name: Publish Packages
uses: benc-uk/workflow-dispatch@v1
with:
ref: refs/heads/release
workflow: Publish Package
token: ${{ secrets.GH_BOT_TOKEN }}