-
Notifications
You must be signed in to change notification settings - Fork 133
137 lines (121 loc) · 5.35 KB
/
on-pull-request.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
133
134
135
136
137
name: PR checks
on:
pull_request:
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: true
NX_CLOUD_DISTRIBUTED_EXECUTION_AGENT_COUNT: 8
NX_BRANCH: ${{ github.event.number || github.ref_name }}
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_AUTH_TOKEN }}
NX_CLOUD_AUTH_TOKEN: ${{ secrets.NX_CLOUD_AUTH_TOKEN }}
FIREBASE_SERVICE_ACCOUNT_TOKEN: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_TOKEN }}
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
jobs:
nx_agents:
name: Nx Cloud Agent ${{ matrix.agent }}
runs-on: ubuntu-latest
strategy:
matrix:
agent: [1, 2, 3, 4, 5, 6, 7, 8]
steps:
- uses: actions/checkout@v4.2.2
- uses: ./.github/actions/nodejs
- name: set up xvfb
run: |
export DISPLAY=:99
sudo Xvfb -ac :99 -screen 0 1920x1080x24 > /dev/null 2>&1 &
- name: Start Nx Cloud Agent
run: npx nx-cloud start-agent
env:
NX_AGENT_NAME: ${{matrix.agent}}
build_test:
runs-on: ubuntu-latest
name: Run affected Build, Lint and test commands
defaults:
run:
working-directory: ${{ github.workspace }}
shell: bash
steps:
- uses: actions/checkout@v4.2.2
name: Checkout
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- uses: nrwl/nx-set-shas@v4.1.2
name: Derive appropriate SHAs for base and head for nx-affected commands
with:
main-branch-name: main
- uses: ./.github/actions/nodejs
- name: Initialize the Nx Cloud distributed CI run
run: npx nx-cloud start-ci-run
- name: Format Check
run: npx nx format:check --base=origin/${{ github.event.pull_request.base.ref }} --head=HEAD
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: false
- uses: wagoid/commitlint-github-action@v6.1.2
name: Commit lint
- name: Run Build, Lint and test commands
uses: ./.github/actions/parallel-commands
with:
parallel-commands: |
npx nx affected --target=build --base=origin/${{ github.event.pull_request.base.ref }} --head=HEAD --exclude=docs --parallel=3
npx nx run-many --target=test --all --skip-nx-cache --base=origin/${{ github.event.pull_request.base.ref }} --head=HEAD --exclude=nx-plugin --parallel=3
npx nx affected --target=lint --base=origin/${{ github.event.pull_request.base.ref }} --head=HEAD --exclude=core,platform,cx,btp --parallel=3
- name: Text workspace tags
run: npx nx run nx-plugin:test --skip-nx-cache
e2e_test:
runs-on: ubuntu-latest
name: Run affected e2e commands
defaults:
run:
working-directory: ${{ github.workspace }}
shell: bash
steps:
- uses: actions/checkout@v4.2.2
name: Checkout
with:
fetch-depth: 0
- uses: ./.github/actions/nodejs
- run: npx nx run docs:compile:production --skip-nx-cache
- uses: browser-actions/setup-chrome@latest
with:
chrome-version: stable
- run: |
export DISPLAY=:99
chrome --version
sudo Xvfb -ac :99 -screen 0 1920x1080x24 > /dev/null 2>&1 & # optional
env:
NX_CLOUD_DISTRIBUTED_EXECUTION: false
- uses: FirebaseExtended/action-hosting-deploy@v0
continue-on-error: true
id: firebase_hosting_preview
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ env.FIREBASE_SERVICE_ACCOUNT_TOKEN }}'
projectId: fundamental-ngx-gh
target: fundamental-ngx-gh
expires: 3d
- name: Test affected on firebase
if: ${{ steps.firebase_hosting_preview.outputs.details_url }}
run: |
npx nx run-many --target=e2e --all --skip-nx-cache --base=origin/main --head=HEAD --parallel=2 --runInBand --baseUrl=${{ steps.firebase_hosting_preview.outputs.details_url }} --devServerTarget=""
- name: Stopping agents # They're no longer needed, so we can stop them to avoid them going on timeout
if: ${{ !steps.firebase_hosting_preview.outputs.details_url }}
run: npx nx-cloud stop-all-agents
- name: Test affected on local
if: ${{ !steps.firebase_hosting_preview.outputs.details_url }}
run: |
NX_CLOUD_DISTRIBUTED_EXECUTION=false npx nx run docs:e2e-app --skip-nx-cache
stop_agents:
if: ${{ always() }}
needs:
- build_test
- e2e_test
name: Nx Cloud - Stop Agents
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: ./.github/actions/nodejs
- name: Stop all running agents for this CI run
run: npx nx-cloud stop-all-agents