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

ci: add action to upload built patch files #325

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jonathanlinat
Copy link

@jonathanlinat jonathanlinat commented Dec 31, 2024

This PR aims to enhance the current CI workflow by uploading the built patch files to GitHub Actions as artifacts so we can download them and test the changes locally.

It also cleans up the CI.yml file for better readability and usability.

The uploaded artifacts will have the following naming pattern: dashfaction-<git-commit-head-sha>-<mingw|msvc>.zip

@is-this-c
Copy link
Contributor

I like this but why is retention-days set to 1 and why does it zip up build? build/bin contains final artifacts.

cmd is deprecated and pwsh is not needed so imo we should set defaults.run.shell to bash for simplicity and use a blank line for clarity between steps.

@jonathanlinat
Copy link
Author

@is-this-c Got it! I've applied the changes you asked for.

  • I've reapplied blank lines between the steps for clarity.
  • I've switched all the steps to bash.
  • I've set the upload-artifact's path to build/bin.
  • I've deleted the upload-artifact's retention days property as the default value is set within the current repository settings.

Copy link
Owner

@rafalh rafalh left a comment

Choose a reason for hiding this comment

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

Looking at my local build/Release/bin directory and files there take 134.4 MB. Compressed it is 40.5 MB. From what I see in my account billing page only 500 MB of storage is free (Storage for Actions and Packages section). This means that for MinGW alone limit will be reached after 13 commits... Default retention is 3 months. 13 commits for 3 months is not a lot and this is only MinGW. We could filter out debug info (in Mingw build it is in .debug files), then it would be just 14 MB, 5 MB compressed. That would be 100 commits for 3 months. But if MSVC is also stored that would be less (50?). Storing output from two compilers seems redundant, maybe MinGW only would be enough?
Also this storage is shared between projects so if I wanted to store artifacts in my other project that would conflict...
Do we really need this? I know there was no release for some time but I was thinking about one soon. Maybe that will "solve" the problem?

cmd is deprecated and pwsh is not needed so imo we should set defaults.run.shell to bash for simplicity and use a blank line for clarity between steps.

To be honest I prefer cmd over pwsh and I don't think it's officially "deprecated" even if Microsoft tries hard to force everyone to use PowerShell. Anyway I think it's best to stick to the defaults unless it makes things hard. Bash is not native on Windows but it is probably much easier to read last commit with it so it's okay to use it.

- name: Install packages
run: |
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install --no-install-recommends g++-mingw-w64-i686-posix ninja-build wine32 wine
shell: bash
Copy link
Owner

Choose a reason for hiding this comment

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

why set shell everywhere? On Linux it is Bash by default

Copy link
Author

Choose a reason for hiding this comment

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

Agreed, I'll remove it from build-mingw.

What about Windows? Do I keep it as an explicit value, as Git provides a Bash shell within Windows-based runners?


- uses: actions/checkout@v4

- name: Set Current Git Commit Head SHA
run: echo "GIT_CURRENT_COMMIT_HEAD_SHA=$(git rev-parse --short=10 HEAD)" >> $GITHUB_ENV
Copy link
Owner

Choose a reason for hiding this comment

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

--short by default uses 8 characters, that's probably enough?

Copy link
Author

Choose a reason for hiding this comment

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

Agreed. In fact, I will remove this flag as it is optional.

@@ -6,50 +6,80 @@ on:

env:
BUILD_TYPE: Release
WORKING_DIRECTORY: ${{ github.workspace }}/build
Copy link
Owner

Choose a reason for hiding this comment

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

not sure we need that var. It is not a working dir in every step so its name may be confusing. Maybe it should be BUILD_DIR?
But from docs I also see that they don't prefix it with ${{github.workspace}} so it is pretty much BUILD_DIR: ./build. With such a simple value I'm not convinced it actually brings much value.

Copy link
Author

Choose a reason for hiding this comment

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

I introduced this global variable as this path is used in multiple places. This is only for consistency and to not repeat.

I agree that the name is not the best. Do you want me to revert this change or only change the variable's name?

@is-this-c
Copy link
Contributor

is-this-c commented Jan 2, 2025

even if Microsoft tries hard to force everyone to use PowerShell.

No one is using cmd these days. Edit: https://x.com/richturn_ms/status/1265155820083240962

What about build artifacts just for whatever commit is latest?

@rafalh
Copy link
Owner

rafalh commented Jan 2, 2025

What about build artifacts just for whatever commit is latest?

What do you mean? AFAIK artifacts are linked to workflow runs and I don't know if there is a way to remove artifacts from older runs when a new one finishes. But if there was that would be a good option probably.

@jonathanlinat
Copy link
Author

jonathanlinat commented Jan 2, 2025

Thank you for the reviews. Based on what you said, I would like to propose a couple of things here.


As you mentioned, there are limitations with GitHub Actions regarding hosting artifacts, etc.

  • What about adjusting the workflow to be triggered only when a Pull Request is open and updated? That will prevent the uploading of artifacts for every commit.
  • What about re-introducing the retention days property to the Upload action and setting it to 7 days, which is enough to access the generated binaries for testing purposes? If it is needed to get access to the expired binaries, the author of the PR or you can re-run the workflow to generate them back.
  • What about introducing the option to the Upload action to override the existing binaries if the Pull Request is updated?

Now, I don't have enough experience with the low-coding ecosystem. I would appreciate your help in understanding.

  • Why does the workflow generate two types of build (mingw and msvc)? What's the purpose? When the patch is officially released, the end user can only access a single binary (As I can see for v1.8.0).
  • What about keeping only one?

Regarding the rest of the comments, I'll apply the changes you asked for.

@jonathanlinat jonathanlinat requested a review from rafalh January 2, 2025 16:36
@is-this-c
Copy link
Contributor

I changed my mind. PR artifacts are not a good idea.

AFAIK artifacts are linked to workflow runs and I don't know if there is a way to remove artifacts from older runs when a new one finishes. But if there was that would be a good option probably.

I believe it is possible. What about this action?

Why does the workflow generate two types of build (mingw and msvc)? What's the purpose?

Ensures compatibility.

@rafalh
Copy link
Owner

rafalh commented Jan 4, 2025

What about adjusting the workflow to be triggered only when a Pull Request is open and updated? That will prevent the uploading of artifacts for every commit.

I am against publishing binary artifacts for PR that were not reviewed because they may contain security issues (e.g. a malicious person could upload a vulnerability and then ask people to test it for them). Instead I was thinking about publishing snapshots for code on master branch instead so people can use them before official release.

Why does the workflow generate two types of build (mingw and msvc)? What's the purpose? When the patch is officially released, the end user can only access a single binary (As I can see for v1.8.0).

I want the project to be compatible with both MSVC and MinGW so people can use a compiler they prefer. Unfortunately there are some differences and a code that is successfully compiled by MSVC may fail to compile in MinGW (or the opposite). Having it compatible with two compilers increases the changes that it is standard-compliant.
When I release Dash Faction I use MinGW for compiling because Linux is my main OS (if I remember correctly some older versions of Dash were built using MSVC, but I don't remember when I switched).

@jonathanlinat
Copy link
Author

Got it. So, do I have to close this PR, or is there anything that you want me to do specifically?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants