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
Add wesnoth-map-diff
#6472
Add wesnoth-map-diff
#6472
Conversation
00d1921
to
b0fe192
Compare
Good on you for giving this a try. If you're not finished, you can always switch the PR to a draft. |
a0f8f61
to
10420e4
Compare
for diff_image in ${{ steps.map-diff.outputs.DIFF_IMAGES }} | ||
do | ||
image_link=$(curl -X POST "https://api.imgur.com/3/upload" \ | ||
-F "image=@\"$diff_image\"" | jq ".data.link" -r) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How often will this upload images?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It uploads an image whenever a PR (with a .map
file) is opened or updated.
.github/workflows/map-diff.yml
Outdated
run: | | ||
cd ./utils/wesnoth-map-diff | ||
|
||
sudo apt-get install -y pngquant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's already utils/woptipng.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't notice this tool before.
But anyway, utils/woptipng.py
isn't standalone.
It depends on a set of different packages (Pillow, advdef, imagemagick/convert
, and optipng).
I think it's simpler just to install a single package (pngquant
) and run it on this action.
pngquant
works well for this kind of image as far as I checked.
10420e4
to
396b27f
Compare
5b0430b
to
aeb9f83
Compare
aeb9f83
to
16fbb5f
Compare
This seems really cool; how do I use it in my repositories for UMC campaigns that I maintain? |
The only thing I don't quite understand is… why upload the image to Imgur when GitHub itself supports image attachments on comments? @cooljeanius It might be enough to just copy the workflow file to your repo (once this is merged). |
Quick question: since most of our users are on Windows, how can they run this tool on Windows systems? IMHO, a text file which explains how to do so would be appreciated. |
There are two options:
Firstly, I tried to upload the image to GitHub. But it's harder since we need to have an authentication token.
There is the readme explaining it. But I can try to explain in more detail how to use it on Windows. |
@Elvish-Hunter I just added more detail on the readme. Please, let me know if it's better now |
.github/workflows/map-diff.yml
Outdated
## Get Maps | ||
git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }} | ||
|
||
map_paths=($(git diff --name-only HEAD ${{ github.event.pull_request.base.sha }} | grep ".map$")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot reproduce the issue with git diff --name-only HEAD ${{ github.event.pull_request.base.sha }} '*.map'
but I think strictly it should be git diff --name-only HEAD ${{ github.event.pull_request.base.sha }} -- '*.map'
If grep is really necessary then it should be grep '\.map$'
since a dot matches any character.
To not use word splitting and unintentionally pathname expansion it'd be better to use mapfile here:
mapfile -t map_paths < <(git diff --name-only HEAD ${{ github.event.pull_request.base.sha }} -- '*.map')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can reproduce the issue using my test repository:
> git clone git@github.com:macabeus/wesnoth.git
> cd wesnoth
> git checkout feat/add-wesnoth-map-diff-backup
> git diff --name-only HEAD 514b8bca9cf -- '*.map'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot reproduce it there either. For me git works as documented.
$ git diff --name-only HEAD 514b8bca9cf -- '*.map'
data/test.map
data/test2.map
Anyway it's not that big a deal to keep the grep as well.
If all comments have been addressed, it sounds like this can be merged? |
Do any of the reviewers know enough about the Node.js ecosystem to review this? I don't, @soliton- appears to be only reviewing the shell-script part, and the other commentators seem to be asking about how to run it rather than reviewing it. |
Yeah, I didn't and don't intend to look at the js part. |
Since it doesn't seem we'll get anyone to review the js part I would suggest to just merge this and see how it goes. |
I'll merge tomorrow then, barring anything else coming up. |
Solves #2323
This PR is a proposal to add a new command-line tool,
wesnoth-map-diff
.It aims to be a CLI to produce an image comparing two tilemaps, used by a GitHub Action to comment on a PR automatically:
I'm writing it using JS because it's the language I'm most used to and be easy to develop this kind of tool.
To use it, you need to have Node.js. Then on your terminal: