Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/devel' into next/24.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CMazzilli committed Sep 17, 2024
2 parents 0aad416 + 766506f commit fdd76c4
Show file tree
Hide file tree
Showing 30 changed files with 652 additions and 260 deletions.
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npx commitlint --edit $1
commitlint --edit $1
188 changes: 49 additions & 139 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,115 +5,27 @@
*/

// git utils
int getCommitParentsCount() {
return Integer.parseInt(
sh(
script: """#!/usr/bin/env bash
git cat-file -p HEAD | grep -w "parent" | wc -l
""",
returnStdout: true
).trim()
)
}

boolean gitIsMergeCommit() {
return 2 <= getCommitParentsCount()
}

void gitFixConfigAndRemote() {
sh(
script: """#!/usr/bin/env bash
git config user.email "bot@zextras.com"
git config user.name "Tarsier Bot"
"""
)
String repoOriginUrl = sh(
script: """#!/usr/bin/env bash
git remote -v | head -n1 | cut -d\$'\t' -f2 | cut -d\" \" -f1
""",
returnStdout: true
).trim()
String newOriginUrl = repoOriginUrl.replaceFirst("https://github.com/Zextras", "git@github.com:Zextras")
sh(
script: """#!/usr/bin/env bash
git remote set-url origin ${newOriginUrl}
"""
)
}

void gitUnshallow() {
sh(
script: """#!/usr/bin/env bash
git fetch --unshallow
"""
)
}

void gitSetup() {
gitFixConfigAndRemote()
gitUnshallow()
}

String getCommitVersion() {
return sh(
script: """#!/usr/bin/env bash
git log -1 | grep \'version:\' | sed -n \'s/.*version:\\s*//p\'
""",
returnStdout: true
).trim()
String getRepositoryName() {
return sh(script: '''#!/bin/bash
git remote -v | head -n1 | cut -d$'\t' -f2 | cut -d' ' -f1 | sed -e 's!https://github.com/!!g' -e 's!git@github.com:!!g' -e 's!.git!!g'
''', returnStdout: true).trim()
}

String getCommitId() {
return sh(
script: """#!/usr/bin/env bash
git rev-parse HEAD
""",
returnStdout: true
).trim()
String getLastTag() {
return sh(script: '''#!/bin/bash
git describe --tags --abbrev=0
''', returnStdout: true).trim()
}

void gitPush(Map opts = [:]) {
def gitOptions = [' ']
if (opts.followTags == true) {
gitOptions << '--follow-tags'
}
if (gitOptions.size() > 1) {
gitOptions << ' '
Boolean tagExistsAtHead() {
try {
sh(script: '''#!/bin/bash
git describe --tags --exact-match
''', returnStdout: true)
return true
} catch (err) {
return false
}

sh(
script: """#!/usr/bin/env bash
git push${gitOptions.join(' ')}origin HEAD:${opts.branch}
"""
)
}

String getOriginUrl() {
return sh(
script: """#!/usr/bin/env bash
git remote -v | head -n1 | cut -d\$'\t' -f2 | cut -d\" \" -f1
""",
returnStdout: true
).trim()
}

void openGithubPr(Map args = [:]) {
def ownerAndRepo = getOriginUrl().replaceAll("git@github.com:", "").replaceAll(".git", "")
echo "Opening PR with https://api.github.com/repos/${ownerAndRepo}/pulls"
sh(
script: """#!/usr/bin/env bash
curl --location https://api.github.com/repos/${ownerAndRepo}/pulls \
-X POST \
-H 'Accept: application/vnd.github+json' \
-H 'Authorization: Bearer ${args.TOKEN}' \
-d '{
\"title\": \"${args.title}\",
\"head\": \"${args.head}\",
\"base\": \"${args.base}\",
\"maintainer_can_modify\": true
}'
"""
)
}

// Package utils
Expand All @@ -127,26 +39,6 @@ String getPackageName() {
).trim()
}

String getPackageDescription() {
return sh(
script: """#!/usr/bin/env bash
cat package.json \
| jq --raw-output '.description'
""",
returnStdout: true
).trim()
}

String getPackageVersion() {
return sh(
script: """#!/usr/bin/env bash
cat package.json \
| jq --raw-output '.version'
""",
returnStdout: true
).trim()
}

// node utils
void nodeCmd(Map args = [:]) {
final boolean install = (args.install != null) ? args.install : false
Expand Down Expand Up @@ -195,14 +87,9 @@ void npmLogin(String npmAuthToken) {
Boolean isReleaseBranch
Boolean isDevelBranch
Boolean isPullRequest
Boolean isMergeCommit
Boolean isBumpBuild
Boolean lcovIsPresent
// PROJECT DETAILS
String pkgName
String pkgVersion
String pkgVersionFull
String[] pkgVersionParts

pipeline {
agent {
Expand Down Expand Up @@ -245,18 +132,8 @@ pipeline {
echo "isDevelBranch: ${isDevelBranch}"
isPullRequest = "${BRANCH_NAME}" ==~ /PR-\d+/
echo "isPullRequest: ${isPullRequest}"
isMergeCommit = gitIsMergeCommit()
echo "isMergeCommit: ${isMergeCommit}"
isBumpBuild = isReleaseBranch && isMergeCommit
echo "isBumpBuild: ${isBumpBuild}"
isDevBuild = !isReleaseBranch
echo "isDevBuild: ${isDevBuild}"
pkgName = getPackageName()
echo "pkgName: ${pkgName}"
pkgDescription = getPackageDescription()
echo "pkgDescription: ${pkgDescription}"
pkgFullVersion = getPackageVersion()
echo "pkgFullVersion: ${pkgFullVersion}"
isSonarQubeEnabled = params.RUN_SONARQUBE == true && (isPullRequest || isDevelBranch || isReleaseBranch)
echo "isSonarQubeEnabled: ${isSonarQubeEnabled}"
}
Expand Down Expand Up @@ -436,6 +313,39 @@ pipeline {
}
}
}
stage('Open release to devel pull request') {
when {
beforeAgent true
allOf {
expression { isReleaseBranch == true }
expression { tagExistsAtHead() == true }
}
}
steps {
script {
catchError(buildResult: "UNSTABLE", stageResult: "FAILURE") {
String versionBumperBranchName = "version-bumper/${getLastTag()}"
sh(script: """#!/bin/bash
git push origin HEAD:refs/heads/${versionBumperBranchName}
""")
withCredentials([usernamePassword(credentialsId: 'tarsier-bot-pr-token-github', usernameVariable: 'GH_USERNAME', passwordVariable: 'GH_TOKEN')]) {
sh(script: """
curl https://api.github.com/repos/${getRepositoryName()}/pulls \
-X POST \
-H 'Accept: application/vnd.github.v3+json' \
-H 'Authorization: token ${GH_TOKEN}' \
-d '{
\"title\": \"chore(release): ${getLastTag()}\",
\"head\": \"${versionBumperBranchName}\",
\"base\": \"devel\",
\"maintainer_can_modify\": true
}'
""")
}
}
}
}
}
}
}

2 changes: 0 additions & 2 deletions THIRDPARTIES
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ MIT License (MIT) applies to:
@testing-library/react, Copyright (c) 2017 Kent C. Dodds
@testing-library/user-event, Copyright (c) 2020 Giorgio Polvara
@types/jest, Copyright (c) Microsoft Corporation.
@types/lodash, Copyright (c) Microsoft Corporation.
@types/node, Copyright (c) Microsoft Corporation.
@types/react-dom, Copyright (c) Microsoft Corporation.
@types/react, Copyright (c) Microsoft Corporation.
Expand All @@ -29,7 +28,6 @@ is-ci, Copyright (c) 2016-2021 Thomas Watson Steen
jest-environment-jsdom, Copyright (c) Meta Platforms, Inc. and affiliates.
jest-fail-on-console, Copyright (c) 2022 Valentin Hervieu
jest, Copyright (c) Meta Platforms, Inc. and affiliates.
lodash, Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
react-dom, Copyright (c) Facebook, Inc. and its affiliates.
react-pdf, Copyright (c) 2017–2023 Wojciech Maj
react, Copyright (c) Facebook, Inc. and its affiliates.
Expand Down
2 changes: 1 addition & 1 deletion docs/api/carbonio-ui-preview.imagepreview.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Main component for rendering the preview of an image
**Signature:**

```typescript
ImagePreview: import("react").ForwardRefExoticComponent<ImagePreviewProps & import("react").RefAttributes<HTMLDivElement>>
ImagePreview: React.ForwardRefExoticComponent<ImagePreviewProps & React.RefAttributes<HTMLDivElement>>
```
11 changes: 10 additions & 1 deletion docs/api/carbonio-ui-preview.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ Description
</td><td>


</td></tr>
<tr><td>

[VideoPreviewProps](./carbonio-ui-preview.videopreviewprops.md)


</td><td>


</td></tr>
</tbody></table>

Expand Down Expand Up @@ -174,7 +183,7 @@ The context give access to the functions needed to manage multiple previews. It

</td><td>

Show the preview for either an image or a pdf. This component is just a wrapper on the two specific preview components.
Show the preview for a video, an image or a pdf. This component is just a wrapper on the two specific preview components.


</td></tr>
Expand Down
4 changes: 3 additions & 1 deletion docs/api/carbonio-ui-preview.previewitem.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ Define an item for the preview. It can be of type 'image' or 'pdf'. The id is re
```typescript
export type PreviewItem = ((MakeOptional<Omit<ImagePreviewProps, 'show'>, 'onClose'> & {
previewType: 'image';
}) | (MakeOptional<Omit<VideoPreviewProps, 'show'>, 'onClose'> & {
previewType: 'video';
}) | (MakeOptional<Omit<PdfPreviewProps, 'show'>, 'onClose'> & {
previewType: 'pdf';
})) & {
id: string;
};
```
**References:** [MakeOptional](./carbonio-ui-preview.makeoptional.md)<!-- -->, [ImagePreviewProps](./carbonio-ui-preview.imagepreviewprops.md)<!-- -->, [PdfPreviewProps](./carbonio-ui-preview.pdfpreviewprops.md)
**References:** [MakeOptional](./carbonio-ui-preview.makeoptional.md)<!-- -->, [ImagePreviewProps](./carbonio-ui-preview.imagepreviewprops.md)<!-- -->, [VideoPreviewProps](./carbonio-ui-preview.videopreviewprops.md)<!-- -->, [PdfPreviewProps](./carbonio-ui-preview.pdfpreviewprops.md)

2 changes: 1 addition & 1 deletion docs/api/carbonio-ui-preview.previewwrapper.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## PreviewWrapper variable

Show the preview for either an image or a pdf. This component is just a wrapper on the two specific preview components.
Show the preview for a video, an image or a pdf. This component is just a wrapper on the two specific preview components.

**Signature:**

Expand Down
4 changes: 3 additions & 1 deletion docs/api/carbonio-ui-preview.previewwrapperprops.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export type PreviewWrapperProps = (ImagePreviewProps & {
previewType: 'image';
}) | (PdfPreviewProps & {
previewType: 'pdf';
}) | (VideoPreviewProps & {
previewType: 'video';
});
```
**References:** [ImagePreviewProps](./carbonio-ui-preview.imagepreviewprops.md)<!-- -->, [PdfPreviewProps](./carbonio-ui-preview.pdfpreviewprops.md)
**References:** [ImagePreviewProps](./carbonio-ui-preview.imagepreviewprops.md)<!-- -->, [PdfPreviewProps](./carbonio-ui-preview.pdfpreviewprops.md)<!-- -->, [VideoPreviewProps](./carbonio-ui-preview.videopreviewprops.md)

13 changes: 13 additions & 0 deletions docs/api/carbonio-ui-preview.videopreviewprops.errorlabel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@zextras/carbonio-ui-preview](./carbonio-ui-preview.md) &gt; [VideoPreviewProps](./carbonio-ui-preview.videopreviewprops.md) &gt; [errorLabel](./carbonio-ui-preview.videopreviewprops.errorlabel.md)

## VideoPreviewProps.errorLabel property

Label shown when the preview cannot be shown

**Signature:**

```typescript
errorLabel?: string;
```
Loading

0 comments on commit fdd76c4

Please sign in to comment.