Code Monkey home page Code Monkey logo

Comments (12)

ajardin avatar ajardin commented on June 4, 2024 1

Your two assumptions are correct, and I don't understand this either. 🙃

I will try to take some time today to investigate further.

from monorepo-split-github-action.

ajardin avatar ajardin commented on June 4, 2024 1

This change would probably allow the script to handle more cases and solve my issue, but I want to do further testing to ensure there are no side effects. I will send you a pull request if my tests are okay, perhaps tomorrow.

from monorepo-split-github-action.

ajardin avatar ajardin commented on June 4, 2024 1

@TomasVotruba It seems to work as expected. 🥳

I have configured the split of 1 repository to 10 other repositories with success. My test scenario involved updating one file (README.md) with new ones (at least one Dockerfile).

Just a small note, because I was afraid I had broken something, we'll have to update the documentation before doing the next release. The names of the inputs have indeed been changed in the meantime (source). I could prepare the PR if you want.

Thanks again for your work!

from monorepo-split-github-action.

TomasVotruba avatar TomasVotruba commented on June 4, 2024

Hi, thanks for reaching out :)

The split works on existing file on the split repository.
New files are split too :)

Maybe a different question... what exactly is your issue with the splitting right now?

from monorepo-split-github-action.

ajardin avatar ajardin commented on June 4, 2024

Thanks for your quick response!

Basically, I have a repository where I store all my Docker images and I want to split it to take advantage of the build on Docker Hub instead of GitHub Actions.

Here are some logs with an empty repository.

[NOTE] Starting...



[NOTE] Cloning "https://github.com/origamiphp/docker-blackfire-entrypoint.git" repository to "/tmp/monorepo_split/clone_directory" directory



[NOTE] Running: git clone -- https://***@github.com/origamiphp/docker-blackfire-entrypoint.git /tmp/monorepo_split/clone_directory

Cloning into '/tmp/monorepo_split/clone_directory'...
warning: You appear to have cloned an empty repository.


[NOTE] Cleaning destination repository of old files



[NOTE] Copying contents to git repo of 'main' branch

fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.

Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

[NOTE] Files that will be pushed

total 28
drwxr-xr-x 3 1001  121 4096 Jun 15 22:11 .
drwxr-xr-x 3 root root 4096 Jun 15 22:11 ..
drwxr-xr-x 7 root root 4096 Jun 15 22:11 .git
-rw-r--r-- 1 1001  121  436 Jun 15 22:11 Dockerfile
-rw-r--r-- 1 1001  121 1086 Jun 15 22:11 LICENSE
-rw-r--r-- 1 1001  121  585 Jun 15 22:11 README.md
-rw-r--r-- 1 1001  121 1010 Jun 15 22:11 entrypoint.sh

[NOTE] Changing directory from "/github/workspace" to "/tmp/monorepo_split/build_directory"

On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	Dockerfile
	LICENSE
	README.md
	entrypoint.sh

nothing added to commit but untracked files present (use "git add" to track)

[NOTE] No files to change



[NOTE] Changing directory from "/tmp/monorepo_split/build_directory" to "/github/workspace"

Here are some logs with an already initialised repository.

[NOTE] Starting...



[NOTE] Cloning "https://github.com/origamiphp/docker-blackfire-entrypoint.git" repository to "/tmp/monorepo_split/clone_directory" directory



[NOTE] Running: git clone -- https://***@github.com/origamiphp/docker-blackfire-entrypoint.git /tmp/monorepo_split/clone_directory

Cloning into '/tmp/monorepo_split/clone_directory'...


[NOTE] Cleaning destination repository of old files



[NOTE] Copying contents to git repo of 'main' branch



[NOTE] Files that will be pushed

total 28
drwxr-xr-x 3 1001  121 4096 Jun 15 22:18 .
drwxr-xr-x 3 root root 4096 Jun 15 22:18 ..
drwxr-xr-x 8 root root 4096 Jun 15 22:18 .git
-rw-r--r-- 1 1001  121  436 Jun 15 22:18 Dockerfile
-rw-r--r-- 1 1001  121 1086 Jun 15 22:18 LICENSE
-rw-r--r-- 1 1001  121  585 Jun 15 22:18 README.md
-rw-r--r-- 1 1001  121 1010 Jun 15 22:18 entrypoint.sh

[NOTE] Changing directory from "/github/workspace" to "/tmp/monorepo_split/build_directory"

On branch main
Your branch is up to date with 'origin/main'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	LICENSE

nothing added to commit but untracked files present (use "git add" to track)

[NOTE] No files to change



[NOTE] Changing directory from "/tmp/monorepo_split/build_directory" to "/github/workspace"

In both cases, my "new" files are not pushed to the split repository. But if I update one of the existing files, the split is correctly handled. 😕

from monorepo-split-github-action.

TomasVotruba avatar TomasVotruba commented on June 4, 2024

I don't have any experience with Docker hub splits, so I can't really help there.
On GitHub Actions splits works well. It might help if the remote branch should exist.

from monorepo-split-github-action.

ajardin avatar ajardin commented on June 4, 2024

I don't have any experience with Docker hub splits, so I can't really help there.

I probably expressed myself poorly, sorry... Let me rephrase. 😅

Here is my expected workflow.

  1. Commit something on the mono-repository
  2. Trigger a split according to subdirectories (example)
  3. Docker Hub automatically detects the change and builds the associated image (not your problem)

On GitHub Actions splits works well. It might help if the remote branch should exist.

I'm not sure to understand as I have a main branch on both repositories.

from monorepo-split-github-action.

TomasVotruba avatar TomasVotruba commented on June 4, 2024

I see, I understand this more clearly now. Thanks 👍

Just to verify, the https://github.com/origamiphp/docker-blackfire-entrypoint is complete, but LICENSE file is missing?

This is the directory that should be split? https://github.com/origamiphp/docker-images/tree/main/common/blackfire-entrypoint

The GitHub Actions setup seems correct, not sure what is wrong.

from monorepo-split-github-action.

TomasVotruba avatar TomasVotruba commented on June 4, 2024

Just a tip: when I try to debug the split, I usually start with single directory and single file. One can get easily lost if there is over 20 files to work with. Often it's some triviality like wrong directory, slashes path, confused setup directory vs repository in the Github action etc.

It saves me some sleep-less night to create just 1 repository with 1 file in 1 directory and try to split it into 1 remote repository that should contain just 1 file.

from monorepo-split-github-action.

ajardin avatar ajardin commented on June 4, 2024

I've done some more tests, and I really can't see which error in my setup would cause only changes to existing files to be pushed. So, I tested another approach by looking at the instruction that checks if there are any changes.

I can reproduce the issue locally with raw Git commands only, as you can see in the following snippet. From my point of view, it would be safer to use something like git status --porcelain instead of git diff-index --quiet HEAD.

What do you think?

#!/usr/bin/env bash

# Initialize the local test repository
mkdir -p tests
cd tests
git init --quiet
touch foo.txt
git add foo.txt
git commit --message="Initial commit" --quiet

# Test with an addition of a new file
touch bar.txt
git diff-index --quiet HEAD
echo "Addition exit code = "$?

# Test with a modification to an existing file
echo "Hello world" > foo.txt
git diff-index --quiet HEAD
echo "Modification exit code = "$?

# Remove the local test repository
cd ..
rm -rf tests
$ bash test.sh
Addition exit code = 0
Modification exit code = 1

from monorepo-split-github-action.

TomasVotruba avatar TomasVotruba commented on June 4, 2024

I have no idea how git works on this level. Basically I've hacked this when needed and try to fix if something is broken :)

Would you suggest to change this in GitHub action? Would it solve your issue?
We can give it a try, then you run the action in dev version to verify. Then we can revert in case of troubles

from monorepo-split-github-action.

TomasVotruba avatar TomasVotruba commented on June 4, 2024

Thanks for testing and sharing real repository where I can see the results easily 👍

I could prepare the PR if you want.

That would be great 🙂

from monorepo-split-github-action.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.