Merge pull request #155 from Lorenzooone/test_docker

Add testing docker build files and usage
This commit is contained in:
jeffman 2022-01-07 15:27:37 -05:00 committed by GitHub
commit b30c7c967e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 103 additions and 38 deletions

View File

@ -29,17 +29,19 @@ This project aims to both complete the VWF codebase and to provide a tool for tr
## Screenshots
![](./screenshots/itshappening2.png) ![](./screenshots/itshappening4.png) ![](./screenshots/itshappening5.png) ![](./screenshots/m2-status2.png) ![](./screenshots/m2-battle-slugs.png) ![](./screenshots/m2-fileselect.png)
# Building with Docker
# Building
## Building with Docker
Docker allows easily building without having to install the dependencies.
1. Put a MOTHER 1+2 ROM in `bin/m12fresh.gba`
2. While in the root of the project, run: `docker run --rm -it -v $PWD:/home/m2gba/src lorenzooone/m2gba_translation:builder`
2. While in the root of the project, run: `docker run --rm -it -v ${PWD}:/home/m2gba/src lorenzooone/m2gba_translation:builder`
The output will be inside the newly created `out` folder.
# Manually Building
## Manually Building
## Dependencies
### Dependencies
- [.NET Core 2.1 or later](https://dotnet.microsoft.com/download)
- [PowerShell Core 6.0 or later](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-6)
- [GNU Arm Embedded Toolchain](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads)
@ -68,9 +70,17 @@ The output will be inside the newly created `out` folder.
2. `dotnet build tools/ScriptToolGui -o bin/ScriptToolGui`
3. Run with `dotnet bin/ScriptToolGui/ScriptToolGui.dll` (or just run the EXE file directly).
# Manually Testing
# Testing
## Dependencies
## Testing with Docker
Docker allows easily testing without having to install the dependencies.
1. Put a MOTHER 1+2 ROM in `bin/m12fresh.gba`
2. While in the root of the project, run: `docker run --rm -it -v ${PWD}:/home/m2gba/src lorenzooone/m2gba_translation:tester`
## Manually Testing
### Dependencies
- [mGBA 0.9.3 or later, or nightly built after Nov 29, 2021](https://mgba.io/downloads.html)
- [Building dependencies](#Building)

View File

@ -1,29 +0,0 @@
FROM mcr.microsoft.com/powershell:ubuntu-20.04
RUN echo "------------------Updating System------------------"
RUN apt update
RUN apt upgrade
RUN apt install -y wget gcc-arm-none-eabi cmake build-essential tar git
RUN echo "------------------Installing dotnet core------------------"
RUN mkdir -p /opt/dep
WORKDIR /opt/dep
RUN wget https://dot.net/v1/dotnet-install.sh
RUN chmod +x dotnet-install.sh
RUN ./dotnet-install.sh -c 2.1
RUN echo "-------------------Installing armips------------------"
RUN git clone --recursive https://github.com/Kingcom/armips.git
WORKDIR /opt/dep/armips
RUN mkdir -p bld
WORKDIR /opt/dep/armips/bld
RUN cmake ../
RUN make -j
RUN mkdir -p /opt/src/bin
RUN cp /opt/dep/armips/bld/armips /opt/src/bin/armips
RUN cp /opt/dep/armips/bld/armipstests /opt/src/bin/armipstests
RUN cp /opt/dep/armips/bld/libarmips.a /opt/src/bin/libarmips.a
RUN useradd m2gba -m
RUN mkdir -p /home/m2gba/src
RUN cp /root/.dotnet /home/m2gba/.dotnet -R && rm -rf /opt/dep && rm -rf /opt/miscrosoft && rm -rf /root/.dotnet
RUN chown -R m2gba:m2gba /home/m2gba && chown -R m2gba:m2gba /opt/src
WORKDIR /opt/src
USER m2gba
CMD /home/m2gba/src/docker-scripts/docker-build-rom-script

View File

@ -1,3 +0,0 @@
#!/bin/bash
docker rm image mother2gba:build
docker build . -t mother2gba:build

View File

@ -0,0 +1,59 @@
FROM mcr.microsoft.com/powershell:ubuntu-20.04 AS builder
RUN echo "------------------Updating System------------------"
RUN apt update
RUN apt upgrade
RUN apt install -y wget gcc-arm-none-eabi cmake build-essential tar git
RUN echo "------------------Installing dotnet core------------------"
RUN mkdir -p /opt/dep
WORKDIR /opt/dep
RUN wget https://dot.net/v1/dotnet-install.sh
RUN chmod +x dotnet-install.sh
RUN ./dotnet-install.sh -c 2.1
RUN echo "-------------------Installing armips------------------"
RUN git clone --recursive https://github.com/Kingcom/armips.git
WORKDIR /opt/dep/armips
# Need a buildable commit...
RUN git checkout d481fe7a48b3ef02ce5358291a240819ff5742f1
RUN mkdir -p bld
WORKDIR /opt/dep/armips/bld
RUN cmake ../
RUN make -j
RUN mkdir -p /opt/src/bin
RUN cp /opt/dep/armips/bld/armips /opt/src/bin/armips
RUN cp /opt/dep/armips/bld/armipstests /opt/src/bin/armipstests
RUN cp /opt/dep/armips/bld/libarmips.a /opt/src/bin/libarmips.a
RUN useradd m2gba -m
RUN mkdir -p /home/m2gba/src
RUN cp /root/.dotnet /home/m2gba/.dotnet -R && rm -rf /opt/dep && rm -rf /opt/miscrosoft && rm -rf /root/.dotnet
RUN chown -R m2gba:m2gba /home/m2gba && chown -R m2gba:m2gba /opt/src
WORKDIR /opt/src
USER m2gba
CMD /home/m2gba/src/docker-scripts/docker-build-rom-script
#---------------------- Building mgba ------------------------
FROM builder AS mgba_builder
USER root
RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential ccache cmake \
git libavcodec-dev libavfilter-dev libavformat-dev libavresample-dev \
libavutil-dev libcmocka-dev libedit-dev libelf-dev libpng-dev \
libqt5opengl5-dev libsdl2-dev libsqlite3-dev libswscale-dev \
libzip-dev qtmultimedia5-dev qttools5-dev qttools5-dev-tools && \
apt-get autoremove -y && apt-get clean
WORKDIR /home/m2gba
USER m2gba
RUN git clone https://github.com/mgba-emu/mgba.git
RUN cd mgba && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr .. && make
#------------------- Building the Tester ---------------------
FROM builder AS tester
USER root
RUN apt-get update && \
apt-get install -y --no-install-recommends pulseaudio alsa-utils libsdl2-dev \
libzip-dev libavcodec-dev libavfilter-dev && \
apt-get autoremove -y && apt-get clean
WORKDIR /opt/src
USER m2gba
COPY --from=mgba_builder /home/m2gba/mgba/build/sdl/mgba ./bin/mgba-sdl
COPY --from=mgba_builder /home/m2gba/mgba/build/libmgba* ./
CMD /home/m2gba/src/docker-scripts/docker-test-rom-script

View File

@ -0,0 +1,3 @@
#!/bin/bash
docker image rm lorenzooone/m2gba_translation:builder
docker build --target builder . -t lorenzooone/m2gba_translation:builder

View File

@ -0,0 +1,3 @@
#!/bin/bash
docker image rm lorenzooone/m2gba_translation:tester
docker build --target tester . -t lorenzooone/m2gba_translation:tester

View File

@ -0,0 +1,22 @@
#!/bin/pwsh
"Starting Dummy services"
$Env:SDL_VIDEODRIVER = "dummy"
pulseaudio -D --exit-idle-time=-1
pactl load-module module-null-sink sink_name=SpeakerOutput sink_properties=device.description="Dummy_Output"
$Env:PATH += ":/home/m2gba/.dotnet:/home/m2gba/.dotnet/tools"
Copy-Item -Path "\home\m2gba\src\*" -Destination "\opt\src" -Recurse -Force
"Starting to build tools"
./build-tools.ps1
"Starting to build test rom"
./test.ps1
"Copying test log to output"
New-Item -Path "\home\m2gba\src" -Name "out" -ItemType "directory" -Force
Copy-Item -Path ".\bin\test.log" "\home\m2gba\src\out"
Copy-Item -Path ".\bin\m12test.gba" "\home\m2gba\src\out"
"Test ran successfully, please review the ./out folder for the resulting logs and test rom"