-
Notifications
You must be signed in to change notification settings - Fork 22
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
Allow increment after successful upload + tidyup #4
Allow increment after successful upload + tidyup #4
Conversation
Many many many thanks for your work pfeerick, I like it and I am going to accept it, well made contribution are always accepted :) I tought on this before I closed #3 but I discarded the solution due to the fact that in this way I will commit a N+1 version on my VCS while my devices are running the N version. Basically the version and Version.h header will always have a N+1 version than what real devices are running. how can we workaround this problem? |
Aw... shucks... you spotted the one fly in the ointment! 🤣 Have to think about that one a little more. I was going to do a .gitignore on the I almost want to do a N+1 in the pre-script also, meaning the post script effectively writes the current version, rather than the next. Maybe this is could work if the 'version doesn't exist hence start from 0` instance is taken care of better... ☕ 🍫 |
If you do some math...
What can we do to solve the problem? |
This is what springs to mind:
This then means that you can build as many times as you like, but it'll only be a successful upload that allows the patch version to increment. Would that do the trick? It would also mean all the work is done in pre, rather in post, making it less repetitive. Hm... sounds like a state machine ...
|
I need to think on this. How can pre increment only if post has deleted a file? Are we referring to two different upload? In this case pre is not incrementing if the previous upload was wrong? You can know it if you launch two upload in the same time, am I missing something? Thanks. |
Ignoring the edge case of the creation of the VERSION file if not present, as I think that needs the be handled slightly differently to the normal (as in that instance, I don't think it should increment, but start at 0.1.0 - but I really don't know if that makes sense, either! 🤣 🤦♂️), what I am thinking of is using a file as a semaphore to link the two scripts somewhat. the pre(build) script logic would be something like:
then the build and upload happens, if it is successful, then post(upload) script runs, with just one job: to delete the UPLOAD_PENDING file. Thus allowing the next run of the pre(build) script to increment the patch number, and create the lock file once again. And if the upload fails, the file is still there, so you can build as many times as you like, and attempt to upload as many times as you like, until it is successful. Only at this point would the UPLOAD_PENDING file be removed. Thus the build number at the end of each successful upload will reflect that of the latest successful upload, rather than a future one. This is all on the basis (and it could just be my personal preference), that a build isn't really a new build until it has been tested (i.e. uploaded). As you might compile several times in a row merely to test your code actually compiles, before actually uploading it. If that sounds reasonable and rationale (!!), I'll look at trying to put that together that tomorrow. |
I'm sorry but I still don't understand. |
Correct. But that gave the
So I'm thinking of doing instead is to put the increment back in the build stage, but only allow it to increment if the last upload attempt was successful. Otherwise, the build stage won't increment. So you can still build as many times as you want, but it won't increment until there has been a successful upload. What I trying to work out as well is differences in VCS usage, programming habits, etc. Do you agree with the premise that the patch number shouldn't change just because you've pressed build, or is that sufficient to warrant the increment? As if that's the case, I think I can still handle that situation, but have a failed upload prevent an auto-increment. |
I agree that the increment should only be triggered with a successful upload. Thanks for your time pferrick I appreciate it. |
I have seen another commit. Please let me know when you think that is all ready to be merged :) |
@pfeerick I don't want to force an answer for you but just to be sure, is the pull request ready to be merged? |
As far as I can tell, it's right to go... was just letting it settle to see that it was stable. Plus other stuff ... life... has a habit of getting in the way. 😆 Basically pre does the increment IF the lock file it wrote when it incremented last is removed by post. If it doesn't increment, it still reports the version number, and also indicates it isn't incrementing. I could hide it in the .pio folder, since that is is untracked by VCS by default, but then that brings into play the problem of multi-machine editing... better for that file to be present in a commit to keep stuff in sync. |
Many thanks for the excellent contribution. |
No problem. And sure... I am responsible for having written some of it... people need to know which monkey with a typewriter to blame for anything that breaks! 😛 😆 |
For me, this resolves #3. Please kick the tyres, see what you think, and if you like it, accept it. After some brief testing, it seems to be working for me so far, but it's early hours ;)
Summary of changes include
Version.h
not found error (since project root is not in include path)