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

Check for revisions upon Samples caching #178

Merged
merged 1 commit into from
Aug 11, 2023
Merged

Conversation

thepetk
Copy link
Contributor

@thepetk thepetk commented Aug 3, 2023

Please specify the area for this PR

/area registry

What does does this PR do / why we need it:

This PR is introducing a check for samples using a different branch than the default. More detailed we have two cases:

  • A sample in extraDevfileEntries.yaml, having different versions while using the same repo. So the version X of a sample is using the X branch of sample repo, while the version Y of sample Y uses the branch Y of the same repo.

  • A sample with a single version that is not using the default branch.

More detailed, a simple addition is made to the cache_sample.sh file in order to check the given extraDevfileEntries.yaml for any git.checkoutFrom.revision fields inside a sample. For this, we are introducing the clone_sample_repo function:

function clone_sample_repo() {
  local repoUrl="$1"
  local repoOutputDir="$2"
  local repoRevision="$3"
  git clone $repoUrl $repoOutputDir
  if [[ $repoRevision != "null" ]]; then
    cd $repoOutputDir && git checkout $repoRevision && cd -
  fi
}

As a result we can support samples defined like:

name: go-basic
displayName: Basic Go
description: Go 1.16 application
icon: https://go.dev/blog/go-brand/Go-Logo/SVG/Go-Logo_Blue.svg
tags:
  - Go
projectType: Go
language: Go
provider: Red Hat
versions:
  - version: 1.0.2
    schemaVersion: 2.1.0
    git:
      checkoutFrom:
        revision: main
      remotes:
        origin: https://github.com/thepetk/devfile-sample-go-basic.git
  - version: 2.1.0
    schemaVersion: 2.2.0
    default: true
    git:
      checkoutFrom:
        revision: update_devfile
      remotes:
        origin: https://github.com/thepetk/devfile-sample-go-basic.git

Which issue(s) this PR fixes:

Fixes devfile/api#1209

PR acceptance criteria:

  • Test Coverage
    • Are your changes sufficiently tested, and are any applicable test cases added or updated to cover your changes?

Documentation (WIP)

How to test changes / Special notes to the reviewer:

@openshift-ci
Copy link

openshift-ci bot commented Aug 3, 2023

@thepetk: The label(s) area/registry cannot be applied, because the repository doesn't have them.

In response to this:

Please specify the area for this PR

/area registry

What does does this PR do / why we need it:

This PR is introducing a check for samples using a different branch than the default. More detailed we have two cases:

  • A sample in extraDevfileEntries.yaml, having different versions while using the same repo. So the version X of a sample is using the X branch of sample repo, while the version Y of sample Y uses the branch Y of the same repo.

  • A sample with a single version that is not using the default branch.

More detailed, a simple addition is made to the cache_sample.sh file in order to check the given extraDevfileEntries.yaml for any git.checkoutFrom.revision fields inside a sample. For this, we are introducing the clone_sample_repo function:

function clone_sample_repo() {
 local repoUrl="$1"
 local repoOutputDir="$2"
 local repoRevision="$3"
 if [[ $revision == "null" ]]; then
   git clone $repoUrl $repoOutputDir
 else
   git clone --single-branch --branch $repoRevision $repoUrl $repoOutputDir
 fi
}

As a result we can support samples defined like:

name: go-basic
displayName: Basic Go
description: Go 1.16 application
icon: https://go.dev/blog/go-brand/Go-Logo/SVG/Go-Logo_Blue.svg
tags:
 - Go
projectType: Go
language: Go
provider: Red Hat
versions:
 - version: 1.0.2
   schemaVersion: 2.1.0
   git:
     checkoutFrom:
       revision: main
     remotes:
       origin: https://github.com/thepetk/devfile-sample-go-basic.git
 - version: 2.1.0
   schemaVersion: 2.2.0
   default: true
   git:
     checkoutFrom:
       revision: update_devfile
     remotes:
       origin: https://github.com/thepetk/devfile-sample-go-basic.git

Which issue(s) this PR fixes:

Fixes #devfile/api#1209

PR acceptance criteria:

  • Test Coverage
    • Are your changes sufficiently tested, and are any applicable test cases added or updated to cover your changes?

Documentation (WIP)

How to test changes / Special notes to the reviewer:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@thepetk thepetk changed the title WIP: Check for revisions upon Samples caching Check for revisions upon Samples caching Aug 3, 2023
Copy link
Contributor

@mike-hoang mike-hoang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do allow commit ids to be used, so wondering if we should support that here?

ref: https://devfile.io/docs/2.2.0/devfile-schema#starter-projects-git-checkout-from-revision

revision string
The revision to checkout from. Should be branch name, tag or commit id. Default branch is used if missing or specified revision is not found.

build-tools/cache_samples.sh Outdated Show resolved Hide resolved
build-tools/cache_samples.sh Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (605081d) 35.93% compared to head (87748a7) 35.93%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #178   +/-   ##
=======================================
  Coverage   35.93%   35.93%           
=======================================
  Files           7        7           
  Lines        1347     1347           
=======================================
  Hits          484      484           
  Misses        816      816           
  Partials       47       47           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: thepetk@gmail.com
Signed-off-by: thepetk <thepetk@gmail.com>
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 10, 2023
@openshift-ci
Copy link

openshift-ci bot commented Aug 10, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mike-hoang, thepetk
Once this PR has been reviewed and has the lgtm label, please assign elsony for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@thepetk thepetk merged commit b136d19 into devfile:main Aug 11, 2023
8 checks passed
thepetk added a commit to thepetk/devfile-registry-support that referenced this pull request Aug 23, 2023
devfile#178)

Signed-off-by: thepetk@gmail.com

Signed-off-by: thepetk@gmail.com
Signed-off-by: thepetk <thepetk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
2 participants