-
-
Notifications
You must be signed in to change notification settings - Fork 19
81 lines (72 loc) · 2.1 KB
/
test-pr.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
name: 🎯 Test PR
# cancel previous runs on the same PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
types: [opened, synchronize, reopened]
env:
CI: true
NODE_VERSION: 16
defaults:
run:
shell: bash
jobs:
build:
name: 🏗 Build Project
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
affected-packages: ${{ steps.get-affected-packages-paths.outputs.affected-packages }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0
- name: Install node_modules
uses: ./.github/actions/install-node-modules
- name: Package
uses: ./.github/actions/package
- name: Get affected packages paths
id: get-affected-packages-paths
uses: ./.github/actions/get-affected-packages-paths
with:
base-branch: ${{ github.base_ref }}
library-lint-and-tests:
name: 🎯 Run Tests
needs: build
runs-on: ubuntu-latest
if: join(fromJson(needs.build.outputs.affected-packages)) != ''
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
AFFECTED_LIB: ${{ fromJson(needs.build.outputs.affected-packages) }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Run tests
uses: ./.github/actions/lint-and-tests
with:
path: ${{ matrix.AFFECTED_LIB }}
validate-pr:
name: ✅ Validate the PR
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build, library-lint-and-tests]
steps:
- name: Validate build
run: |
if [[ ${{ needs.build.result }} = "failure" ]]; then
echo "build failed"
exit 1
fi
- name: Validate tests
run: |
if [[ ${{ needs.library-lint-and-tests.result }} = "failure" ]]; then
echo "tests failed"
exit 1
fi