diff --git a/.github/workflows/flake_vendorhash.yaml b/.github/workflows/flake_vendorhash.yaml index 542c87f8c1..1a1bc827ff 100644 --- a/.github/workflows/flake_vendorhash.yaml +++ b/.github/workflows/flake_vendorhash.yaml @@ -6,8 +6,10 @@ on: paths: - go.mod - go.sum - workflow_dispatch: - workflow_call: + pull_request: + paths: + - go.mod + - go.sum jobs: updateVendorHash: @@ -36,12 +38,14 @@ jobs: - name: Update ocm vendor hash run: nix run .#nixpkgs.nix-update -- --flake --version=skip ocm - name: Check diff and create action summary - id: check-diff + id: diff run: | diff=$(git diff) if [[ -z "$diff" ]]; then echo "Everything is tidy." exit 0 + else + echo "exists=true" >> "$GITHUB_OUTPUT" fi cat << EOF >> "${GITHUB_STEP_SUMMARY}" Updates the vendorHash in \`flake.nix\` @@ -54,8 +58,14 @@ jobs: \`\`\` EOF - name: Create Commit + if: ${{ steps.diff.outputs.exists }} # https://docs.github.com/de/rest/repos/contents?apiVersion=2022-11-28#create-or-update-file-contents run: | FILE=flake.nix - echo "{\"message\":\"auto update vendor hash\",\"content\":\"$(base64 -w0 ${FILE})\",\"sha\":\"$(git rev-parse :${FILE})\"}" > input.json - gh api -X PUT https://api.github.com/repos/open-component-model/ocm/contents/${FILE} --input input.json + BRANCH=${{ github.head_ref }} + echo "{\"message\":\"auto update vendor hash\",\"content\":\"$(base64 -w0 ${FILE})\",\"sha\":\"$(git rev-parse :${FILE})\"" > input.json + if [[ -n "$BRANCH" ]]; then + echo ",\"branch\":\"${{ github.head_ref }}\"" >> input.json + fi + echo "}" >> input.json + gh api -X PUT https://api.github.com/repos/${{ github.repository }}/contents/${FILE} --input input.json diff --git a/.gitignore b/.gitignore index 2bbcc71a08..330cd57626 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,9 @@ go.mod.bak dist/ .cache_ggshield .DS_Store +.project +.classpath +.settings/ +*.exe +.secrets +*.log diff --git a/cmds/ocm/ca/component-descriptor.yaml b/cmds/ocm/ca/component-descriptor.yaml deleted file mode 100644 index c9b54655c1..0000000000 --- a/cmds/ocm/ca/component-descriptor.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: ocm.software/v3alpha1 -kind: ComponentVersion -metadata: - creationTime: "2024-05-03T09:43:30Z" - name: test.com/postgresql - provider: - name: test.com - version: 14.0.5 -repositoryContexts: [] -spec: {} diff --git a/cmds/ocm/ocm_test.go b/cmds/ocm/ocm_test.go new file mode 100644 index 0000000000..77602644ea --- /dev/null +++ b/cmds/ocm/ocm_test.go @@ -0,0 +1,37 @@ +package main_test + +import ( + "os" + + . "github.com/mandelsoft/goutils/testutils" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + . "github.com/open-component-model/ocm/cmds/ocm/testhelper" + + "github.com/open-component-model/ocm/pkg/common/accessio" + "github.com/open-component-model/ocm/pkg/contexts/oci/attrs/cacheattr" +) + +var _ = Describe("OCM command line test Environment", func() { + var env *TestEnv + + BeforeEach(func() { + env = NewTestEnv(TestData()) + }) + + AfterEach(func() { + env.Cleanup() + }) + + It("Add OCI image resource fails when a cache directory is specified on Windows", func() { + tmp := Must(os.MkdirTemp("", "ocm-cache-*")) + defer os.RemoveAll(tmp) + // configure ocm cache + MustBeSuccessful(cacheattr.Set(env.OCIContext(), Must(accessio.NewStaticBlobCache(tmp)))) + + // ocm create ca --file ca --scheme ocm.software/v3alpha1 --provider test.com test.com/postgresql 14.0.5 + Expect(env.Execute("create", "ca", "--file", "ca", "--scheme", "ocm.software/v3alpha1", "--provider", "test.com", "test.com/postgresql", "14.0.5")).To(Succeed()) + // ocm add resource --file ca --name bitnami-shell --type ociImage --accessType ociArtifact --version 10 --reference bitnami/postgresql:16.2.0-debian-11-r1 + Expect(env.Execute("add", "resource", "--file", "ca", "--name", "bitnami-shell", "--type", "ociImage", "--accessType", "ociArtifact", "--version", "10", "--reference", "bitnami/postgresql:16.2.0-debian-11-r1")).To(Succeed()) + }) +}) diff --git a/cmds/ocm/suite_test.go b/cmds/ocm/suite_test.go new file mode 100644 index 0000000000..1852aab154 --- /dev/null +++ b/cmds/ocm/suite_test.go @@ -0,0 +1,13 @@ +package main_test + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestConfig(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "OCM command line tests - for bug verification") +} diff --git a/pkg/common/accessio/cache.go b/pkg/common/accessio/cache.go index 7cbb62b7f4..8f770c3399 100644 --- a/pkg/common/accessio/cache.go +++ b/pkg/common/accessio/cache.go @@ -232,8 +232,8 @@ func (c *blobCache) AddBlob(blob blobaccess.BlobAccess) (int64, digest.Digest, e if err != nil { return blobaccess.BLOB_UNKNOWN_SIZE, "", errors.Wrapf(err, "cannot create blob file in cache") } - defer writer.Close() size, err := io.Copy(writer, reader) + writer.Close() if err != nil { c.cache.Remove(tmp) return blobaccess.BLOB_UNKNOWN_SIZE, "", err