1
+ name : PR
2
+
3
+ # Run on all pull requests
4
+ on : [ pull_request ]
5
+
6
+ env :
7
+ NX_BRANCH : ${{ github.event.number }}
8
+ NX_RUN_GROUP : ${{ github.run_id }}
9
+
10
+ jobs :
11
+
12
+ prepare-env :
13
+ runs-on : ubuntu-latest
14
+ outputs :
15
+ GITHUB_HEAD_REF : ${{ steps.GITHUB_HEAD_REF.outputs.value }}
16
+ GITHUB_BASE_REF : ${{ steps.GITHUB_BASE_REF.outputs.value }}
17
+ steps :
18
+ - uses : nrwl/last-successful-commit-action@v1
19
+ id : last_successful_commit
20
+ with :
21
+ branch : ' master'
22
+ workflow_id : ' release.yml'
23
+ github_token : ${{ secrets.GITHUB_TOKEN }}
24
+
25
+ - id : GITHUB_HEAD_REF
26
+ run : echo "::set-output name=value::$(echo ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}})"
27
+
28
+ - id : GITHUB_BASE_REF
29
+ run : echo "::set-output name=value::$(echo ${{ steps.last_successful_commit.outputs.commit_hash }}})"
30
+
31
+ build :
32
+ needs : [ prepare-env ]
33
+ runs-on : ubuntu-latest
34
+ strategy :
35
+ matrix :
36
+ node-version : [ 14.x ]
37
+ steps :
38
+ - uses : actions/checkout@v2
39
+ with :
40
+ fetch-depth : 0
41
+
42
+ - name : Cache node modules
43
+ id : cache
44
+ uses : actions/cache@v2
45
+ with :
46
+ path : |
47
+ **/node_modules
48
+ key : ${{ env.DEPENDENCIES_CACHE }}-${{ hashFiles('yarn.lock') }}
49
+
50
+ - name : Cache Nx
51
+ uses : actions/cache@v2
52
+ with :
53
+ path : node_modules/.cache/nx
54
+ key : ${{ env.NX_CACHE }}-${{ hashFiles('yarn.lock') }}-${{ matrix.target }}-${{ matrix.index }}-${{ github.sha }}
55
+ restore-keys : |
56
+ ${{ env.NX_CACHE }}-${{ hashFiles('yarn.lock') }}-${{ matrix.target }}-${{ matrix.index }}-
57
+ ${{ env.NX_CACHE }}-${{ hashFiles('yarn.lock') }}-
58
+ ${{ env.NX_CACHE }}-
59
+
60
+ - name : Use Node.js ${{ matrix.node-version }}
61
+ uses : actions/setup-node@v2
62
+ with :
63
+ node-version : ${{ matrix.node-version }}
64
+
65
+ - name : yarn install
66
+ if : steps.cache.outputs.cache-hit != 'true'
67
+ run : yarn install
68
+
69
+ - name : GIT config
70
+ run : |
71
+ git config user.name "${GITHUB_ACTOR}"
72
+ git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
73
+
74
+ - name : nx affected:version
75
+ run : node ./tools/scripts/run-many.js version origin/${{ needs.prepare-env.outputs.GITHUB_HEAD_REF }} ${{ needs.prepare-env.outputs.GITHUB_BASE_REF }}
76
+
77
+ - name : nx affected:build
78
+ run : node ./tools/scripts/run-many.js build origin/${{ needs.prepare-env.outputs.GITHUB_HEAD_REF }} ${{ needs.prepare-env.outputs.GITHUB_BASE_REF }}
79
+
80
+ unit-test :
81
+ needs : [ prepare-env ]
82
+ runs-on : ubuntu-latest
83
+ strategy :
84
+ matrix :
85
+ node-version : [ 14.x ]
86
+ steps :
87
+ - uses : actions/checkout@v2
88
+ with :
89
+ fetch-depth : 0
90
+
91
+ - name : Cache node modules
92
+ id : cache
93
+ uses : actions/cache@v2
94
+ with :
95
+ path : |
96
+ **/node_modules
97
+ key : ${{ env.DEPENDENCIES_CACHE }}-${{ hashFiles('yarn.lock') }}
98
+
99
+ - name : Cache Nx
100
+ uses : actions/cache@v2
101
+ with :
102
+ path : node_modules/.cache/nx
103
+ key : ${{ env.NX_CACHE }}-${{ hashFiles('yarn.lock') }}-${{ matrix.target }}-${{ matrix.index }}-${{ github.sha }}
104
+ restore-keys : |
105
+ ${{ env.NX_CACHE }}-${{ hashFiles('yarn.lock') }}-${{ matrix.target }}-${{ matrix.index }}-
106
+ ${{ env.NX_CACHE }}-${{ hashFiles('yarn.lock') }}-
107
+ ${{ env.NX_CACHE }}-
108
+
109
+ - name : Use Node.js ${{ matrix.node-version }}
110
+ uses : actions/setup-node@v2
111
+ with :
112
+ node-version : ${{ matrix.node-version }}
113
+
114
+ - name : yarn install
115
+ if : steps.cache.outputs.cache-hit != 'true'
116
+ run : yarn install
117
+
118
+ - name : nx affected:test
119
+ run : node ./tools/scripts/run-many.js test origin/${{ needs.prepare-env.outputs.GITHUB_HEAD_REF }} ${{ needs.prepare-env.outputs.GITHUB_BASE_REF }}
120
+
121
+ e2e-test :
122
+ needs : [ prepare-env ]
123
+ runs-on : ubuntu-latest
124
+ strategy :
125
+ matrix :
126
+ node-version : [ 14.x ]
127
+ db-type : ['postgres', 'mysql']
128
+ steps :
129
+ - uses : actions/checkout@v2
130
+ with :
131
+ fetch-depth : 0
132
+
133
+ - name : Cache node modules
134
+ id : cache
135
+ uses : actions/cache@v2
136
+ with :
137
+ path : |
138
+ **/node_modules
139
+ key : ${{ env.DEPENDENCIES_CACHE }}-${{ hashFiles('yarn.lock') }}
140
+
141
+ - name : Cache Nx
142
+ uses : actions/cache@v2
143
+ with :
144
+ path : node_modules/.cache/nx
145
+ key : ${{ env.NX_CACHE }}-${{ hashFiles('yarn.lock') }}-${{ matrix.target }}-${{ matrix.index }}-${{ github.sha }}
146
+ restore-keys : |
147
+ ${{ env.NX_CACHE }}-${{ hashFiles('yarn.lock') }}-${{ matrix.target }}-${{ matrix.index }}-
148
+ ${{ env.NX_CACHE }}-${{ hashFiles('yarn.lock') }}-
149
+ ${{ env.NX_CACHE }}-
150
+
151
+ - name : Use Node.js ${{ matrix.node-version }}
152
+ uses : actions/setup-node@v2
153
+ with :
154
+ node-version : ${{ matrix.node-version }}
155
+
156
+ - name : yarn install
157
+ if : steps.cache.outputs.cache-hit != 'true'
158
+ run : yarn install
159
+
160
+ - name : nx affected:e2e
161
+ run : node ./tools/scripts/run-many.js e2e origin/${{ needs.prepare-env.outputs.GITHUB_HEAD_REF }} ${{ needs.prepare-env.outputs.GITHUB_BASE_REF }}
162
+ env :
163
+ NESTJS_QUERY_DB_TYPE : ${{ matrix.db-type }}
0 commit comments