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

add unit test #351

Merged
merged 4 commits into from
Feb 11, 2024
Merged

add unit test #351

merged 4 commits into from
Feb 11, 2024

Conversation

win5923
Copy link
Contributor

@win5923 win5923 commented Feb 10, 2024

Context

  • resolves Automated Docker Container Tests #343 (comment)
  • Add unit test in uni-test.yml
  • Test if the server has successfully started through RCON.
  • Test if port 8211, 27015 and 25575 are listening with netcat command.
  • Test the backup command functions and check if the ./palworld/backups/ path contains a backup folder.

Due to the limitation that macOS environments in GitHub Actions do not support Docker for ARM64, it cannot be included.
Refer to: https://github.com/orgs/community/discussions/25777#discussioncomment-3249229

Not sure how to check If PalWorldSettings.ini is valid.

Choices

  • Improving Efficiency Through CI

Test instructions

  1. Push to the main branch and check each unit test step to ensure it meets the expected criteria.

Checklist before requesting a review

  • I have performed a self-review of my code
  • I've added documentation about this change to the README.
  • I've not introduced breaking changes.

@win5923 win5923 marked this pull request as draft February 10, 2024 20:49
@sonroyaalmerol
Copy link
Contributor

Due to the limitation that macOS environments in GitHub Actions do not support Docker for ARM64, it cannot be included.

docker/setup-qemu-action adds a layer of emulation that enables Docker to run ARM64 images among others. With that in the workflow, it should be able to run a test for the ARM64 images as well, albeit not an actual macOS environment. Also on that note, you won't need the QEMU step in the workflow for AMD64 images as the ubuntu-latest hosted runner of GitHub is already running on AMD64 architecture.

@win5923
Copy link
Contributor Author

win5923 commented Feb 10, 2024

Due to the limitation that macOS environments in GitHub Actions do not support Docker for ARM64, it cannot be included.

docker/setup-qemu-action adds a layer of emulation that enables Docker to run ARM64 images among others. With that in the workflow, it should be able to run a test for the ARM64 images as well, albeit not an actual macOS environment. Also on that note, you won't need the QEMU step in the workflow for AMD64 images as the ubuntu-latest hosted runner of GitHub is already running on AMD64 architecture.

Thx for your suggest, but when I try to install Docker on macOS, it installs a VM with ubuntu-23.10-minimal-cloudimg-amd64. Is this also acceptable?

arm64 build image process also takes more than 10 minutes.

Log:

Run brew install docker
Warning: Treating docker as a formula. For the cask, use homebrew/cask/docker
==> Downloading https://ghcr.io/v2/homebrew/core/docker/manifests/2[5](https://github.com/win5923/palworld-server-docker/actions/runs/7857284630/job/21440995946#step:3:6).0.2
==> Fetching dependencies for docker: docker-completion
==> Downloading https://ghcr.io/v2/homebrew/core/docker-completion/manifests/25.0.2
==> Fetching docker-completion
==> Downloading https://ghcr.io/v2/homebrew/core/docker-completion/blobs/sha25[6](https://github.com/win5923/palworld-server-docker/actions/runs/7857284630/job/21440995946#step:3:7):251922be53fecdb926b7ce66165d3552d2bfcd43d65dc6d9a388d0c36edeaf69
==> Fetching docker
==> Downloading https://ghcr.io/v2/homebrew/core/docker/blobs/sha256:82b0e5bc43ea64c[7](https://github.com/win5923/palworld-server-docker/actions/runs/7857284630/job/21440995946#step:3:8)7758d54ff7b1914afc412d56de625e6bca94c6eaf131a42d
==> Installing dependencies for docker: docker-completion
==> Installing docker dependency: docker-completion
==> Downloading https://ghcr.io/v2/homebrew/core/docker-completion/manifests/25.0.2
Already downloaded: /Users/runner/Library/Caches/Homebrew/downloads/09e35[8](https://github.com/win5923/palworld-server-docker/actions/runs/7857284630/job/21440995946#step:3:9)dd98d96a9c7536f96e856fdd9478371c512e8a851160b6b6a3dc20e384--docker-completion-25.0.2.bottle_manifest.json
==> Pouring docker-completion--25.0.2.all.bottle.tar.gz
🍺  /usr/local/Cellar/docker-completion/25.0.2: 9 files, 338.7KB
==> Installing docker
==> Pouring docker--25.0.2.monterey.bottle.tar.gz
🍺  /usr/local/Cellar/docker/25.0.2: 13 files, 25.7MB
time="2024-02-10T20:37:07Z" level=info msg="starting colima"
time="2024-02-10T20:37:07Z" level=info msg="runtime: docker"
time="2024-02-10T20:37:07Z" level=info msg="creating and starting ..." context=vm
time="2024-02-10T20:37:07Z" level=info msg="Terminal is not available, proceeding without opening an editor"
time="2024-02-10T20:37:08Z" level=info msg="Starting the instance \"colima\" with VM driver \"qemu\""
time="2024-02-10T20:37:09Z" level=info msg="QEMU binary \"/usr/local/bin/qemu-system-x86_64\" seems properly signed with the \"com.apple.security.hypervisor\" entitlement"
time="2024-02-10T20:37:09Z" level=info msg="Attempting to download the image" arch=x86_64 digest="sha512:97a6df4d4f4d13267fc7989933da537071513b3175a5785728992a8a198e0ceaaa0eaa2a9a4b01beaf6b998cc20b5995dc701e5c6d9ba2f4308e4208a84215df" location="https://github.com/abiosoft/colima-core/releases/download/v0.6.8-2/ubuntu-23.10-minimal-cloudimg-amd64.qcow2"
Downloading the image (ubuntu-23.[10](https://github.com/win5923/palworld-server-docker/actions/runs/7857284630/job/21440995946#step:3:11)-minimal-cloudimg-amd64.qcow2)

@sonroyaalmerol
Copy link
Contributor

sonroyaalmerol commented Feb 10, 2024

Thx for your suggest, but when I try to install Docker on macOS, it installs a VM with ubuntu-23.10-minimal-cloudimg-amd64. Is this also acceptable?

You probably shouldn't be using the macos-latest in this case. It wouldn't make sense as the runner is still using AMD64 architecture if I remember correctly. It's just the operating system that is different. It's made available for people who want to build stuff for the macOS itself with the likes of Swift and such. If you use macos-latest for Docker images, it would attempt to use a virtualized Ubuntu just to build the image (as you can see on your logs) as most Docker containers need the Linux kernel.

You'd want to still use ubuntu-latest with the QEMU step. Try to review the current workflows on the deployment of the ARM64 image.

arm64 build image process also takes more than 10 minutes.

arm64 build is indeed expected to be longer than the amd64 one as it has another build step for a dependency (rcon-cli) but it shouldn't take that long. The only reason it's taking more than 10 minutes in this case is because you're trying to build a Docker image within a macOS environment.

@win5923
Copy link
Contributor Author

win5923 commented Feb 10, 2024

Thx for your suggest, but when I try to install Docker on macOS, it installs a VM with ubuntu-23.10-minimal-cloudimg-amd64. Is this also acceptable?

You probably shouldn't be using the macos-latest in this case. It wouldn't make sense as the runner is still using AMD64 architecture if I remember correctly. It's just the operating system that is different. It's made available for people who want to build stuff for the macOS itself with the likes of Swift and such. If you use macos-latest for Docker images, it would attempt to use a virtualized Ubuntu just to build the image (as you can see on your logs) as most Docker containers need the Linux kernel.

You'd want to still use ubuntu-latest with the QEMU step. Try to review the current workflows on the deployment of the ARM64 image.

arm64 build image process also takes more than 10 minutes.

arm64 build is indeed expected to be longer than the amd64 one as it has another build step for a dependency (rcon-cli) but it shouldn't take that long. The only reason it's taking more than 10 minutes in this case is because you're trying to build a Docker image within a macOS environment.

Thank you so much!

@Twinki14
Copy link
Contributor

One thing I'll suggest is turning each unit test into its own reusable worklfow or action

https://docs.github.com/en/actions/using-workflows/reusing-workflows

It'll allow future us to run unit tests remotely in other workflows, which right now isn't all that beneficial but in the future it might be

Only a suggestion, not a reccomendation or requirement.

@win5923 win5923 marked this pull request as ready for review February 11, 2024 00:12
Copy link
Owner

@thijsvanloef thijsvanloef left a comment

Choose a reason for hiding this comment

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

This is really great! And I can't wait until more tests are added this way

@thijsvanloef thijsvanloef merged commit 76e3100 into thijsvanloef:main Feb 11, 2024
7 checks passed
MusclePr pushed a commit to MusclePr/palworld-server-docker that referenced this pull request Jun 19, 2024
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.

Automated Docker Container Tests
4 participants