Skip to content

Commit

Permalink
Merge pull request #90 from duluca/cypress-updates
Browse files Browse the repository at this point in the history
update ci, rename stages, and cleanup
  • Loading branch information
duluca committed Aug 28, 2023
2 parents ea4c821 + ab1a5cc commit f23aacf
Show file tree
Hide file tree
Showing 972 changed files with 2,974 additions and 2,535 deletions.
5 changes: 2 additions & 3 deletions .circleci/config.docker-integration.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: 2.1
orbs:
aws-cli: circleci/aws-cli@1.0.0
aws-cli: circleci/aws-cli@4
jobs:
build:
docker:
- image: circleci/node:lts
- image: cimg/node:lts
working_directory: ~/repo
steps:
- checkout
Expand Down Expand Up @@ -63,7 +63,6 @@ jobs:
command: npm run aws:deploy

workflows:
version: 2
build-and-deploy:
jobs:
- build
Expand Down
14 changes: 5 additions & 9 deletions .circleci/config.ch9.yml → .circleci/config.stage9.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
version: 2.1
orbs:
coveralls: coveralls/coveralls@1.0.4
coveralls: coveralls/coveralls@2.2.1
jobs:
build:
docker:
- image: circleci/node:lts-browsers
- image: cimg/node:lts-browsers
working_directory: ~/repo
steps:
- checkout
Expand All @@ -16,9 +16,6 @@ jobs:

- run: npm ci

# force update the webdriver, so it runs with latest version of Chrome
- run: cd ./node_modules/protractor && npm i webdriver-manager@latest

# because we use "npm ci" to install NPM dependencies
# we cache "~/.npm" folder
- save_cache:
Expand All @@ -30,7 +27,6 @@ jobs:
- run: npm run lint
- run: npm run build:prod
- run: npm test -- --watch=false --code-coverage
- run: npm run e2e

- store_test_results:
path: ./test_results
Expand Down Expand Up @@ -60,14 +56,13 @@ jobs:
- dist/lemon-mart
deploy:
docker:
- image: circleci/node:lts
- image: cimg/node:lts
working_directory: ~/repo
steps:
- attach_workspace:
at: /tmp/workspace
- run: npx vercel --token $VERCEL_TOKEN --platform-version 2 --prod /tmp/workspace/dist/lemon-mart --confirm
- run: npx vercel deploy --token $VERCEL_TOKEN --prod /tmp/workspace/dist/lemon-mart --yes
workflows:
version: 2
build-test-and-approval-deploy:
jobs:
- build
Expand All @@ -79,5 +74,6 @@ workflows:
branches:
only: main
- deploy:
context: vercel
requires:
- hold
78 changes: 38 additions & 40 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2.1
orbs:
coveralls: coveralls/coveralls@2.2.1
browser-tools: circleci/browser-tools@1.4.3
cypress: cypress-io/cypress@3.1.3
cypress: cypress-io/cypress@3
commands:
install:
description: 'Install project dependencies'
Expand All @@ -19,15 +19,10 @@ commands:
condition: << parameters.warm-cache >>
steps:
- run: npm ci
# Pre-build Angular modules
- run: npx ngcc --properties es2015
# force update the webdriver, so it runs with latest version of Chrome
# - run: cd ./node_modules/protractor && npm i webdriver-manager@latest
- save_cache:
key: node_modules-{{ checksum "package-lock.json" }}
paths:
- node_modules
- ~/.cache/Cypress
lint:
description: 'Check for code style and linting errors'
steps:
Expand All @@ -43,27 +38,23 @@ commands:
type: boolean
default: true
steps:
- browser-tools/install-chrome
- browser-tools/install-chromedriver
- run: npx ng build --configuration production --project << parameters.project >>
- when:
condition: << parameters.run-tests >>
steps:
# - run: cd ./node_modules/protractor && npm i webdriver-manager@latest
# --code-coverage
- run: npx ng test --watch=false --project << parameters.project >>
- attach_workspace:
at: ~/
- browser-tools/install-chrome
- browser-tools/install-chromedriver
- run: npx ng test --watch=false --project << parameters.project >> --code-coverage
# - run: npx ng run << parameters.project >>:cypress-run
store:
description: 'Stores build_and_test artifacts'
parameters:
project:
type: string
default: 'lemon-mart'
steps:
- run:
command: npx cypress run
# install-browsers: true
# start-command: npm start

- store_test_results:
path: ./test_results
- store_artifacts:
Expand All @@ -72,7 +63,8 @@ commands:
# upload coverage report to coveralls for readme badge support
# requires config.yml version 2.1 and orbs: coveralls: coveralls/coveralls@1.0.4
# requires coveralls account and token named COVERALLS_REPO_TOKEN specific to repo to be stored in CircleCI
# - coveralls/upload
- coveralls/upload
# https://docs.cypress.io/guides/tooling/code-coverage

- run:
name: Tar & Gzip compiled app
Expand All @@ -99,7 +91,7 @@ commands:
steps:
- attach_workspace:
at: /tmp/workspace
- run: npx vercel --token $VERCEL_TOKEN --platform-version 2 --prod /tmp/workspace/dist/<< parameters.project >> --confirm
- run: npx vercel deploy --token $VERCEL_TOKEN --prod /tmp/workspace/dist/<< parameters.project >> --yes
jobs:
initialize:
docker:
Expand All @@ -108,6 +100,11 @@ jobs:
steps:
- install:
warm-cache: true
- cypress/install
- persist_to_workspace:
root: ~/
paths:
- .cache/Cypress
default:
docker:
- image: cimg/node:lts-browsers
Expand All @@ -116,7 +113,7 @@ jobs:
- install
- lint
- build_and_test
- cypress/install
- run: npx ng run lemon-mart:cypress-run
- store
deploy:
docker:
Expand All @@ -125,62 +122,62 @@ jobs:
steps:
- deploy_vercel

ch7: # this job is only here to verify sample code from the book, remove it in your own projects
stage7: # this job is only here to verify sample code from the book, remove it in your own projects
docker:
- image: cimg/node:lts-browsers
working_directory: ~/repo
steps:
- install
- build_and_test:
project: 'ch7'
ch8: # this job is only here to verify sample code from the book, remove it in your own projects
project: 'stage7'
stage8: # this job is only here to verify sample code from the book, remove it in your own projects
docker:
- image: cimg/node:lts-browsers
working_directory: ~/repo
steps:
- install
- build_and_test:
project: 'ch8'
ch10: # this job is only here to verify sample code from the book, remove it in your own projects
project: 'stage8'
stage10: # this job is only here to verify sample code from the book, remove it in your own projects
docker:
- image: cimg/node:lts-browsers
working_directory: ~/repo
steps:
- install
- build_and_test:
project: 'ch10'
ch11: # this job is only here to verify sample code from the book, remove it in your own projects
project: 'stage10'
stage11: # this job is only here to verify sample code from the book, remove it in your own projects
docker:
- image: cimg/node:lts-browsers
working_directory: ~/repo
steps:
- install
- build_and_test:
project: 'ch11'
ch12: # this job is only here to verify sample code from the book, remove it in your own projects
project: 'stage11'
stage12: # this job is only here to verify sample code from the book, remove it in your own projects
docker:
- image: cimg/node:lts-browsers
working_directory: ~/repo
steps:
- install
- build_and_test:
project: 'ch12'
ch13: # this job is only here to verify sample code from the book, remove it in your own projects
project: 'stage12'
stage13: # this job is only here to verify sample code from the book, remove it in your own projects
docker:
- image: cimg/node:lts-browsers
working_directory: ~/repo
steps:
- install
- build_and_test:
project: 'ch13'
ch14: # this job is only here to verify sample code from the book, remove it in your own projects
project: 'stage13'
stage14: # this job is only here to verify sample code from the book, remove it in your own projects
docker:
- image: cimg/node:lts-browsers
working_directory: ~/repo
steps:
- install
- build_and_test:
project: 'ch14'
project: 'stage14'

workflows:
build-test-and-approval-deploy:
Expand All @@ -189,28 +186,29 @@ workflows:
- default:
requires:
- initialize
- ch7: # this job is only here to verify sample code from the book, remove it in your own projects
- stage7: # this job is only here to verify sample code from the book, remove it in your own projects
requires:
- initialize
- ch8: # this job is only here to verify sample code from the book, remove it in your own projects
- stage8: # this job is only here to verify sample code from the book, remove it in your own projects
requires:
- initialize
- ch10: # this job is only here to verify sample code from the book, remove it in your own projects
- stage10: # this job is only here to verify sample code from the book, remove it in your own projects
requires:
- initialize
- ch11: # this job is only here to verify sample code from the book, remove it in your own projects
- stage11: # this job is only here to verify sample code from the book, remove it in your own projects
requires:
- initialize
- ch12: # this job is only here to verify sample code from the book, remove it in your own projects
- stage12: # this job is only here to verify sample code from the book, remove it in your own projects
requires:
- initialize
- ch13: # this job is only here to verify sample code from the book, remove it in your own projects
- stage13: # this job is only here to verify sample code from the book, remove it in your own projects
requires:
- initialize
- ch14: # this job is only here to verify sample code from the book, remove it in your own projects
- stage14: # this job is only here to verify sample code from the book, remove it in your own projects
requires:
- initialize
- deploy:
context: vercel
requires:
- default
filters:
Expand Down
28 changes: 14 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# dependencies
# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
/.idea
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
# Miscellaneous
/.angular/cache
/.sass-cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
testem.log
/typings

# e2e
/e2e/src/*.js
/e2e/src/*.map

# System Files
# System files
.DS_Store
Thumbs.db
.env

/tests
.env
cache
.firebase
*.tar**
cypress/videos
cypress/screenshots
coverage
test_results
8 changes: 0 additions & 8 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@
"webRoot": "${workspaceRoot}",
"sourceMaps": true,
"preLaunchTask": "npm: test"
},
{
"name": "npm run e2e",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/protractor/bin/protractor",
"protocol": "inspector",
"args": ["${workspaceRoot}/protractor.conf.js"]
}
]
}
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ If you'd like to use this project as a starter or a template project for your pr
- Run `npm start` for a developmenet web server.
- Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
- Run `npm test` to execute the unit tests via [Karma](https://karma-runner.github.io).
- Run `npm run e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
- Run `npm run e2e` to execute the end-to-end tests via [Cypress](https://cypress.io).

### Code scaffolding

Expand All @@ -141,12 +141,14 @@ See the example project here https://github.com/duluca/lemon-mart-server

# Changes

Changes are inevitable to keep the project up-to-date with libraries, tools, patterns and practices. Below are some notable changes that differ from the 1st and 2nd edition of my book.
Changes are inevitable to keep the project up-to-date with libraries, tools, patterns and practices. Below are some notable changes that differ from the 1st, 2nd, and 3rd edition of my book.

## Angular 16 (planned)
## Angular 16

- Plan to replace jasmine and karma with Jest
- Plan to move to standalone configuration and using @ngrx/component-store
- Renamed `projects` from `ch2` format to `stage2`, so they make sense in the 3rd edition.
- Replaced tslint with eslint
- Replaced protractor with cypress for e2e, added tests
- Moved to Standalone configuration

## Angular 13-15

Expand Down
Loading

0 comments on commit f23aacf

Please sign in to comment.