Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci/external publish pr #2

Merged
merged 24 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5f6a2d4
fix(component): configuration extractor to extract aliased types
kpanot Jul 18, 2023
8ab1387
fix: default value in schematics schema.json (for NX support)
kpanot Jul 18, 2023
899b88d
fix(ama-sdk/create): enable create feature for yarn pnp
kpanot Jul 14, 2023
bb65cea
Merge pull request #535 from AmadeusITGroup/bugfix/524
kpanot Jul 18, 2023
3362e1b
Merge pull request #539 from AmadeusITGroup/bugfix/cherry-pick-from-s…
pginoux-1A Jul 18, 2023
59586d8
ci: improve it-tests reports
fpaul-1A Jul 17, 2023
ee8ff89
fix: sdk generator - enhance questions for typescript shell
pginoux-1A Jul 18, 2023
ba5ab4b
Merge pull request #544 from AmadeusITGroup/bugfix/sdk-generator-on-b…
kpanot Jul 19, 2023
c7db7ce
Merge pull request #536 from AmadeusITGroup/bugfix/491
kpanot Jul 19, 2023
8c41e4d
chore(deps): update dependency @openapitools/openapi-generator-cli to…
renovate[bot] Jul 19, 2023
1ef6303
Merge pull request #546 from AmadeusITGroup/renovate/all-minor-patch
matthieu-crouzet Jul 19, 2023
6ee88e6
fix: export assets-path-override store module
mrednic-1A Jul 11, 2023
a13a4b8
fix(cascading): create pull request from the correct branch
kpanot Jul 12, 2023
3598626
fix: Use tagname for mat-option in fixtures
rglearns Jul 13, 2023
a096405
fix(cascading): increase get branch limit
kpanot Jul 19, 2023
fb3ffef
Merge pull request #551 from AmadeusITGroup/conflict/8.3.0-9.0.0-rc
kpanot Jul 19, 2023
0e85078
Merge release/9.0.0-rc into cascading/9.0.0-rc-main
otter-cascading[bot] Jul 19, 2023
9492e69
Merge pull request #552 from AmadeusITGroup/cascading/9.0.0-rc-main
matthieu-crouzet Jul 19, 2023
e3bce46
feat(cascading): add support for multi repositories with more than 10…
kpanot Jul 19, 2023
cfca870
Merge pull request #528 from AmadeusITGroup/ci/it-report
fpaul-1A Jul 19, 2023
0fb517d
ci: add timeouts for it-tests
fpaul-1A Jul 19, 2023
cf44439
Merge pull request #554 from AmadeusITGroup/ci/it-timeout
fpaul-1A Jul 19, 2023
6dd0c9f
Merge pull request #548 from AmadeusITGroup/feature/cascading-branch-…
kpanot Jul 19, 2023
d44e74f
ci: publish-pr on external workflow
fpaul-1A Jul 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/it-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: IT Tests report

on:
workflow_run:
workflows: ['Main CI']
types:
- completed

jobs:
publish-report:
runs-on: ubuntu-latest
steps:
- uses: dorny/test-reporter@v1
with:
artifact: it-reports
name: IT Tests report
path: '**/*.xml'
reporter: jest-junit
12 changes: 1 addition & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,7 @@ jobs:
with:
version: ${{ needs.version.outputs.nextVersionTag }}
prerelease: ${{ needs.version.outputs.isPreRelease == 'true' }}
publish-packages-pr:
uses: ./.github/workflows/publish.yml
if: ${{ github.event_name == 'pull_request' }}
permissions:
packages: write
contents: read
secrets: inherit
needs: [version, build]
with:
version: ${{ needs.version.outputs.nextVersionTag }}
prerelease: ${{ needs.version.outputs.isPreRelease == 'true' }}
isPullRequest: false

documentation-main:
secrets: inherit
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/publish-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Publish PR

on:
workflow_run:
workflows: ['Main CI']
types:
- completed

jobs:
version:
if: ${{ github.event.workflow_run.event == 'pull_request' }}
permissions:
actions: read
runs-on: ubuntu-latest
outputs:
nextVersionTag: ${{ steps.newVersion.outputs.nextVersionTag }}
steps:
- name: get logs from workflow run
uses: actions/github-script@v6
with:
script: |
let download = await github.rest.actions.downloadWorkflowRunLogs({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/logs.zip`, Buffer.from(download.data));
- run: unzip logs.zip
- name: extract version from logs
run: echo nextVersionTag=$(find *_version.txt | xargs grep -iPo '(?<=nextVersionTag variable has been set with ).*$') >> "$GITHUB_OUTPUT"

publish-packages-pr:
uses: ./.github/workflows/publish.yml
needs: [version]
permissions:
packages: write
contents: read
secrets: inherit
with:
version: ${{ needs.version.outputs.nextVersionTag }}
prerelease: true
isPullRequest: true

notify-parent:
runs-on: ubuntu-latest
needs: [publish-packages-pr]
permissions:
checks: write
steps:
- name: Update triggering workflow
uses: actions/github-script@v6
with:
script: |
const backUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/attempts/${context.runAttempt || 1}`;
await github.rest.checks.create({
head_sha: context.payload.workflow_run.head_commit.id,
name: 'publish packages',
conclusion: 'success',
status: 'completed',
output: {
title: 'publish packages',
summary: 'Successful publish [${backUrl}](${backUrl})'
},
...context.repo
});
12 changes: 8 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
default: false
required: false
description: Version of the artifact to publish
isPullRequest:
type: boolean
default: ${{ github.event_name == 'pull_request' }}
required: false
secrets:
AZURE_VSC_EXT_TOKEN:
required: false
Expand All @@ -37,7 +41,7 @@ jobs:
runs-on: ubuntu-latest
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
environment: ${{github.event_name == 'pull_request' && 'development' || 'production'}}
environment: ${{inputs.isPullRequest && 'development' || 'production'}}
permissions:
packages: write
contents: read
Expand All @@ -55,7 +59,7 @@ jobs:
is-prerelease: ${{ inputs.prerelease }}
version: ${{ inputs.version }}
- name: Publish
run: yarn run publish --tag=${{ github.event_name == 'pull_request' && 'pr' || steps.get-npm-tag.outputs.tag }} ${{ github.event_name == 'pull_request' && '--userconfig=./.npmrc.pr' || ''}} --always-auth=true
run: yarn run publish --tag=${{ inputs.isPullRequest && 'pr' || steps.get-npm-tag.outputs.tag }} ${{ inputs.isPullRequest && '--userconfig=./.npmrc.pr' || ''}} --always-auth=true
env:
GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand All @@ -64,7 +68,7 @@ jobs:
AZURE_EMAIL: ${{ secrets.AZURE_EMAIL }}

publish-cascading:
if: github.event_name != 'pull_request'
if: '!inputs.isPullRequest'
runs-on: ubuntu-latest
env:
APP_PATH: 'apps/github-cascading-app/dist'
Expand Down Expand Up @@ -100,7 +104,7 @@ jobs:

publish-extensions:
runs-on: ubuntu-latest
environment: ${{github.event_name == 'pull_request' && 'development' || 'production'}}
environment: ${{inputs.isPullRequest && 'development' || 'production'}}
permissions:
packages: write
contents: read
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ jobs:
with:
name: it-tests
path: it-tests.zip
- name: Publish tests reports
if: always()
uses: actions/upload-artifact@v3
with:
name: it-reports
path: 'packages/**/dist-test/it-report.xml'
- name: Stop verdaccio
if: always()
run: yarn verdaccio:stop
18 changes: 16 additions & 2 deletions apps/github-cascading-app/src/cascading/cascading-probot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,22 @@ export class CascadingProbot extends Cascading {
/** @inheritdoc */
protected async getBranches() {
this.logger.debug('List remote branches');
const res = await this.options.octokit.repos.listBranches(this.options.repo);
return res.data.map(({name}) => name);
/* eslint-disable camelcase, @typescript-eslint/naming-convention */
const per_page = 100;
let pageIndex = 1;
let getCurrentPage = true;
const branchNames: string[] = [];
while (getCurrentPage && pageIndex <= 20) {
const res = await this.options.octokit.repos.listBranches({
...this.options.repo,
per_page,
page: pageIndex++
});
branchNames.push(...res.data.map(({ name }) => name));
getCurrentPage = res.data.length === per_page;
}
return branchNames;
/* eslint-enable camelcase, @typescript-eslint/naming-convention */
}

/** @inheritdoc */
Expand Down
9 changes: 7 additions & 2 deletions apps/github-cascading-app/src/cascading/cascading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ export abstract class Cascading {
const openPr = await this.findOpenPullRequest(cascadingBranch, targetBranch);

if (!openPr) {
this.logger.debug(`Will recreate the branch ${cascadingBranch}`);
try {
await this.deleteBranch(cascadingBranch);
await this.createBranch(cascadingBranch, currentBranch);
Expand All @@ -263,6 +264,7 @@ export abstract class Cascading {
}
return this.createPullRequestWithMessage(cascadingBranch, currentBranch, targetBranch, config, true);
} else {
this.logger.debug(`Updating the PR ${openPr.id}`);
const message = await this.generatePullRequestBody({
...(openPr.context || { bypassReviewers: config.bypassReviewers, currentBranch, targetBranch, isConflicting: false}),
bypassReviewers: false
Expand Down Expand Up @@ -344,14 +346,15 @@ export abstract class Cascading {

const currentBranch = cascadingBranches[branchIndex];
const targetBranch = cascadingBranches[branchIndex + 1];
const cascadingBranch = this.determineCascadingBranchName(currentBranch.semver?.format() || currentBranch.branch, targetBranch.semver?.format() || targetBranch.branch);
let cascadingBranch = this.determineCascadingBranchName(currentBranch.semver?.format() || currentBranch.branch, targetBranch.semver?.format() || targetBranch.branch);
const isAhead = await this.isBranchAhead(currentBranch.branch, targetBranch.branch);

if (!isAhead) {
this.logger.info(`${currentBranch.branch} is not ahead of ${targetBranch.branch}. The cascading process will be skipped`);
return;
}

let isConflicting = false;
if (branches.includes(cascadingBranch)) {
try {
await this.merge(currentBranch.branch, cascadingBranch);
Expand All @@ -372,10 +375,12 @@ export abstract class Cascading {
this.logger.warn(`Fail to remove the cascading branch "${cascadingBranch}"`);
}
const conflictCascadingBranch = this.determineCascadingBranchName(currentBranch.semver?.format() || currentBranch.branch, targetBranch.semver?.format() || targetBranch.branch, true);
isConflicting = true;
await this.createBranch(conflictCascadingBranch, currentBranch.branch);
cascadingBranch = conflictCascadingBranch;
}
}
await this.createPullRequestWithMessage(cascadingBranch, currentBranch.branch, targetBranch.branch, config);
await this.createPullRequestWithMessage(cascadingBranch, currentBranch.branch, targetBranch.branch, config, isConflicting);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@
"^specs"
]
},
"test-int": {
"outputs": [
"{projectRoot}/dist-test/it-report.xml"
]
},
"prepare-publish": {
"outputs": [
"{projectRoot}/dist/package.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/@ama-sdk/create/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@angular-devkit/core": "~16.0.5",
"@angular-devkit/schematics": "~16.0.5",
"@angular-devkit/schematics-cli": "~16.0.5",
"@openapitools/openapi-generator-cli": "~2.6.0",
"@openapitools/openapi-generator-cli": "~2.7.0",
"@schematics/angular": "~16.0.5",
"minimist": "^1.2.6",
"typescript": "~5.0.2"
Expand Down
1 change: 1 addition & 0 deletions packages/@ama-sdk/create/src/index.it.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const cacheFolderPath = path.join(currentFolder, '.cache', appName);
const execAppOptions: ExecSyncOptions = {
cwd: sdkFolderPath,
stdio: 'inherit',
timeout: 15 * 60 * 1000,
/* eslint-disable @typescript-eslint/naming-convention, camelcase */
env: {
...process.env,
Expand Down
4 changes: 3 additions & 1 deletion packages/@ama-sdk/create/testing/jest.config.it.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
],
reporters: [
'default',
['jest-junit', {outputDirectory: resolve(__dirname, '..', 'dist-test'), outputName: 'it-report.xml'}],
'github-actions'
],
globals: {
Expand All @@ -23,5 +24,6 @@ module.exports = {
},
testMatch: [
'<rootDir>/**/*.it.spec.ts'
]
],
testTimeout: 30 * 60 * 1000
};
1 change: 1 addition & 0 deletions packages/@ama-sdk/generator-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"eslint-plugin-unicorn": "^47.0.0",
"isomorphic-fetch": "~3.0.0",
"jest": "~29.6.0",
"jest-junit": "^16.0.0",
"mem-fs": "^2.2.1",
"npm-run-all": "^4.1.5",
"onchange": "^7.0.2",
Expand Down
4 changes: 3 additions & 1 deletion packages/@ama-sdk/generator-sdk/testing/jest.config.it.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
],
reporters: [
'default',
['jest-junit', {outputDirectory: resolve(__dirname, '..', 'dist-test'), outputName: 'it-report.xml'}],
'github-actions'
],
globals: {
Expand All @@ -23,5 +24,6 @@ module.exports = {
},
testMatch: [
'<rootDir>/**/*.it.spec.ts'
]
],
testTimeout: 30 * 60 * 1000
};
5 changes: 3 additions & 2 deletions packages/@ama-sdk/schematics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@angular-devkit/schematics": "~16.0.5",
"@angular-devkit/schematics-cli": "~16.0.5",
"@angular/cli": "~16.0.5",
"@openapitools/openapi-generator-cli": "~2.6.0",
"@openapitools/openapi-generator-cli": "~2.7.0",
"@schematics/angular": "~16.0.5"
},
"dependencies": {
Expand All @@ -69,7 +69,7 @@
"@o3r/build-helpers": "workspace:^",
"@o3r/eslint-plugin": "workspace:^",
"@o3r/schematics": "workspace:^",
"@openapitools/openapi-generator-cli": "~2.6.0",
"@openapitools/openapi-generator-cli": "~2.7.0",
"@schematics/angular": "~16.0.5",
"@types/jest": "~29.5.2",
"@types/js-yaml": "^4.0.5",
Expand All @@ -89,6 +89,7 @@
"eslint-plugin-unicorn": "^47.0.0",
"isomorphic-fetch": "~3.0.0",
"jest": "~29.6.0",
"jest-junit": "^16.0.0",
"mem-fs": "^2.2.1",
"npm-run-all": "^4.1.5",
"nx": "~16.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function ngGenerateJavaClientCore(options: NgGenerateJavaClientCoreSchema
specPath,
codegenLanguage: 'javaClient',
apiTests: false,
specConfigPath: options.specConfigPath
specConfigPath: options.specConfigPath || undefined
})
]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
},
"specConfigPath": {
"type": "string",
"description": "Swagger config file\nMore info: https://openapi-generator.tech/docs/generators/java/#config-options",
"default": ""
"description": "Swagger config file\nMore info: https://openapi-generator.tech/docs/generators/java/#config-options"
}
},
"additionalProperties": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export interface NgGenerateJavaClientCoreSchematicsSchema extends JsonObject {
specPath: string;

/** Swagger config file */
specConfigPath: string;
specConfigPath: string | null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
},
"specConfigPath": {
"type": "string",
"description": "Spec config file\nMore info: https://openapi-generator.tech/docs/generators/typescript/#config-options",
"default": ""
"description": "Spec config file\nMore info: https://openapi-generator.tech/docs/generators/typescript/#config-options"
},
"directory": {
"type": "string",
"description": "Directory where to generate the SDK",
"default": ""
"description": "Directory where to generate the SDK"
},
"packageManager": {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ export interface NgGenerateTypescriptSDKCoreSchematicsSchema extends JsonObject
specPath: string;

/** Directory where to generate the SDK */
directory: string;
directory: string | null;

/** Package manager to be used in the generated SDK */
packageManager: 'npm' | 'yarn' | '';

/** Path to the spec generation configuration */
specConfigPath: string;
specConfigPath: string | null;
}
Loading