Skip to content

Conversation

@MarkCallow
Copy link

@MarkCallow MarkCallow commented Jun 7, 2025

The fastest way for me to debug the reported unittest failures in my PR #206 was to create a CMake build to generate an Xcode project. Here it is together with a CI workflow that builds the utilities and unittest on macOS, Ubuntu and Windows and runs unittest. This CI will reveal issues in any future PRs.

Note that you may have to add a file .github/workflows/build_and_test.yml to master in order to be able to run the CI in this PR. GH Actions ignores workflow files in branches that don't have an equivalent in master. Whether this applies to PRs I do not know.

This CI will run when a tag of the form vX.Y.Z is added, when a commit is pushed to master and on PRs (subject to the above caveat.) It can also be run manually.

The PR includes fixes for many compile warnings, mostly about loss of data from 64-bit to 32-bit conversions. None of these are in lodepng.{cpp,h}. MSVC reports many more including many int to char conversions that should be looked at. Many of these are in lodepng.{cpp,h}.

See https://github.com/KhronosGroup/lodepng/actions/runs/15513735532 for an example CI run. See the log for the Windows job for all the MSVC warnings I wrote about.

There are still warnings in lodepng_unittest.cpp which are being
suppressed by a compile option. They should be fixed. See comment
in CMakeLists.txt.
Includes
* documentation in README.md
* vcpkg.json letting vcpkg automatically download, build and
  install sdl2 for the benchmark and showpng utilities.
* .gitignore to ignore artifacts of both the CMake and Makefile
  builds.

sdl2 can also be installed with the platform's package manager.

Includes .gitignore to ignore artifacts of the build.
so it can be run without knowledge of the executable location
within the build directory.
@MarkCallow
Copy link
Author

The CI workflow uses a hack for caching the built vcpkg package (sdl2) to speed up subsequent CI runs. I am not sure how robust it is to recognizing package or platform updates or changes. I have created an alternative using the caching technique recommended by vcpkg which will be robust. However this requires a GitHub Personal Access Token to work. It is needed for accessing the GitHub API for reading and writing packages to NuGet (the caching service). It is easy to create such a PAT and add it to the Actions secrets. @lvandeve Let me know if you are okay with this. If so, I will update this PR.

Convert to use pre-installed vcpkg on macOS.
@MarkCallow
Copy link
Author

I just pushed a change to use the NuGet caching recommended by vcpkg. This is fully robust. Since vcpkg handles the caching it always knows what packages have changed and need to uploaded to the cache again. The commit includes a change to use the pre-installed vcpkg on macOS.

I have used the username lvandev for the cache user. The workflow needs a GitHub Personal Access Token (PAT) which it uses as both a key for the relevant GitHub API and as a password for accessing the cache. Add this token to the repo's Actions Secrets with the name GH_PACKAGES_TOKEN. To generate the token go to your Account->Settings->Developer Settings. Then click on Personal Access Tokens followed by Tokens (classic). Click Generate New Token then New Token (classic). Select the expiration of your choice then under Scopes click on Write:packages (this will also select Read:packages. Scroll to the bottom and click Generate Token. Once you've added this token to the repo's secrets this workflow should function.

@MarkCallow
Copy link
Author

Commit ccef5eb removes the need to make a GitHub Personal Access Token for access to GitHub packages for the vcpkg cache. It uses GITHUB_TOKEN instead which is available in every workflow. It adds packages: write permission for this token in order that the workflow can write to the cache.

I used a custom token before because the vcpkg documentation said you could not use GITHUB_TOKEN as it only has permission to read packages. They failed to say that a workflow can add write permission. Glad I learned that you can.

@MarkCallow
Copy link
Author

To use this you will need to enable Actions for this repo in Settings->Actions. I think I will then need to push some innocuous (non) change to this PR to trigger a run of the workflow. I wrote earlier that you may have to add the workflow file to main in order for it to run in this PR. I have now learned that only manual triggering of the workflow requires a workflow of the same name in main. Please enable Actions and let's try this out.

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.

1 participant