forked from rx-angular/rx-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (112 loc) · 4.19 KB
/
build-and-test.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
name: CI
on:
push:
branches: [main]
pull_request:
concurrency:
# Group concurrency on workflow, then:
# - Is merge run? Group on branch name (`refs/heads/main`)
# - Is pull request? Group on pull request branch name, for example `feat/add-awesome-feature`
group: >-
${{ github.workflow }}-${{
github.event_name == 'push'
&& github.ref
|| github.head_ref
}}
# Run merge workflows in sequence to prevent parallel deployments and releases
# Cancel stale pull request runs in progress for the same branch
cancel-in-progress: ${{ github.event_name != 'push' }}
env:
NODE_OPTIONS: --max-old-space-size=6144
docs-name: docs
docs-path: dist/apps/docs
NX_BRANCH: ${{ github.event.number || github.ref_name }}
permissions:
actions: read
contents: read
jobs:
main:
name: Main CI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout [Pull Request]
if: ${{ github.event_name == 'pull_request' }}
with:
# By default, PRs will be checked-out based on the Merge Commit, but we want the actual branch HEAD.
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
- uses: actions/checkout@v4
name: Checkout [Default Branch]
if: ${{ github.event_name != 'pull_request' }}
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v4
- name: Initialize the Nx Cloud distributed CI run
run: npx nx-cloud start-ci-run --distribute-on="./nx/workflows/dynamic-changesets.yml" --stop-agents-after="e2e" --require-explicit-completion
- name: Set up dependencies
uses: ./.github/actions/setup
- name: Run commands in parallel
run: |
npx nx-cloud record -- npx nx format:check
npx nx affected -t lint build test component-test e2e --parallel=4 --exclude=docs
npx nx-cloud complete-ci-run
# Upload coverage reports to Codecov
- name: Upload coverage
if: steps.test.outcome == 'success'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/state/lcov.info, coverage/template/lcov.info, coverage/cdk/lcov.info, coverage/isr/lcov.info, coverage/eslint-plugin/lcov.info
flags: state, template, cdk, isr, eslint-plugin
# The docs project is built in a separate job because it requires Node.js 16
build-docs:
name: Build docs
runs-on: ubuntu-latest
steps:
- name: Checkout all commits
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up dependencies
uses: ./.github/actions/setup
- name: Build docs
run: yarn nx build docs
- name: '[Merge] Upload docs'
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v4
with:
name: ${{ env.docs-name }}
path: ${{ env.docs-path }}
deploy-docs:
name: '[Merge] Deploy docs'
runs-on: ubuntu-latest
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
if: github.ref == 'refs/heads/main'
# Deploy to the github-pages environment
environment:
name: github-pages
url: www.rx-angular.io
#url: ${{ steps.deployment.outputs.page_url }}
needs: [build-docs]
steps:
- name: Download docs
uses: actions/download-artifact@v4
with:
name: ${{ env.docs-name }}
path: ${{ env.docs-path }}
- name: Set up GitHub Pages
uses: actions/configure-pages@v4
- name: Upload docs to GitHub Pages
uses: actions/upload-pages-artifact@v1
with:
path: ${{ env.docs-path }}
- name: Deploy docs to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1