Skip to content

Merge pull request #11 from mcpt/DMOJ-merge #52

Merge pull request #11 from mcpt/DMOJ-merge

Merge pull request #11 from mcpt/DMOJ-merge #52

Workflow file for this run

name: build
on: push
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install Black and Flake8
run: |
pip install black==19.3b0 flake8 flake8-future-import flake8-logging-format
- name: Run Flake8
run: |
black --version
flake8 --version
flake8
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install dependencies and mypy
run: |
pip install cython mypy
pip install -r requirements.txt
- name: Verify mypy types
run: |
mypy --version
mypy dmoj
test-sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install build dependencies
run: pip install cython
- name: Create sdist
run: python setup.py sdist
- name: Install test dependencies
run: sudo apt-get install -y libseccomp-dev
- name: Test sdist
run: |
pip install dist/*.tar.gz
dmoj-autoconf
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.6, 3.7, 3.8, 3.9 ]
sandbox: [ seccomp ]
include:
- python-version: 3.6
sandbox: ptrace
- python-version: 3.9
sandbox: ptrace
steps:
- uses: actions/checkout@v2
- name: Download docker image
run: docker pull dmoj/runtimes-tier3
- name: Install python
run: |
curl -L "https://github.com/DMOJ/runtimes-python/releases/latest/download/python${{ matrix.python-version }}-amd64.tar.gz" |
tar -xz
- name: Create docker scripts
run: |
cat > run <<'EOF'
#!/bin/bash -e
export PYTHONUNBUFFERED=1
export LANG=C.UTF-8
export PYTHONIOENCODING=utf8
cd /code
export PYTHON="/code/python${{ matrix.python-version }}/bin/python${{ matrix.python-version }}"
"$PYTHON" -m pip install --upgrade pip wheel
"$PYTHON" -m pip install cython coverage
"$PYTHON" -m pip install -e .[test]
chmod o+w .
runuser -u judge -w PATH /code/run-su
EOF
cat > run-su <<'EOF'
#!/bin/bash -e
. ~/.profile
cd /code
"$PYTHON" -m coverage run -m unittest discover dmoj/tests/
"$PYTHON" -m coverage run --append .docker.test.py
"$PYTHON" -m coverage combine
"$PYTHON" -m coverage xml
EOF
chmod a+x run run-su
- uses: actions/cache@v2
with:
path: ~/docker-cache
key: ${{ runner.os }}-python-${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}
- name: Create cache
run: |
mkdir -p "$HOME/docker-cache/pip"
sudo chown root:root -R "$HOME/docker-cache"
- name: Execute tests in docker
run: docker run -e PYTHON_VERSION="${{ matrix.python-version }}" -e DMOJ_USE_SECCOMP="$([ ${{ matrix.sandbox }} = seccomp ] && echo yes || echo no)" -v "$(pwd):/code" -v "$HOME/docker-cache:/root/.cache" --cap-add=SYS_PTRACE dmoj/runtimes-tier3
- name: Upload coverage data
uses: codecov/codecov-action@v1
- name: Prepare cache for storage
run: sudo chown -R "$USER:$USER" "$HOME/docker-cache"