Skip to content

Commit

Permalink
refactor: add function deploy actions
Browse files Browse the repository at this point in the history
  • Loading branch information
BioPhoton authored Aug 3, 2023
2 parents 591f12e + b5c844b commit 77a97da
Show file tree
Hide file tree
Showing 41 changed files with 487 additions and 361 deletions.
8 changes: 6 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"ignorePatterns": [
"**/*"
],
"overrides": [
{
"files": ["*.ts"],
"files": [
"*.ts"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.*?.json"
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: CI - build,test affected projects on Pr+Merge
'on':
on:
pull_request:
push:
branches:
- main

jobs:
ci:
runs-on: ubuntu-latest
Expand All @@ -30,5 +29,12 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Run Nx Affected
run: npx nx affected --targets=lint,build,test,prerender --exclude cloudflare-worker
# TODO: have different dist locations to run in parallel
- name: Run Nx Affected lint,test
run: npx nx affected --targets=lint,test
- name: Run Nx Affected build
run: npx nx affected --targets=build --exclude docs
- name: Run build docs
run: npx nx build docs
- name: Run Nx Affected prerende
run: npx nx affected --targets=prerende
2 changes: 1 addition & 1 deletion .github/workflows/cloudflare-hosting-pr.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: E2E Cloudflare Pages Preview Channel on PR
'on': pull_request
on: pull_request
jobs:
build_and_cloudflare_preview:
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/docs-hosting-m.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Deploy to GitHub README.md on Merge
'on':
on:
push:
branches:
- main

jobs:
update_docs:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
name: E2E Firebase Live Hosting on Merge
'on':
name: Deploy Firebase Function|Hosting on Merge
on:
push:
branches:
- main

jobs:
deploy_firebase_function_and_hosting:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
# needed for all cases
- if: github.event_name == 'push' && github.ref_name == 'main'
uses: actions/checkout@v3
# needed for nx affected command
- if: github.event_name == 'pull_request'
uses: actions/checkout@v3
with:
fetch-depth: 0
# needed for nx affected command
- if: github.event_name == 'pull_request'
run: git fetch --no-tags --depth=1 origin $BASE_BRANCH

- name: Setup Node.js
uses: actions/setup-node@v3
Expand All @@ -20,28 +28,23 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Production build (client + prerender + server)
run: npm run nx run firebase-function:build:production

- name: Deploy firebase live hosting
- name: Deploy firebase function|hosting
id: deployStep
# We can not use the firebase github action as it throws because of "channelID requires"
# Notes: in package.json there is a hack (`|| true`) in the prepare script to make it pass (`"prepare": "husky install || true"`).
# Since we don't upload the node_modules. The real reason dough is we don't put a custom `package.json` in the dist folder.
# We can not use the firebase GitHub action as it throws because of "channelID requires"
run: |
npm run nx run firebase-function:deploy
npm run nx affected -- --targets=deploy-firebase --no-parallel
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

- name: Run user flow against firebase live hosting
run: npm run nx run movies:user-flow:production -- --format=md --url=https://angular-movies-a12d3.web.app

- name: Collect user flows
id: firebase-live-hosting
id: test-firebase-function--deploy-live
uses: push-based/[email protected]
with:
verbose: on
commentId: firebase-live-hosting
commentId: test-firebase-function--deploy-live
onlyComments: on
outPath: ./dist/user-flow/movies
rcPath: ./projects/movies/.user-flowrc.json
4 changes: 2 additions & 2 deletions .github/workflows/firebase-function-pr.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: E2E Firebase Function on PR
'on': pull_request
on: pull_request
jobs:
emulate_firebase_function_and_test:
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
Expand Down Expand Up @@ -28,7 +28,7 @@ jobs:
uses: push-based/[email protected]
with:
verbose: on
commentId: firebase-function-emulation
commentId: test-firebase-function--deploy-emulation
onlyComments: on
outPath: ./dist/user-flow/firebase-function
rcPath: projects/firebase-function/.user-flowrc.json
4 changes: 2 additions & 2 deletions .github/workflows/firebase-hosting-pr.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: E2E Firebase Preview Channel Hosting on PR
'on': pull_request
on: pull_request
jobs:
build_and_firebase_preview:
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
Expand All @@ -18,7 +18,7 @@ jobs:
run: npm ci

- name: Production build for static file hosting (client + prerender)
run: npm run nx prerender ng-universal-express
run: npm run nx build movies

- name: Deploy firebase preview channel hosting
id: previewDeployStep
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ng-universal-pr.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: E2E NG Universal Express on PR
'on': pull_request
on: pull_request
jobs:
build_and_ng-universal-express:
if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}'
Expand Down
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,32 @@ For now you can search the codebase for "Perf Tip" later on there will be proppe

### Bundle Stats

<!-- bundle-stats-start -->

| Names | Size |
|-------------------------------------------------------------------------------------|---------------|
| main.js | 341.11 KB |
| styles.css | 6.21 KB |
| runtime.js | 2.65 KB |
| **Initial Total** | **349.96 KB** |
| Names | Size |
| app_pages_movie-detail-page_movie-detail-page_component_ts.js | 16.91 KB |
| app_pages_person-detail-page_person-detail-page_component_ts.js | 11.86 KB |
| a-6a8199.js | 10.16 KB |
| app_pages_account-feature_list-detail-page_list-movies_list-movies_compon-d13d08.js | 9.91 KB |
| common.js | 7.62 KB |
| app_pages_account-feature_list-detail-page_list-items-edit_list-items-edi-13eb42.js | 7.24 KB |
| app_pages_movie-list-page_movie-list-page_component_ts.js | 5.9 KB |
| app_pages_account-feature_list-create-page_list-create-page_component_ts--1f481e.js | 5.8 KB |
| app_app-shell_account-menu_account-menu_component_ts.js | 5.7 KB |
| app_pages_account-feature_account-list-page_account-list-page_component_ts.js | 4.97 KB |
| app_pages_account-feature_list-detail-page_list-image_list-image_componen-cb4b89.js | 4.42 KB |
| default-node_modules_rx-angular_template_fesm2022_template-if_mjs.js | 4.31 KB |
| app_pages_account-feature_list-detail-page_list-remove_list-remove_compon-a10eb2.js | 3.53 KB |
| app_pages_account-feature_list-detail-page_list-detail-page_component_ts--a2c81d.js | 3.35 KB |
| app_pages_not-found-page_not-found-page_component_ts.js | 1.86 KB |
| app_pages_account-feature_list-detail-page_list-detail-page_routes_ts.js | 1.66 KB |
| app_pages_account-feature_account-feature-page_routes_ts.js | 1.01 KB |
<!-- bundle-stats-start -->
| Names | Size |
|-------------------------------------------------------------------------------------|-------------|
| main.js | 2.5 MB |
| runtime.js | 12 KB |
| styles.css | 8.54 KB |
| **Initial Total** | **2.52 MB** |
| Names | Size |
| app_pages_movie-detail-page_movie-detail-page_component_ts.js | 58.67 KB |
| app_pages_person-detail-page_person-detail-page_component_ts.js | 45.81 KB |
| common.js | 37.43 KB |
| a-4d8953.js | 36.55 KB |
| default-node_modules_rx-angular_template_fesm2022_template-if_mjs.js | 28.2 KB |
| app_pages_account-feature_list-detail-page_list-items-edit_list-items-edi-13eb42.js | 26.27 KB |
| app_pages_movie-list-page_movie-list-page_component_ts.js | 24.04 KB |
| app_pages_account-feature_list-create-page_list-create-page_component_ts--1f481e.js | 21.58 KB |
| app_pages_account-feature_account-list-page_account-list-page_component_ts.js | 20.36 KB |
| app_app-shell_account-menu_account-menu_component_ts.js | 20.2 KB |
| app_pages_account-feature_list-detail-page_list-image_list-image_componen-cb4b89.js | 16.83 KB |
| app_pages_account-feature_list-detail-page_list-detail-page_component_ts--a2c81d.js | 14.71 KB |
| app_pages_account-feature_list-detail-page_list-remove_list-remove_compon-a10eb2.js | 11.1 KB |
| app_pages_not-found-page_not-found-page_component_ts.js | 6.95 KB |
| app_pages_account-feature_list-detail-page_list-detail-page_routes_ts.js | 3.4 KB |
| app_pages_account-feature_account-feature-page_routes_ts.js | 2.65 KB |
| app_pages_account-feature_list-detail-page_list-movies_list-movies_component_ts.js | 2.55 KB |
<!-- bundle-stats-end -->

## Comparison to next and nuxt
Expand Down
31 changes: 31 additions & 0 deletions firebase.function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"emulators": {
"functions": {
"port": 4402
}
},
"functions": {
"source": ".",
"ignore": [
" **/.*",
"**/node_modules/**",
"**/tmp/**",
"**/tooling/**",
"**/LICENSE",
"**/CONTRIBUTING.md",
"**/README.md",
"**/commitlint.config.js",
"**/database.rules.json",
"**/firebase-debug.log",
"**/firebase.function.json",
"**/firebase.json",
"**/jest.config.ts",
"**/jest.preset.js",
"**/migrations.json",
"**/nx.json",
"**/tsconfig.json",
"**/ui-debug.log",
"**/wrangler.toml"
]
}
}
68 changes: 40 additions & 28 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,53 @@
"emulators": {
"hosting": {
"port": 4202
},
"functions": {
"port": 4402
}
},
"functions": {
"source": ".",
"ignore": [
"./cf-tools",
"./docs",
"./projects",
"./tooling",
"./*.{js,ts,md,log,jpg,toml,yaml}",
"./nx.json",
"./tsconfig.json",
"./firebase.json",
"**/.*",
"**/node_modules/**"
]
},
"hosting": {
"public": "./dist/projects/movies/browser",
"cleanUrls": true,
"trailingSlash": false,
"ignore": [
"./cf-tools",
"./docs",
"./projects",
"./tooling",
"./*.{js,ts,md,log,jpg,toml,yaml}",
"./nx.json",
"./tsconfig.json",
"./firebase.json",
"**/.*",
"**/node_modules/**"
" **/.*",
"**/node_modules/**",
"**/tmp/**",
"**/.DS_Store/**",
"**/.angular/**",
"**/.firebase/**",
"**/.git/**",
"**/.github/**",
"**/.husky/**",
"**/.idea/**",
"**/.local-config/**",
"**/.stylelintrc/**",
"**/.vscode/**",
"**/tooling/**",
"**/.wrangler/**",
"**/.gitignore",
"**/.eslintrc.json",
"**/.editorconfig",
"**/.lint-staged.config.js",
"**/.lintstagedrc.json",
"**/.prettierignore",
"**/.prettierrc.json",
"**/.size-limit.js",
"**/LICENSE",
"**/CONTRIBUTING.md",
"**/README.md",
"**/commitlint.config.js",
"**/database.rules.json",
"**/firebase-debug.log",
"**/firebase.function.json",
"**/firebase.json",
"**/jest.config.ts",
"**/jest.preset.js",
"**/migrations.json",
"**/nx.json",
"**/tsconfig.json",
"**/ui-debug.log",
"**/wrangler.toml",
"**/package.json",
"**/package-lock.json"
],
"headers": [
{
Expand Down
2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"default": {
"runner": "nx-cloud",
"options": {
"cacheableOperations": [],
"cacheableOperations": ["build"],
"accessToken": "OTI0YWJiN2ItNTI2MC00M2RmLTlmM2EtOWRiODZkYmVjZTAyfHJlYWQtd3JpdGU="
}
}
Expand Down
Loading

0 comments on commit 77a97da

Please sign in to comment.