Skip to content

Add continuous integration using GitHub Actions - #52

Merged
svgeesus merged 3 commits into
pnggroup:mainfrom
claricle:rt-add-github-workflows
Jul 21, 2025
Merged

Add continuous integration using GitHub Actions#52
svgeesus merged 3 commits into
pnggroup:mainfrom
claricle:rt-add-github-workflows

Conversation

@ronaldtse

@ronaldtse ronaldtse commented Jul 8, 2025

Copy link
Copy Markdown
Contributor

Fixes #50.

(This PR was split from #51 , for your review @jbowler )

The current repository did not implement continuous integration and it is hard to ensure that the latest code and build methods work across the multitude of supported platforms.

We have added comprehensive workflows using GitHub Actions that test all supported build methods across multiple platforms, including:

  • Ubuntu: 22.04, 24.04 (both x64 and arm64)
  • macOS: 13 (Intel), 14 (arm64), 15 (arm64)
  • Windows: 2022 (x64), 11 ARM (arm64), MinGW32, MinGW64

In accordance to INSTALL.md which describes CMake and Makefiles as both accepted/supported methods to build, two workflows are created:

Both workflows share a build matrix configuration which is encoded at matrix.json.

Specifically:

  • The Windows Makefiles made a return (containing edits from @groelofs and @jbowler) to support the Makefile builds

  • CMake builds use the following setup:

    • Ubuntu/macOS: System zlib integration
    • Windows MSVC: vcpkg integration with arm64 support
    • Windows MSYS2: MinGW32/64 with native toolchain
  • Makefile builds use the following setup: (this is now in Add Makefile build workflow with Windows Makefiles #55)

    • Ubuntu/macOS: normal make
    • Windows MSVC: nmake with Makefile.w32
    • Windows MinGW: make with Makefile.mingw (32/64-bit)
  • An additional workflow for packaging a release at GitHub Releases is added which is triggered by pushing of a version tag (i.e. v*).

Caveat:

  • While a custom/manual zlib is also supported, I did not add that to the CI since it would result in too many jobs, a give or take given that most users would be using the system zlib (across platforms).

Credits

@ProgramMax

Copy link
Copy Markdown
Member

IIRC, @ctruta has CI running (just not on GitHub).
I'll wait to hear confirmation from them whether or not we should move forward here.

(IIRC the reasoning was to split CI up across several free services so we don't hit the free limit from GitHub. That said, I don't think we're close to hitting it so I would favor the CI running here.)

@jbowler

jbowler commented Jul 8, 2025

Copy link
Copy Markdown
Contributor

(IIRC the reasoning was to split CI up across several free services so we don't hit the free limit from GitHub. That said, I don't think we're close to hitting it so I would favor the CI running here.)

Seconded. After all what is the point of not using github CI at all? I trust no one has given out their credit card :-) so if the allocation runs out the CI tests stop (I assume).

@ronaldtse

Copy link
Copy Markdown
Contributor Author

Thanks for the positive response! Actually GitHub Actions for public repositories doesn’t stop, so the worry could be set aside 😉

@jbowler

jbowler commented Jul 8, 2025

Copy link
Copy Markdown
Contributor

Thanks for the positive response! Actually GitHub Actions for public repositories doesn’t stop, so the worry could be set aside 😉

Thank you. @ctruta, @svgeesus, @ProgramMax this guy should get a credit in the libpng documentation.

@ronaldtse
ronaldtse force-pushed the rt-add-github-workflows branch 2 times, most recently from a774f23 to e520d9e Compare July 9, 2025 05:22
@svgeesus

Copy link
Copy Markdown
Collaborator

The intent is great, but I'm aware of my own shallow knowledge in this area and trust @ctruta to spot any problems here, or approve it if there are none.

@ronaldtse

Copy link
Copy Markdown
Contributor Author

Thanks @jbowler @svgeesus , to be fair I would have used a C framework for functional tests but didn’t have the time to dig deeper in the code. So these tests really just check pngcheck as an opaque command-line tool.

@ctruta

ctruta commented Jul 16, 2025

Copy link
Copy Markdown
Member

Hello, apologies for my delayed review. I promise to take a careful look tomorrow.

Comment thread .gitignore Outdated
@@ -0,0 +1 @@
build/ No newline at end of file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is super-duper-incomplete, especially considering that we have plenty of non-CMake artifacts as well. For a plain C project, the .gitignore file should contain (at least) something like this:
https://github.com/github/gitignore/blob/main/C.gitignore

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ctruta This was only meant to be barebones since the project never had a .gitignore file and there was no indication what the project wanted in terms of such a file. Would you want me to copy in the contents of the C gitignore template from GitHub?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ronaldtse that's a good file as a barebones starter, but it's far from ideal (e.g. as I had negotiated with @jbowler about what to put in libpng, there's no exclusion for temporary files created by common editors like Vim and EMACS).

Please give me a few minutes, until I steal something from my other PNG projects, and then I'll ask you to review.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The gitignore file in this PR is now removed.

Comment thread CMakeLists.txt Outdated
find_package(ZLIB)
if(ZLIB_FOUND)
target_link_libraries(pngcheck PRIVATE ZLIB::ZLIB)
target_compile_definitions(pngcheck PRIVATE USE_ZLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

From commit 00f4d73 onwards, this is no longer necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed as requested.

Comment thread CMakeLists.txt Outdated
message(STATUS "Using local ZLIB subproject (location not available)")
endif()
target_link_libraries(pngcheck PRIVATE zlibstatic)
target_compile_definitions(pngcheck PRIVATE USE_ZLIB)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same comment as above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed as requested.

@ctruta ctruta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We removed the makefiles for the Windows builds, leaving the CMake dependency which is a standard requirement in a Windows programming workflow nowadays. (Integrated in the Visual Studio IDE, shipped with the Visual Studio installer, standard availability in Cygwin, MSYS2, etc.)

I would be glad to take in a CI automation, but may I please suggest splitting the CI contribution from any local build contributions? We can debate about taking in (or not) the makefiles. My refutation is about the simplification of testing and maintenance, and that includes the simplification of the CI build matrix.

As for the .gitignore file, if you please don't mind me, I will submit a competing PR. It took me a while to refine what to exclude and whatnot, for makefile artifacts, build system artifacts, IDE artifacts, etc. etc.

So, to conclude, if you could please resubmit, focusing exclusively on the additions required for verification via GitHub Actions, that'd be great!

@ronaldtse

Copy link
Copy Markdown
Contributor Author

Happy to change this in any way as long as it helps.

Personally, I think the Makefiles are a burden to maintain if there is already CMake.

Would the following changes be sufficient?

  • remove all Makefile* changes
  • remove the CI workflow that uses Makefile*, only keeping the CMake workflow
  • remove the .gitignore file since you have one

@ctruta ctruta mentioned this pull request Jul 17, 2025
@ronaldtse
ronaldtse force-pushed the rt-add-github-workflows branch from e520d9e to c001924 Compare July 17, 2025 13:29
@ronaldtse

ronaldtse commented Jul 17, 2025

Copy link
Copy Markdown
Contributor Author

@ctruta I've made the changes as requested, and will move the Windows Makefiles and Makefile CI workflow to a new PR if anyone wants it in the future. This is ready for review again.

@ctruta

ctruta commented Jul 17, 2025

Copy link
Copy Markdown
Member

@ctruta I've made the changes as requested, and will move the Windows Makefiles and Makefile CI workflow to a new PR if anyone wants it in the future. This is ready for review again.

Thank you. I had a brief look and I will continue tomorrow, but an overall comment that I'd like to make: the build matrix is just too expensive. We're using 100% portable C, nothing fancy or system-specific, so, if you're testing both 32-bit and 64-bit platforms, that's cool; but if you're testing on old and new flavours of Ubuntu, that's just time wasted. Even more so on macos-13 and macos-14 and macos-15, especially considering that AFAIK a test on Mac is more expensive (in cents per minute) than a test on Linux, for example.

I mean, sure, it's "free" for us, until we exceed our minutes (if we do exceed our minutes at all) but my point is this: for any extra test that you add, make sure you have a reason for it. You should be fine if you're just running the tests on ubuntu-latest, macos-latest and windows-latest, really.

And then, there's the Unix Makefile. You shouldn't bother with verification of the Windows makefiles because those are gone and we aren't bringing them back; but the Unix Makefile that we're currently having, is, well, here already, and that one should be tested. But make it Ubuntu-only, please, because one Unix platform to test should be sufficient, especially considering that you aren't even testing pngcheck.c anymore (because you did that already with the CMake test) -- you're testing the Unix Makefile.

@ronaldtse

Copy link
Copy Markdown
Contributor Author

I'm not sure about other users, but our users rely on pngcheck extensively on various platforms and architectures (amd64 and arm64). There are platforms that we could omit, for sample an older Ubuntu or a macOS version.

(I haven't even filed an issue that a user is asking for NetBSD support of pngcheck.)

Here's the justification for the matrix:

  • Ubuntu: we need to test one version for both ARM and x86 platforms, i.e. ubuntu-24.04-arm and ubuntu-24.04.
  • macOS: we need to test one version of ARM (Apple M-series) and Intel (x86), i.e. macos-15 (arm) and macos-13 (intel)
  • Windows: we need to test one version of ARM and x86, i.e. windows-11-arm and windows-2022.
  • Windows MinGW: we need to test both 32-bit and 64-bit

So we can remove ubuntu-22.04* and macos-14.

These are all platforms that people (at least our users) use pngcheck on.

I mean, sure, it's "free" for us, until we exceed our minutes (if we do exceed our minutes at all)
AFAIK a test on Mac is more expensive (in cents per minute) than a test on Linux

GitHub actually provides "unlimited minutes" for public repositories to support open source, so there is actually no monetary cost concern here. The only cost involved is the developer wait time for running tests with the potential maintenance of the build workflow.

And then, there's the Unix Makefile. You shouldn't bother with verification of the Windows makefiles because those are gone and we aren't bringing them back; but the Unix Makefile that we're currently having, is, well, here already, and that one should be tested. But make it Ubuntu-only, please, because one Unix platform to test should be sufficient, especially considering that you aren't even testing pngcheck.c anymore (because you did that already with the CMake test) -- you're testing the Unix Makefile.

Sure, I'll update that.

@ronaldtse

Copy link
Copy Markdown
Contributor Author

@ctruta the requested changes have been made. Hope this is good to go!

@ctruta

ctruta commented Jul 18, 2025

Copy link
Copy Markdown
Member

@ctruta the requested changes have been made. Hope this is good to go!

Acknowledged. I started the review. I want to do my own testing also, in order to get a better understanding of a bunch of things, and I disclose that I'll be stealing from your work 😉

I will complete the review by EOD today.

@ronaldtse

Copy link
Copy Markdown
Contributor Author

@ctruta all to the benefit of PNG and its users! 🥂😜

@ctruta

ctruta commented Jul 18, 2025

Copy link
Copy Markdown
Member

So I haven't had a chance to run my own tests -- I was busier than expected -- but I did look over your changes, and they look good. Very thorough 👍

@ctruta ctruta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good morning,

I just realized I haven't selected the "Approve" button, although I accepted with these changes. May I please ask for one more change, not in the commits but in the commit messages:

Specifically, could you please amend the first commit so that the message body (especially the first line) does not exceed 72 characters? Several of Git tools, including GitHub's own web interface, rely on this limit -- for example, it splits the subject line of commit 9d76a09 like this:

feat: add github actions for cmake and make: ubuntu, macos, windows, f…
…ixes #50

My suggestion: just drop the ending (fixes #50) and that will fix the problem. Over the decades, we've moved our PNG software over a variety of hosting services, 'cause nothing lasts forever, not even GitHub, so these numeric fields don't carry that much informational value.

In the same manner, for the last line

Contribution from Ronald Tse (@ronaldtse) of Ribose (@riboseinc/@metanorma)

it's better if you use a trailer that is understood by the Git tools. (For example, see git help commit and scroll down to the --trailer option. For example, here's a suggestion:

Contributed-by: Ronald Tse (@ronaldtse) of Ribose (@riboseinc/@metanorma)

Admittedly, this suggestion does exceed the 72-character limit, too, but the trailers in commit messages have a special status, they are expected to be one-liners, so the line length is not a hard requirement in the way that it would be for regular prose.

@ronaldtse
ronaldtse force-pushed the rt-add-github-workflows branch from 9a89a05 to 7c30964 Compare July 21, 2025 15:52
@ronaldtse

Copy link
Copy Markdown
Contributor Author

@ctruta Just pushed the requested changes! If you click on the "Approve" this workflow run then you can see the CI running in this PR.

@ctruta ctruta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If you click on the "Approve" this workflow run then you can see the CI running in this PR.

(👀)

@svgeesus
svgeesus merged commit 906a669 into pnggroup:main Jul 21, 2025
@ronaldtse
ronaldtse deleted the rt-add-github-workflows branch July 22, 2025 03:43
@ronaldtse

Copy link
Copy Markdown
Contributor Author

@ctruta @svgeesus thank you for merging!

@ctruta

ctruta commented Dec 12, 2025

Copy link
Copy Markdown
Member

This got broken due to GitHub retiring macos-13 as a supported build platform. Following up in PR #61.

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.

Continuous integration across supported platforms

5 participants