Skip to content

Commit

Permalink
Merge pull request #123 from Mbed-TLS/dev/bensze01/psa-crypto
Browse files Browse the repository at this point in the history
Add test job for crypto repo
  • Loading branch information
mpg authored Dec 6, 2024
2 parents 99a5a4f + f560831 commit d736fff
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 7 deletions.
61 changes: 55 additions & 6 deletions vars/checkout_repo.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import hudson.model.Result
import hudson.plugins.git.GitSCM
import hudson.scm.NullSCM
import jenkins.model.CauseOfInterruption
import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
Expand Down Expand Up @@ -74,16 +75,33 @@ Map<String, String> checkout_tls_repo(String branch) {
try {
def result = checkout_report_errors(scm_config)

dir('framework') {
if (env.TARGET_REPO == 'framework' && env.CHECKOUT_METHOD == 'scm') {
dir('tf-psa-crypto') {
if (env.TARGET_REPO == 'tf-psa-crypto' && env.CHECKOUT_METHOD == 'scm') {
checkout_report_errors(scm)
} else if (env.FRAMEWORK_REPO && env.FRAMEWORK_BRANCH) {
checkout_report_errors(parametrized_repo(env.FRAMEWORK_REPO, env.FRAMEWORK_BRANCH))
} else if (env.TF_PSA_CRYPTO_REPO && env.TF_PSA_CRYPTO_BRANCH) {
checkout_report_errors(parametrized_repo(env.TF_PSA_CRYPTO_REPO, env.TF_PSA_CRYPTO_BRANCH))
} else {
echo 'Using default framework version'
echo 'Using default tf-psa-crypto version'
}
}

def framework_dirs = ['framework', 'tf-psa-crypto/framework']
if (env.TARGET_REPO == 'framework' && env.CHECKOUT_METHOD == 'scm') {
framework_dirs.each { framework_dir ->
dir(framework_dir) {
checkout_report_errors(scm)
}
}
} else if (env.FRAMEWORK_REPO && env.FRAMEWORK_BRANCH) {
framework_dirs.each { framework_dir ->
dir(framework_dir) {
checkout_report_errors(parametrized_repo(env.FRAMEWORK_REPO, env.FRAMEWORK_BRANCH))
}
}
} else {
echo 'Using default framework version'
}

// After the clone, replicate it in the local config, so it is effective when running inside docker
sh_or_bat '''
git config url.git@github.com:.insteadOf https://github.com/ && \
Expand Down Expand Up @@ -112,18 +130,49 @@ Map<String, String> checkout_mbed_os_example_repo(String repo, String branch) {
return checkout_report_errors(scm_config)
}

/** Produce an object that can be passed to {@code checkout} to make a shallow clone of the specified branch.
*
* @param repo
* URL of the Git repo.
*
* @param branch
* The branch / commit / tag to check out. Supports a variety of formats accepted by
* {@code git rev-parse}, eg.:
* <ul>
* <li>{@code <branchName>}
* <li>{@code refs/heads/<branchName>}
* <li>{@code origin/<branchName>}
* <li>{@code remotes/origin/<branchName>}
* <li>{@code refs/remotes/origin/<branchName>}
* <li>{@code <tagName>}
* <li>{@code refs/tags/<tagName>}
* <li>{@code refs/pull/<pullNr>/head}
* <li>{@code <commitId>}
* <li>{@code ${ENV_VARIABLE}}
* </ul>
* See also:
* <a href="https://www.jenkins.io/doc/pipeline/steps/params/scmgit/#scmgit">
* the documentation of the Git Plugin.
* </a>
*
* @return
* A {@link Map} representing a {@link GitSCM} object.
*/
Map<String, Object> parametrized_repo(String repo, String branch) {
String remoteRef = branch.replaceFirst('^((refs/)?remotes/)?origin/', '')
String localBranch = branch.replaceFirst('^(refs/)?(heads/|tags/|(remotes/)?origin/)?','')
return [
$class: 'GitSCM',
userRemoteConfigs: [[
url: repo,
refspec: "+$remoteRef:refs/remotes/origin/$localBranch",
credentialsId: env.GIT_CREDENTIALS_ID
]],
branches: [[name: branch]],
extensions: [
[$class: 'CloneOption', timeout: 60, honorRefspec: true, shallow: true],
[$class: 'SubmoduleOption', recursiveSubmodules: true, parentCredentials: true, shallow: true],
[$class: 'LocalBranch', localBranch: '**'],
[$class: 'LocalBranch', localBranch: localBranch],
],
]
}
Expand Down
2 changes: 1 addition & 1 deletion vars/environ.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void set_pr_environment(String target_repo, boolean is_production) {
env.JOB_TYPE = 'PR'
env.TARGET_REPO = target_repo
if (is_production) {
if (target_repo == 'framework') {
if (target_repo in ['framework', 'tf-psa-crypto']) {
env.MBED_TLS_REPO = 'git@github.com:Mbed-TLS/mbedtls.git'
}
set_common_pr_production_environment()
Expand Down
3 changes: 3 additions & 0 deletions vars/tf_psa_crypto.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
void run_pr_job() {
mbedtls.run_pr_job('tf-psa-crypto', true, ['development'])
}

0 comments on commit d736fff

Please sign in to comment.