diff --git a/.github/workflows/bump-version-save.yml b/.github/actions/bump-version-save.yml similarity index 100% rename from .github/workflows/bump-version-save.yml rename to .github/actions/bump-version-save.yml diff --git a/.github/actions/publish.yml b/.github/actions/publish.yml new file mode 100644 index 00000000..799f7030 --- /dev/null +++ b/.github/actions/publish.yml @@ -0,0 +1,49 @@ +name: Publish + +on: +# workflow_run: +# workflows: [ "Create Releases" ] +# types: +# - completed + workflow_dispatch: +env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} + NPM_CONFIG_PROVENANCE: true + +jobs: + publish: + #if: ${{ github.event.workflow_run.conclusion == 'success' }} + name: Publish + runs-on: ubuntu-latest + permissions: + contents: "read" + actions: "read" + id-token: "write" # needed for provenance data generation + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Npm install + uses: ./.github/actions + - name: Restore cached .nx + id: cache-nx-restore + uses: actions/cache/restore@v4 + with: + path: | + .nx + key: ${{ runner.os }}-nx-master + - run: npx nx affected -t build --parallel=3 --exclude='json-api-front,json-api-server,json-api-server-e2e,shared-utils,json-shared-type,microorm-database,typeorm-database,type-for-rpc' + - name: Publish packages + run: npx nx release publish + shell: bash + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_CONFIG_PROVENANCE: true + - name: Save cached .nx + id: cache-dependencies-save + uses: actions/cache/save@v4 + with: + path: | + .nx + key: ${{ steps.cache-nx-restore.outputs.cache-primary-key }} diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index ddf27740..b428a1b2 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -18,7 +18,7 @@ on: type: boolean default: false secrets: - NODE_AUTH_TOKEN: + NPM_TOKEN: required: true GITHUB_TOKEN_SECRET: required: true @@ -26,24 +26,35 @@ on: required: true env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN_SECRET }} NPM_CONFIG_PROVENANCE: true jobs: bump-version: runs-on: ubuntu-latest + permissions: + contents: "write" + actions: "read" + id-token: "write" steps: + - name: Settings git + run: | + git config --global user.email "actions@github.com" + git config --global user.name "GitHub Actions" - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - token: ${{ secrets.PAT }} + persist-credentials: true - name: Npm install uses: ./.github/actions - name: Bump version run: | - git config --global user.email "actions@github.com" - git config --global user.name "GitHub Actions" - npx nx release --skip-publish --projects=${{ inputs.projects }} --dry-run=${{ inputs.dry-run }} + if [ "${{ inputs.beta-release }}" = "true" ]; then + npx nx release --skip-publish --projects=${{ inputs.projects }} --dry-run=${{ inputs.dry-run }} --preid=beta + else + npx nx release --skip-publish --projects=${{ inputs.projects }} --dry-run=${{ inputs.dry-run }} + fi shell: bash + diff --git a/.github/workflows/compute-projects.yml b/.github/workflows/compute-projects.yml index eb740adb..0496fd79 100644 --- a/.github/workflows/compute-projects.yml +++ b/.github/workflows/compute-projects.yml @@ -31,11 +31,13 @@ on: outputs: finalProjects: description: "Result Project" - value: ${{ steps.final.outputs.finalProjects }} + value: ${{ jobs.compute.outputs.finalProjects }} jobs: compute: runs-on: ubuntu-latest + outputs: + finalProjects: ${{ steps.final.outputs.finalProjects }} steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/.github/workflows/e2e-test.yaml b/.github/workflows/e2e-test.yml similarity index 97% rename from .github/workflows/e2e-test.yaml rename to .github/workflows/e2e-test.yml index eb0eb231..cfce24dd 100644 --- a/.github/workflows/e2e-test.yaml +++ b/.github/workflows/e2e-test.yml @@ -36,6 +36,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup Node.js uses: ./.github/actions diff --git a/.github/workflows/create-release.yaml b/.github/workflows/new-release.yml similarity index 60% rename from .github/workflows/create-release.yaml rename to .github/workflows/new-release.yml index 46c2daca..35a04a6b 100644 --- a/.github/workflows/create-release.yaml +++ b/.github/workflows/new-release.yml @@ -1,14 +1,4 @@ -name: 📦 Create Release - -defaults: &project_options - - "" - - json-api-nestjs - - json-api-nestjs-sdk - - nestjs-json-rpc - - nestjs-json-rpc-sdk - - json-api-nestjs-microorm - - json-api-nestjs-shared - - json-api-nestjs-typeorm +name: 📦 New Release on: workflow_dispatch: @@ -28,25 +18,57 @@ on: required: false default: "" type: choice - options: *project_options + options: + - "" + - json-api-nestjs + - json-api-nestjs-sdk + - nestjs-json-rpc + - nestjs-json-rpc-sdk + - json-api-nestjs-microorm + - json-api-nestjs-shared + - json-api-nestjs-typeorm project2: description: "Select project" required: false default: "" type: choice - options: *project_options + options: + - "" + - json-api-nestjs + - json-api-nestjs-sdk + - nestjs-json-rpc + - nestjs-json-rpc-sdk + - json-api-nestjs-microorm + - json-api-nestjs-shared + - json-api-nestjs-typeorm project3: description: "Select project" required: false default: "" type: choice - options: *project_options + options: + - "" + - json-api-nestjs + - json-api-nestjs-sdk + - nestjs-json-rpc + - nestjs-json-rpc-sdk + - json-api-nestjs-microorm + - json-api-nestjs-shared + - json-api-nestjs-typeorm project4: description: "Select project" required: false default: "" type: choice - options: *project_options + options: + - "" + - json-api-nestjs + - json-api-nestjs-sdk + - nestjs-json-rpc + - nestjs-json-rpc-sdk + - json-api-nestjs-microorm + - json-api-nestjs-shared + - json-api-nestjs-typeorm beta-release: description: 'Is beta release?' required: false @@ -70,7 +92,7 @@ jobs: project4: ${{ github.event.inputs.project4 }} test: - need: [compute-projects] + needs: [compute-projects] uses: ./.github/workflows/test.yml with: mainBranch: "last-tag" @@ -79,7 +101,7 @@ jobs: e2e-test: needs: [test] - uses: ./.github/workflows/e2e-test.yaml + uses: ./.github/workflows/e2e-test.yml with: mainBranch: "last-tag" secrets: @@ -95,7 +117,7 @@ jobs: upload-badge: needs: [ test, e2e-test ] - uses: ./.github/workflows/upload-badge.yaml + uses: ./.github/workflows/upload-badge.yml with: mainBranch: "last-tag" secrets: @@ -108,9 +130,16 @@ jobs: uses: ./.github/workflows/bump-version.yml with: projects: ${{ needs.compute-projects.outputs.finalProjects }} - beta-release: ${{ github.event.inputs.beta-release }} - dry-run: ${{ github.event.inputs.dry-run }} + beta-release: ${{ fromJSON(github.event.inputs.beta-release) }} + dry-run: ${{ fromJSON(github.event.inputs.dry-run) }} secrets: - NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} GITHUB_TOKEN_SECRET: ${{ secrets.GITHUB_TOKEN }} PAT: ${{secrets.PAT}} + + publish: + if: ${{ fromJSON(github.event.inputs.dry-run) == false }} + needs: [bump-version] + uses: ./.github/workflows/publish.yml + secrets: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index dc23c75c..beac577e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -11,7 +11,7 @@ jobs: e2e-test: needs: [test] - uses: ./.github/workflows/e2e-test.yaml + uses: ./.github/workflows/e2e-test.yml secrets: NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 799f7030..337d8b10 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,49 +1,31 @@ -name: Publish +name: ⚙️ Publish + on: -# workflow_run: -# workflows: [ "Create Releases" ] -# types: -# - completed - workflow_dispatch: + workflow_call: + secrets: + NPM_TOKEN: + required: true + env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_CONFIG_PROVENANCE: true jobs: publish: - #if: ${{ github.event.workflow_run.conclusion == 'success' }} - name: Publish runs-on: ubuntu-latest - permissions: - contents: "read" - actions: "read" - id-token: "write" # needed for provenance data generation - timeout-minutes: 10 steps: - - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Npm install + + - name: Setup Node.js uses: ./.github/actions - - name: Restore cached .nx - id: cache-nx-restore - uses: actions/cache/restore@v4 - with: - path: | - .nx - key: ${{ runner.os }}-nx-master - - run: npx nx affected -t build --parallel=3 --exclude='json-api-front,json-api-server,json-api-server-e2e,shared-utils,json-shared-type,microorm-database,typeorm-database,type-for-rpc' + + - name: Build + run: npx nx affected -t build --parallel=3 --exclude='*,!tag:type:publish' + - name: Publish packages run: npx nx release publish - shell: bash - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - NPM_CONFIG_PROVENANCE: true - - name: Save cached .nx - id: cache-dependencies-save - uses: actions/cache/save@v4 - with: - path: | - .nx - key: ${{ steps.cache-nx-restore.outputs.cache-primary-key }} + diff --git a/.github/workflows/upload-badge.yaml b/.github/workflows/upload-badge.yml similarity index 98% rename from .github/workflows/upload-badge.yaml rename to .github/workflows/upload-badge.yml index 7f1d7a83..9f260064 100644 --- a/.github/workflows/upload-badge.yaml +++ b/.github/workflows/upload-badge.yml @@ -4,6 +4,7 @@ on: workflow_call: inputs: mainBranch: + type: string description: Type for main nx affect required: false default: "master" diff --git a/apps/json-api-server-e2e/src/json-api/json-api-sdk/patch-methode.spec.ts b/apps/json-api-server-e2e/src/json-api/json-api-sdk/patch-methode.spec.ts index 5a2d61d6..e603de0c 100644 --- a/apps/json-api-server-e2e/src/json-api/json-api-sdk/patch-methode.spec.ts +++ b/apps/json-api-server-e2e/src/json-api/json-api-sdk/patch-methode.spec.ts @@ -129,6 +129,7 @@ describe('PATCH method:', () => { userWithEmptyAttr.id = userAfterSave.id; userWithEmptyAttr.addresses = newAddressAfterSave; userWithEmptyAttr.comments = [newCommentsAfterSave]; + userWithEmptyAttr.lastName = null as any; await jsonSdk.jonApiSdkService.patchOne(userWithEmptyAttr); const userAfterUpdate = await jsonSdk.jonApiSdkService.getOne( diff --git a/libs/json-api/json-api-nestjs-microorm/project.json b/libs/json-api/json-api-nestjs-microorm/project.json index 04be98fb..1a2d4b75 100644 --- a/libs/json-api/json-api-nestjs-microorm/project.json +++ b/libs/json-api/json-api-nestjs-microorm/project.json @@ -37,6 +37,19 @@ "updateBuildableProjectDepsInPackageJson": true } }, + "test": { + "executor": "@nx/jest:jest", + "outputs": [ + "{workspaceRoot}/coverage/{projectRoot}" + ], + "options": { + "jestConfig": "{projectRoot}/jest.config.ts", + "codeCoverage": true, + "coverageReporters": [ + "json-summary" + ] + } + }, "upload-badge": { "executor": "nx:run-commands", "dependsOn": [ @@ -46,7 +59,10 @@ ], "options": { "commands": [ - "node tools/scripts/upload-badge.mjs json-api-nestjs-microorm" + { + "command": "node tools/scripts/upload-badge.mjs json-api-nestjs-microorm", + "forwardAllArgs": false + } ], "cwd": "./", "parallel": false, diff --git a/libs/json-api/json-api-nestjs-sdk/project.json b/libs/json-api/json-api-nestjs-sdk/project.json index 7fa3ec1e..0a58414c 100644 --- a/libs/json-api/json-api-nestjs-sdk/project.json +++ b/libs/json-api/json-api-nestjs-sdk/project.json @@ -89,6 +89,38 @@ "parallel": false } }, + "test": { + "executor": "@nx/jest:jest", + "outputs": [ + "{workspaceRoot}/coverage/{projectRoot}" + ], + "options": { + "jestConfig": "{projectRoot}/jest.config.ts", + "codeCoverage": true, + "coverageReporters": [ + "json-summary" + ] + } + }, + "upload-badge": { + "executor": "nx:run-commands", + "dependsOn": [ + { + "target": "test" + } + ], + "options": { + "commands": [ + { + "command": "node tools/scripts/upload-badge.mjs json-api-nestjs-sdk", + "forwardAllArgs": false + } + ], + "cwd": "./", + "parallel": false, + "outputPath": "{workspaceRoot}/{projectRoot}" + } + }, "nx-release-publish": { "options": { "packageRoot": "dist/{projectRoot}" diff --git a/libs/json-api/json-api-nestjs-shared/project.json b/libs/json-api/json-api-nestjs-shared/project.json index 7696c291..a49a81e5 100644 --- a/libs/json-api/json-api-nestjs-shared/project.json +++ b/libs/json-api/json-api-nestjs-shared/project.json @@ -81,6 +81,19 @@ "parallel": false } }, + "test": { + "executor": "@nx/jest:jest", + "outputs": [ + "{workspaceRoot}/coverage/{projectRoot}" + ], + "options": { + "jestConfig": "{projectRoot}/jest.config.ts", + "codeCoverage": true, + "coverageReporters": [ + "json-summary" + ] + } + }, "upload-badge": { "executor": "nx:run-commands", "dependsOn": [ @@ -90,7 +103,10 @@ ], "options": { "commands": [ - "node tools/scripts/upload-badge.mjs json-api-nestjs-shared" + { + "command": "node tools/scripts/upload-badge.mjs json-api-nestjs-shared", + "forwardAllArgs": false + } ], "cwd": "./", "parallel": false, diff --git a/libs/json-api/json-api-nestjs-typeorm/project.json b/libs/json-api/json-api-nestjs-typeorm/project.json index 74981bfb..10a9c9b8 100644 --- a/libs/json-api/json-api-nestjs-typeorm/project.json +++ b/libs/json-api/json-api-nestjs-typeorm/project.json @@ -24,6 +24,19 @@ "packageRoot": "dist/{projectRoot}" } }, + "test": { + "executor": "@nx/jest:jest", + "outputs": [ + "{workspaceRoot}/coverage/{projectRoot}" + ], + "options": { + "jestConfig": "{projectRoot}/jest.config.ts", + "codeCoverage": true, + "coverageReporters": [ + "json-summary" + ] + } + }, "upload-badge": { "executor": "nx:run-commands", "dependsOn": [ @@ -33,7 +46,10 @@ ], "options": { "commands": [ - "node tools/scripts/upload-badge.mjs json-api-nestjs-typeorm" + { + "command": "node tools/scripts/upload-badge.mjs json-api-nestjs-typeorm", + "forwardAllArgs": false + } ], "cwd": "./", "parallel": false, diff --git a/libs/json-api/json-api-nestjs/project.json b/libs/json-api/json-api-nestjs/project.json index cba7e66b..dc351dbf 100644 --- a/libs/json-api/json-api-nestjs/project.json +++ b/libs/json-api/json-api-nestjs/project.json @@ -71,11 +71,14 @@ ], "options": { "commands": [ - "node tools/scripts/upload-badge.mjs json-api-nestjs" + { + "command": "node tools/scripts/upload-badge.mjs json-api-nestjs", + "forwardAllArgs": false + } ], "cwd": "./", "parallel": false, - "outputPath": "{workspaceRoot}/projectRoot}" + "outputPath": "{workspaceRoot}/{projectRoot}" } } },