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

#416 Add WSL to CI workflow #418

Merged
merged 33 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,37 @@ jobs:
- uses: actions/checkout@v4
- run: bash test/yaml/generators/test_schemata.sh
- run: pytest

test-wsl:
runs-on: windows-latest
steps:
- run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v4
- uses: Vampire/setup-wsl@v4
with:
distribution: Ubuntu-24.04
wsl-version: 2
additional-packages:
python3
python3-yaml
python3-colorama
python3-argcomplete
python3-ruamel.yaml
python3-matplotlib
python3-requests
python3-pytest
build-essential
default-jre
default-jdk
kotlin
texlive
texlive-latex-base
texlive-latex-recommended
texlive-latex-extra
lmodern
texlive-science
latexmk
- shell: wsl-bash {0}
run: pytest
9 changes: 2 additions & 7 deletions bin/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ def is_windows() -> bool:
return sys.platform in ['win32', 'cygwin']


# https://www.scivision.dev/python-detect-wsl/
def is_wsl() -> bool:
return 'Microsoft' in platform.uname().release


def is_mac() -> bool:
return sys.platform in ['darwin']

Expand Down Expand Up @@ -1044,7 +1039,7 @@ def exec_command(
kwargs.pop('memory')
if config.args.memory:
memory_limit = config.args.memory
if is_windows() or is_wsl() or config.args.sanitizer:
if is_windows() or config.args.sanitizer:
memory = None

process: Optional[ResourcePopen] = None
Expand All @@ -1062,7 +1057,7 @@ def interrupt_handler(sig, frame):
tstart = time.monotonic()

try:
if not is_windows() and not is_wsl() and preexec_fn:
if not is_windows() and preexec_fn:
process = ResourcePopen(
command,
preexec_fn=limit_setter(command, timeout, memory),
Expand Down
24 changes: 13 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,25 @@ After cloning the repository, symlink [bin/tools.py](bin/tools.py) to somewhere
```

### Windows
For Windows, the preferred way to use BAPCtools is inside the Windows Subsystem for Linux (WSL).

For Windows, you'll need the following in your
`path`:

- `Python` for Python 3
- `g++` to compile C++
- `javac` and `java` to compile and run `java`.

Resource limits (memory limit/hard cpu time limit) are also not supported.

BAPCtools makes use of symlinks for building programs. By default users are not allowed to create symlinks on Windows.
This can be fixed by enabling Developer Mode on Windows (Only since Windows 10, version 1703 or newer).<br>
Note that BAPCtools makes use of symlinks for building programs.
By default, users are not allowed to create symlinks on Windows.
This can be fixed by enabling Developer Mode on Windows (only since Windows 10 version 1703, or newer).<br>
In case you're still having problems with symlinks in combination with Git after enabling this setting,
please try the suggestions at https://stackoverflow.com/a/59761201.
Specifically, `git config -g core.symlinks true` should do the trick,
after which you can restore broken symlinks using `git checkout -- path/to/symlink`.

### Native Windows
If you cannot or do not want to use WSL, you'll need the following in your `%PATH%`:

- `python` for Python 3
- `g++` to compile C++
- `javac` and `java` to compile and run Java.

Resource limits (memory limit/hard cpu time limit) are not supported.

### Docker

A docker image containing this git repo and dependencies, together with commonly
Expand Down
2 changes: 2 additions & 0 deletions test/problems/hellounix/problem.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ validation: default
# time_multiplier: 2
# Warning for submissions within 1 second of limit:
# time_safety_margin: 1
limits:
memory: 512
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* This should fail with RUN-ERROR due to running out of memory, which
* is restricted.
*
* Note: This may try to create a coredump on exit and time out. This
* can be prevented with `ulimit -c 0`.
*/

#include <iostream>
#include <vector>

using namespace std;

const size_t mb = 513;

int main() {
std::cerr << "Trying to allocate at least: " << 513 << " MB" << std::endl;
vector<char> v(513 * 1024 * 1024);
std::cerr << "Allocated: " << v.size() << " MB" << std::endl;
return 0;
}