Skip to content

Commit

Permalink
build: add angular 17 support (#2079)
Browse files Browse the repository at this point in the history
* build: add angular 17 support

- extend allowed range of ng peer dependency to 18
- add an additional integration test for NG17 with updated dependencies and tests.
- add additional test in all places the other tests run

fixes #2078

* Update index.html to correct version number in the title

* chore: regenerate yarn.lock

* build: angular v17 support in websocket-plugin

* chore: run CI on node 18

---------

Co-authored-by: Dmitriy Stepanenko <[email protected]>
  • Loading branch information
jpraetorius and dmitry-stepanenko authored Nov 23, 2023
1 parent 22a8ab1 commit 744e67c
Show file tree
Hide file tree
Showing 44 changed files with 10,026 additions and 1,475 deletions.
16 changes: 16 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,22 @@ jobs:
paths:
- app/integrations/hello-world-ng16/dist-integration

integration_ng17_tests:
<<: *job_defaults
steps:
- *attach_workspace
# https://github.com/CircleCI-Public/browser-tools-orb/issues/75
- browser-tools/install-browser-tools:
chrome-version: '116.0.5845.96'
replace-existing-chrome: true
- run:
name: Run integration tests for ng17 application
command: yarn integration:ng17
- persist_to_workspace:
root: ~/workspace
paths:
- app/integrations/hello-world-ng17/dist-integration

integration_test_types:
<<: *job_defaults
steps:
Expand Down
1 change: 1 addition & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ runs:
./@ngxs
./integrations/hello-world-ng15/dist-integration
./integrations/hello-world-ng16/dist-integration
./integrations/hello-world-ng17/dist-integration
key: ${{ runner.os }}-node-${{ inputs.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}-branch-${{ inputs.github-ref-name }}-sha-${{ inputs.github-sha }}
restore-keys: |
${{ runner.os }}-node-${{ inputs.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}-branch-${{ inputs.github-ref-name }}-sha-
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
pull_request:

env:
NODE_VERSION: 16.x
NODE_VERSION: 18.x
BASE_REF: ${{ format('remotes/origin/{0}', github.base_ref) }}

defaults:
Expand Down Expand Up @@ -85,6 +85,7 @@ jobs:
script:
- 'integration:ng15'
- 'integration:ng16'
- 'integration:ng17'
- 'test:types'

steps:
Expand Down
2 changes: 1 addition & 1 deletion integrations/hello-world-ng15/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"test:ci": "ng test --no-watch --no-progress --browsers=ChromeHeadlessCI --source-map=false",
"test:integration": "yarn install:ivy && yarn test:ci && yarn build:prod && yarn e2e:ci",
"preinstall": "yarn --cwd ../../ cpx -v -C \"@ngxs/**/*\" integrations/hello-world-ng15/node_modules/@ngxs",
"install:ivy": "yarn --frozen-lockfile --non-interactive --no-progress",
"postinstall": "ngcc",
"install:ivy": "yarn --frozen-lockfile --non-interactive --no-progress",
"cy:open": "cypress open",
"cy:run": "cypress run",
"cy:run:ssr": "cypress run --spec=cypress/integration-ssr/*.ts",
Expand Down
42 changes: 42 additions & 0 deletions integrations/hello-world-ng17/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

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

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

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

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

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

# System files
.DS_Store
Thumbs.db
96 changes: 96 additions & 0 deletions integrations/hello-world-ng17/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"hello-world-ng17": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist-integration",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.scss"],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "hello-world-ng17:build:production"
},
"development": {
"browserTarget": "hello-world-ng17:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "hello-world-ng17:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": ["zone.js", "zone.js/testing"],
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"inlineStyleLanguage": "scss",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.scss"],
"scripts": []
}
}
}
}
}
}
17 changes: 17 additions & 0 deletions integrations/hello-world-ng17/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { defineConfig } from 'cypress';

export default defineConfig({
video: false,
responseTimeout: 60000,
pageLoadTimeout: 120000,
e2e: {
supportFile: false,
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config);
},
baseUrl: 'http://localhost:4200',
excludeSpecPattern: ['**/plugins/**.js', '**/tsconfig.json']
}
});
15 changes: 15 additions & 0 deletions integrations/hello-world-ng17/cypress/e2e/index-page.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe('Index page', () => {
beforeEach(() => cy.visit('/'));

it('should render application using the latest version', () => {
// Arrange & act & assert
// Expect that the running applicaiton was compiled
// with the necessary Angular version!
cy.get('app-root').invoke('attr', 'ng-version').should('have.string', '17');
});

it('should click on the button and increase the counter', () => {
// Arrange & act & assert
cy.get('button').click().click().click().get('p').should('contain.text', 'Counter is 3');
});
});
5 changes: 5 additions & 0 deletions integrations/hello-world-ng17/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
17 changes: 17 additions & 0 deletions integrations/hello-world-ng17/cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
};
11 changes: 11 additions & 0 deletions integrations/hello-world-ng17/cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"sourceMap": false,
"declaration": false,
"moduleResolution": "node",
"types": ["node", "cypress"],
"typeRoots": ["../node_modules/@types"],
"lib": ["es2017", "dom"]
},
"include": ["e2e/*.ts", "support/*.ts", "../node_modules/cypress"]
}
47 changes: 47 additions & 0 deletions integrations/hello-world-ng17/karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = config => {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage/ng17'),
subdir: '.',
reporters: [{ type: 'html' }, { type: 'text-summary' }]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
customLaunchers: {
ChromeHeadlessCI: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
restartOnFileChange: true
});
};
61 changes: 61 additions & 0 deletions integrations/hello-world-ng17/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"name": "hello-world-ng17",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start-test": "start-server-and-test",
"start": "ng serve",
"build": "ng build",
"build:prod": "ng build --configuration production",
"test": "ng test",
"test:ci": "ng test --no-watch --no-progress --browsers=ChromeHeadlessCI --source-map=false",
"test:integration": "yarn install:ci && yarn test:ci && yarn build:prod && yarn e2e:ci",
"preinstall": "yarn --cwd ../../ cpx -v -C \"@ngxs/**/*\" integrations/hello-world-ng17/node_modules/@ngxs",
"install:ci": "yarn --frozen-lockfile --non-interactive --no-progress",
"cy:open": "cypress open",
"cy:run": "cypress run",
"cy:run:ssr": "cypress run --spec=cypress/integration-ssr/*.ts",
"serve:integration:static": "serve dist-integration -s -l 4200 --cors",
"e2e": "start-test serve:integration:static 4200 cy:open",
"e2e:ci": "start-test serve:integration:static 4200 cy:run"
},
"private": true,
"dependencies": {
"@angular/animations": "17.0.0",
"@angular/common": "17.0.0",
"@angular/compiler": "17.0.0",
"@angular/core": "17.0.0",
"@angular/forms": "17.0.0",
"@angular/platform-browser": "17.0.0",
"@angular/platform-browser-dynamic": "17.0.0",
"@angular/platform-server": "17.0.0",
"@angular/router": "17.0.0",
"@ngxs/devtools-plugin": "file:./node_modules/@ngxs/devtools-plugin",
"@ngxs/form-plugin": "file:./node_modules/@ngxs/form-plugin",
"@ngxs/logger-plugin": "file:./node_modules/@ngxs/logger-plugin",
"@ngxs/router-plugin": "file:./node_modules/@ngxs/router-plugin",
"@ngxs/storage-plugin": "file:./node_modules/@ngxs/storage-plugin",
"@ngxs/store": "file:./node_modules/@ngxs/store",
"@ngxs/websocket-plugin": "file:./node_modules/@ngxs/websocket-plugin",
"rxjs": "~7.8.1",
"tslib": "^2.6.2",
"zone.js": "~0.14.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "17.0.0",
"@angular/cli": "17.0.0",
"@angular/compiler-cli": "17.0.0",
"@types/jasmine": "~4.3.0",
"@types/node": "20.1.4",
"cypress": "file:../../node_modules/cypress",
"jasmine-core": "~4.5.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"serve": "file:../../node_modules/serve",
"start-server-and-test": "file:../../node_modules/start-server-and-test",
"typescript": "~5.2.2"
}
}
4 changes: 4 additions & 0 deletions integrations/hello-world-ng17/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<h1>Angular 17 Integration Test</h1>

<button (click)="increment()">Increment</button>
<p>Counter is {{ counter$ | async }}</p>
Loading

0 comments on commit 744e67c

Please sign in to comment.