-
Notifications
You must be signed in to change notification settings - Fork 1
132 lines (113 loc) · 3.46 KB
/
ci.yml
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
132
name: CI
# This event is triggered on pushes & PRs to all branches
on:
pull_request:
push:
branches:
- '*'
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
prepare:
name: Preparing pipeline
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Cloning repository
- name: Get npm cache directory
id: npm-cache-dir
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Get npm cache
uses: actions/cache@v4
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/setup-node@v4
name: Setting Node.js Version
with:
node-version-file: .nvmrc
- name: Install dependencies
run: npm ci
continue-on-error: false
tests:
needs: prepare
strategy:
matrix:
# Creates jobs for each element in the matrix
test: ['unit', 'lint', 'typecheck', 'coverage']
# Let individual jobs in the matrix fail without canceling all jobs
fail-fast: false
name: ${{ matrix.test }} tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Cloning repository
- name: Get npm cache directory
id: npm-cache-dir
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Get npm cache
uses: actions/cache@v4
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/setup-node@v4
name: Setting Node.js Version
with:
node-version-file: .nvmrc
- name: Install dependencies
run: npm ci
continue-on-error: false
- name: Running ${{ matrix.test }} tests
run: npm run test:${{ matrix.test }}
continue-on-error: false
dispatch-string:
needs: tests
name: Dispatch using stringified payload
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Cloning repository
- uses: ./
name: Dispatch Event
id: dispatch_action
with:
eventType: 'test_dispatch'
token: ${{ secrets.REPO_PAT }}
payload: '{"requested_by": "${{github.actor}}"}'
dispatch-path:
needs: tests
name: Dispatch using file path payload
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Cloning repository
- uses: ./
name: Dispatch Event
id: dispatch_action
with:
eventType: 'test_dispatch'
token: ${{ secrets.REPO_PAT }}
payloadType: path
payloadPath: test/files/valid.json
dispatch-url:
needs: tests
name: Dispatch using file URL payload
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Cloning repository
- uses: ./
name: Dispatch Event
id: dispatch_action
with:
eventType: 'test_dispatch'
token: ${{ secrets.REPO_PAT }}
payloadType: url
payloadUrl: https://raw.githubusercontent.com/iniva/action-repository-dispatch/main/test/files/valid.json