From 989d2db77304e738feb86fe3d72e43288e84500a Mon Sep 17 00:00:00 2001 From: Marcelo Shima Date: Wed, 5 Jun 2024 21:41:26 -0300 Subject: [PATCH] use generate-sample at ios workflow --- .blueprint/generate-sample/generator.mjs | 2 +- .../templates/samples/21points-jwt.jdl | 18 ++- .../templates/samples/app-jwt.jdl | 86 ++++++------ .../templates/samples/app-oauth2.jdl | 86 ++++++------ .../templates/samples/app-websocket.jdl | 88 ++++++------ .../templates/samples/flickr2-jwt.jdl | 17 ++- .../github-build-matrix/build-matrix.mjs | 11 +- .blueprint/github-build-matrix/generator.mjs | 2 +- .github/workflows/ios.yml | 126 +++++++----------- 9 files changed, 224 insertions(+), 212 deletions(-) diff --git a/.blueprint/generate-sample/generator.mjs b/.blueprint/generate-sample/generator.mjs index a0019cc77..befd85ab0 100644 --- a/.blueprint/generate-sample/generator.mjs +++ b/.blueprint/generate-sample/generator.mjs @@ -35,7 +35,7 @@ export default class extends BaseGenerator { get [BaseGenerator.LOADING]() { return this.asLoadingTaskGroup({ async loadCommand() { - await this.loadCurrentJHipsterCommandConfig(undefined); + await this.loadCurrentJHipsterCommandConfig(this); }, }); } diff --git a/.blueprint/generate-sample/templates/samples/21points-jwt.jdl b/.blueprint/generate-sample/templates/samples/21points-jwt.jdl index e6f2a933c..2c9b428af 100644 --- a/.blueprint/generate-sample/templates/samples/21points-jwt.jdl +++ b/.blueprint/generate-sample/templates/samples/21points-jwt.jdl @@ -3,23 +3,28 @@ */ application { - config { - authenticationType jwt - skipClient true - devDatabaseType h2Disk - } - entities * + config { + authenticationType jwt + skipClient true + devDatabaseType h2Disk + creationTimestamp 1617901618886 + jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" + } + entities * } +@ChangelogDate(20240101000000) entity BloodPressure { timestamp ZonedDateTime required systolic Integer required diastolic Integer required } +@ChangelogDate(20240102000000) entity Weight { timestamp ZonedDateTime required weight Double required } +@ChangelogDate(20240103000000) entity Points { date LocalDate required exercise Integer @@ -27,6 +32,7 @@ entity Points { alcohol Integer notes String maxlength(140) } +@ChangelogDate(20240105000000) entity Preferences { weeklyGoal Integer required min(10) max(21) weightUnits Units required diff --git a/.blueprint/generate-sample/templates/samples/app-jwt.jdl b/.blueprint/generate-sample/templates/samples/app-jwt.jdl index a32f8b341..bb24cb1f3 100644 --- a/.blueprint/generate-sample/templates/samples/app-jwt.jdl +++ b/.blueprint/generate-sample/templates/samples/app-jwt.jdl @@ -1,59 +1,69 @@ application { - config { - authenticationType jwt - skipClient true - devDatabaseType h2Disk - } - entities * + config { + authenticationType jwt + creationTimestamp 1617901618886 + jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" + skipClient true + devDatabaseType h2Disk + } + entities * } +@ChangelogDate(20240101000000) entity Region { - regionName String + regionName String } +@ChangelogDate(20240102000000) entity Country { - countryName String + countryName String } +@ChangelogDate(20240103000000) entity Location { - streetAddress String - postalCode String - city String - stateProvince String + streetAddress String + postalCode String + city String + stateProvince String } +@ChangelogDate(20240104000000) entity Department { - departmentName String required - departmentPic ImageBlob - departmentDescription TextBlob - departmentInfoPdf Blob + departmentName String required + departmentPic ImageBlob + departmentDescription TextBlob + departmentInfoPdf Blob } +@ChangelogDate(20240105000000) entity Task { - title String - description String + title String + description String } +@ChangelogDate(20240106000000) entity Employee { - firstName String - lastName String - email String - phoneNumber String - hireDate Instant - salary Long - commissionPct Long + firstName String + lastName String + email String + phoneNumber String + hireDate Instant + salary Long + commissionPct Long } +@ChangelogDate(20240107000000) entity Job { - jobTitle String - minSalary Long - maxSalary Long + jobTitle String + minSalary Long + maxSalary Long } +@ChangelogDate(20240108000000) entity JobHistory { - startDate Instant - endDate Instant - language Language + startDate Instant + endDate Instant + language Language } enum Language { @@ -61,13 +71,13 @@ enum Language { } relationship ManyToMany { - Job{task(title)} to Task{job(jobTitle)} + Job{task(title)} to Task{job(jobTitle)} } relationship OneToMany { - Employee{job(jobTitle)} to Job{employee(email)} - Department{employee(email)} to - Employee{department(departmentName)} + Employee{job(jobTitle)} to Job{employee(email)} + Department{employee(email)} to + Employee{department(departmentName)} } relationship ManyToOne { @@ -78,9 +88,9 @@ relationship ManyToOne { } relationship OneToOne { - JobHistory{job} to Job - JobHistory{department} to Department - JobHistory{employee} to Employee + JobHistory{job} to Job + JobHistory{department} to Department + JobHistory{employee} to Employee } paginate JobHistory, Employee with infinite-scroll diff --git a/.blueprint/generate-sample/templates/samples/app-oauth2.jdl b/.blueprint/generate-sample/templates/samples/app-oauth2.jdl index 66c50e69e..5910edce2 100644 --- a/.blueprint/generate-sample/templates/samples/app-oauth2.jdl +++ b/.blueprint/generate-sample/templates/samples/app-oauth2.jdl @@ -1,59 +1,69 @@ application { - config { - authenticationType oauth2 - skipClient true - devDatabaseType h2Disk - } - entities * + config { + authenticationType oauth2 + skipClient true + devDatabaseType h2Disk + creationTimestamp 1617901618886 + jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" + } + entities * } +@ChangelogDate(20240101000000) entity Region { - regionName String + regionName String } +@ChangelogDate(20240102000000) entity Country { - countryName String + countryName String } +@ChangelogDate(20240103000000) entity Location { - streetAddress String - postalCode String - city String - stateProvince String + streetAddress String + postalCode String + city String + stateProvince String } +@ChangelogDate(20240104000000) entity Department { - departmentName String required - departmentPic ImageBlob - departmentDescription TextBlob - departmentInfoPdf Blob + departmentName String required + departmentPic ImageBlob + departmentDescription TextBlob + departmentInfoPdf Blob } +@ChangelogDate(20240105000000) entity Task { - title String - description String + title String + description String } +@ChangelogDate(20240106000000) entity Employee { - firstName String - lastName String - email String - phoneNumber String - hireDate Instant - salary Long - commissionPct Long + firstName String + lastName String + email String + phoneNumber String + hireDate Instant + salary Long + commissionPct Long } +@ChangelogDate(20240107000000) entity Job { - jobTitle String - minSalary Long - maxSalary Long + jobTitle String + minSalary Long + maxSalary Long } +@ChangelogDate(20240108000000) entity JobHistory { - startDate Instant - endDate Instant - language Language + startDate Instant + endDate Instant + language Language } enum Language { @@ -61,13 +71,13 @@ enum Language { } relationship ManyToMany { - Job{task(title)} to Task{job(jobTitle)} + Job{task(title)} to Task{job(jobTitle)} } relationship OneToMany { - Employee{job(jobTitle)} to Job{employee(email)} - Department{employee(email)} to - Employee{department(departmentName)} + Employee{job(jobTitle)} to Job{employee(email)} + Department{employee(email)} to + Employee{department(departmentName)} } relationship ManyToOne { @@ -78,9 +88,9 @@ relationship ManyToOne { } relationship OneToOne { - JobHistory{job} to Job - JobHistory{department} to Department - JobHistory{employee} to Employee + JobHistory{job} to Job + JobHistory{department} to Department + JobHistory{employee} to Employee } paginate JobHistory, Employee with infinite-scroll diff --git a/.blueprint/generate-sample/templates/samples/app-websocket.jdl b/.blueprint/generate-sample/templates/samples/app-websocket.jdl index d935b4a72..878c1feed 100644 --- a/.blueprint/generate-sample/templates/samples/app-websocket.jdl +++ b/.blueprint/generate-sample/templates/samples/app-websocket.jdl @@ -1,60 +1,70 @@ application { - config { - authenticationType jwt - websocket spring-websocket - skipClient true - devDatabaseType h2Disk - } - entities * + config { + authenticationType jwt + websocket spring-websocket + skipClient true + devDatabaseType h2Disk + creationTimestamp 1617901618886 + jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" + } + entities * } +@ChangelogDate(20240101000000) entity Region { - regionName String + regionName String } +@ChangelogDate(20240102000000) entity Country { - countryName String + countryName String } +@ChangelogDate(20240103000000) entity Location { - streetAddress String - postalCode String - city String - stateProvince String + streetAddress String + postalCode String + city String + stateProvince String } +@ChangelogDate(20240104000000) entity Department { - departmentName String required - departmentPic ImageBlob - departmentDescription TextBlob - departmentInfoPdf Blob + departmentName String required + departmentPic ImageBlob + departmentDescription TextBlob + departmentInfoPdf Blob } +@ChangelogDate(20240105000000) entity Task { - title String - description String + title String + description String } +@ChangelogDate(20240106000000) entity Employee { - firstName String - lastName String - email String - phoneNumber String - hireDate Instant - salary Long - commissionPct Long + firstName String + lastName String + email String + phoneNumber String + hireDate Instant + salary Long + commissionPct Long } +@ChangelogDate(20240107000000) entity Job { - jobTitle String - minSalary Long - maxSalary Long + jobTitle String + minSalary Long + maxSalary Long } +@ChangelogDate(20240108000000) entity JobHistory { - startDate Instant - endDate Instant - language Language + startDate Instant + endDate Instant + language Language } enum Language { @@ -62,13 +72,13 @@ enum Language { } relationship ManyToMany { - Job{task(title)} to Task{job(jobTitle)} + Job{task(title)} to Task{job(jobTitle)} } relationship OneToMany { - Employee{job(jobTitle)} to Job{employee(email)} - Department{employee(email)} to - Employee{department(departmentName)} + Employee{job(jobTitle)} to Job{employee(email)} + Department{employee(email)} to + Employee{department(departmentName)} } relationship ManyToOne { @@ -79,9 +89,9 @@ relationship ManyToOne { } relationship OneToOne { - JobHistory{job} to Job - JobHistory{department} to Department - JobHistory{employee} to Employee + JobHistory{job} to Job + JobHistory{department} to Department + JobHistory{employee} to Employee } paginate JobHistory, Employee with infinite-scroll diff --git a/.blueprint/generate-sample/templates/samples/flickr2-jwt.jdl b/.blueprint/generate-sample/templates/samples/flickr2-jwt.jdl index fdae58449..13dc1d124 100644 --- a/.blueprint/generate-sample/templates/samples/flickr2-jwt.jdl +++ b/.blueprint/generate-sample/templates/samples/flickr2-jwt.jdl @@ -3,20 +3,24 @@ */ application { - config { - authenticationType jwt - skipClient true - devDatabaseType h2Disk - } - entities * + config { + authenticationType jwt + skipClient true + devDatabaseType h2Disk + creationTimestamp 1617901618886 + jwtSecretKey "ZjY4MTM4YjI5YzMwZjhjYjI2OTNkNTRjMWQ5Y2Q0Y2YwOWNmZTE2NzRmYzU3NTMwM2NjOTE3MTllOTM3MWRkMzcyYTljMjVmNmQ0Y2MxOTUzODc0MDhhMTlkMDIxMzI2YzQzZDM2ZDE3MmQ3NjVkODk3OTVmYzljYTQyZDNmMTQ=" + } + entities * } +@ChangelogDate(20240101000000) entity Album { title String required description TextBlob created Instant } +@ChangelogDate(20240102000000) entity Photo { title String required description TextBlob @@ -27,6 +31,7 @@ entity Photo { uploaded Instant } +@ChangelogDate(20240103000000) entity Tag { name String required minlength(2) } diff --git a/.blueprint/github-build-matrix/build-matrix.mjs b/.blueprint/github-build-matrix/build-matrix.mjs index a4fac05d3..a12338704 100644 --- a/.blueprint/github-build-matrix/build-matrix.mjs +++ b/.blueprint/github-build-matrix/build-matrix.mjs @@ -3,20 +3,25 @@ import { RECOMMENDED_JAVA_VERSION, RECOMMENDED_NODE_VERSION } from 'generator-jh import { fromMatrix } from 'generator-jhipster/testing'; const defaultMatrix = { - os: ['macos-13'], + os: ['macos-14'], 'node-version': [RECOMMENDED_NODE_VERSION], 'java-version': [RECOMMENDED_JAVA_VERSION], 'default-environment': ['dev'], }; +const oauth2Sample = { + os: 'macos-14', + 'default-environment': 'prod', +}; + export const buildMatrix = async samplesFolder => { const samples = await readdir(samplesFolder); return { include: Object.values( fromMatrix({ - ...defaultMatrix, + ...(samplesFolder === 'oauth2' ? oauth2Matrix : defaultMatrix), 'sample-name': samples.filter(sample => !sample.includes('disabled')), }), - ), + ).map(sample => (sample['sample-name'].includes('oauth2') ? { ...sample, ...oauth2Sample } : sample)), }; }; diff --git a/.blueprint/github-build-matrix/generator.mjs b/.blueprint/github-build-matrix/generator.mjs index d36967455..06f3523fe 100644 --- a/.blueprint/github-build-matrix/generator.mjs +++ b/.blueprint/github-build-matrix/generator.mjs @@ -21,7 +21,7 @@ export default class extends BaseGenerator { get [BaseGenerator.LOADING]() { return this.asLoadingTaskGroup({ async loadCommand() { - await this.loadCurrentJHipsterCommandConfig(undefined); + await this.loadCurrentJHipsterCommandConfig(this); }, }); } diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index aa92efe2a..60c5a875f 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -1,15 +1,5 @@ name: iOS-E2E on: - workflow_dispatch: - inputs: - recordVideo: - description: 'Record failing E2E Tests' - required: false - default: 'false' - screenshots: - description: 'Screenshot failing E2E Tests' - required: false - default: 'false' push: branches: - 'main' @@ -31,61 +21,39 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20.x + node-version: 20 - name: check-dependencies run: | cd generators/react-native/resources/expo npm run check-dependencies - applications: - name: e2e-${{ matrix.app_type }}-${{ matrix.jhipster_version }} - runs-on: macos-14 + + build-matrix: + runs-on: ubuntu-latest needs: [check-dependencies] + outputs: + matrix: ${{ steps.build.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + - id: build + run: | + npm ci --ignore-scripts --omit=dev + cli/cli.cjs github-build-matrix + + applications: + name: ${{ matrix.sample-name }} + runs-on: ${{ matrix.os }} + needs: build-matrix timeout-minutes: 90 defaults: run: working-directory: ${{ github.workspace }}/client strategy: fail-fast: false - matrix: - jhipster_version: [8] - node_version: [20.x] - app_type: - - JwtDtoApp - - JwtWebsocketsApp - - JwtHealthPointsApp - - JwtFlickrApp - - OauthApp - include: - - app_type: JwtDtoApp - auth_type: jwt - dto: true - - app_type: JwtWebsocketsApp - auth_type: jwt - dto: false - websockets: true - - app_type: JwtHealthPointsApp - auth_type: jwt - dto: false - entity_jdl: entities-21points.jdl - - app_type: JwtFlickrApp - auth_type: jwt - dto: false - entity_jdl: entities-flickr2.jdl - - app_type: OauthApp - auth_type: oauth2 - backend: 'false' - dto: false + matrix: ${{fromJson(needs.build-matrix.outputs.matrix)}} env: - JHI_REACT_NATIVE_APP_NAME: ${{ matrix.app_type }} - JHI_AUTH_TYPE: ${{ matrix.auth_type }} - JHI_DTO: ${{ matrix.dto }} - JHI_WEBSOCKETS: ${{ matrix.websockets }} - JHI_ENTITY_JDL: ${{ matrix.entity_jdl }} - JHIPSTER_VERSION: ${{ matrix.jhipster_version }} - SCRIPT_DIR: ${{ github.workspace }}/generator-jhipster-react-native/test/scripts - PLATFORM: ios - JHI_RECORD_VIDEO: ${{ github.event.inputs.recordVideo || 'false' }} - JHI_SCREENSHOTS: ${{ github.event.inputs.screenshots || 'false' }} FORCE_COLOR: true steps: - uses: jhipster/actions/create-app-path@v0 @@ -96,50 +64,47 @@ jobs: path: backend - uses: jhipster/actions/setup-runner@v0 with: - node-version: 20 - java-version: 17 + node-version: ${{ matrix.node-version }} + java-version: ${{ matrix.java-version }} maven-cache: true binary-dir: ${{ github.workspace }}/generator-jhipster-react-native/cli - uses: actions/checkout@v4 with: path: generator-jhipster-react-native fetch-depth: 2 - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: latest - uses: nick-invision/retry@v3.0.0 - name: 'TOOLS: installing Detox and its dependencies' + name: 'TOOLS: installing applesimutils' with: max_attempts: 3 timeout_minutes: 60 - command: $SCRIPT_DIR/install-detox.sh + command: brew tap wix/brew && brew install applesimutils && applesimutils --list retry_wait_seconds: 15 - - run: $SCRIPT_DIR/display-tools.sh - name: 'TOOLS: display tools' - - run: npm i - name: 'TOOLS: npm install in generator-jhipster-react-native' - working-directory: ${{ github.workspace }}/generator-jhipster-react-native - - run: $SCRIPT_DIR/copy-jdl-file.sh - name: 'SETUP: copy the JDL file for the backend and app' + - run: npm install working-directory: ${{ github.workspace }}/generator-jhipster-react-native - - run: cli.cjs jdl ../${JHI_REACT_NATIVE_APP_NAME}.jdl --force --skip-checks --skip-commit-hook --no-insight --skip-install --disable-blueprints - name: 'GENERATING: generate jhipster backend' + - run: cli.cjs generate-sample ${{ matrix.sample-name }} --force --skip-commit-hook working-directory: ${{ github.workspace }}/backend - - run: cli.cjs --force --skip-install - name: 'GENERATING: generate react-native app' - uses: jhipster/actions/compare-sample@v0 - continue-on-error: true + id: compare-backend + if: >- + github.event.pull_request && + contains(github.event.pull_request.labels.*.name, 'pr: compare-backend') + with: + application-base-path: ${{ github.workspace }}/backend-base + application-folder: backend + compare-folder: backend + generator-path: generator-jhipster-react-native + cmd: cli.cjs generate-sample ${{ matrix.sample-name }} --force --skip-git --skip-commit-hook + - uses: jhipster/actions/compare-sample@v0 id: compare if: >- github.event.pull_request && - !contains(github.event.pull_request.labels.*.name, 'pr: disable-compare') + !contains(github.event.pull_request.labels.*.name, 'pr: disable-compare') && + steps.compare-backend.outputs.has-changes != 'true' with: + application-folder: backend + compare-folder: client generator-path: generator-jhipster-react-native - application-base-path: ${{ github.workspace }}/client-base - current-application-base-path: ${{ github.workspace }}/client - application-folder: . - compare-folder: . - cmd: cli.cjs --force --skip-install + cmd: cli.cjs generate-sample ${{ matrix.sample-name }} --force --skip-git --skip-commit-hook - run: npm install if: steps.compare.outputs.equals != 'true' - run: npx expo prebuild -p ios @@ -150,19 +115,20 @@ jobs: npm run app:start & npm install -g wait-on wait-on -t 60000 http-get://127.0.0.1:8080/management/health - if: steps.compare.outputs.equals != 'true' && matrix.backend != 'false' + if: matrix.default-environment != 'prod' && steps.compare.outputs.equals != 'true' working-directory: ${{ github.workspace }}/backend - run: npm run e2e:test:ios if: steps.compare.outputs.equals != 'true' - uses: actions/upload-artifact@v4 if: steps.compare.outputs.equals != 'true' && always() with: - name: expo-app-${{ matrix.app_type }}-${{ matrix.jhipster_version }} + name: expo-app-${{ matrix.sample-name }} path: | ${{ github.workspace }}/client/ !${{ github.workspace }}/**/android !${{ github.workspace }}/**/ios !${{ github.workspace }}/**/node_modules + ios-result: permissions: contents: none