-
Notifications
You must be signed in to change notification settings - Fork 1
Add inginious-task-tester workflow template #1
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
Open
nrybowski
wants to merge
4
commits into
UCL-INGI:master
Choose a base branch
from
nrybowski:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
workflow-templates/inginious-task-tester-container-builder.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #! /bin/env python3 | ||
|
|
||
| import subprocess | ||
| import os | ||
|
|
||
| containers = os.environ.get('REQUIRED', 'base').split(' ') | ||
| container_names = [] | ||
| for container in containers: | ||
| container_name = 'ingi/inginious-c-%s:latest' % container | ||
| container_names.append(container_name) | ||
| subprocess.run('docker build -t {container_name} {base_dir}/{sub_dir}/{container}'.format( | ||
| container_name=container_name, | ||
| container=container, | ||
| base_dir='${INGINIOUS}' if container == 'base' else '${CONTAINERS}', | ||
| sub_dir='base-containers' if container == 'base' else 'grading'), | ||
| shell=True) | ||
| subprocess.run('docker save %s -o ${INGINIOUS_IMAGES}' % ' '.join(container_names), shell=True) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| REQUIRED=base cpp pyjavacpp | ||
| PLUGIN_URLS=git+https://github.com/CNP3/INGInious-problems-network-trace git+https://github.com/UCL-INGI/INGInious-problems-math | ||
| PLUGIN_NAMES=inginious-problems-network-trace inginious_problems_math |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "name": "INGInious task tester", | ||
| "description": "Replay old submissions to ensure that the tasks behavior is unchanged", | ||
| "categories": [ "CI" ], | ||
| "filesPatterns": [ ".github/workflows/inginious-task-tester.env" ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| # This is a basic workflow to help you get started with Actions | ||
|
|
||
| name: INGInious tasks tester | ||
|
|
||
| # Controls when the workflow will run | ||
| on: | ||
| # Triggers the workflow on push or pull request events but only for the "main" branch | ||
| push: | ||
| branches: [ $default-branch ] | ||
| pull_request: | ||
| branches: [ $default-branch ] | ||
|
|
||
| # Allows you to run this workflow manually from the Actions tab | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| INGINIOUS: /home/runner/INGInious | ||
| CONTAINERS: /home/runner/containers | ||
| CONFIG_FILE: ${GITHUB_WORKSPACE}/.github/workflows/inginious-task-tester.env | ||
| INGINIOUS_IMAGES: /home/runner/inginious-images.tar | ||
| PYTHON_VER: 3.11 | ||
|
|
||
| # A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
| jobs: | ||
| # This workflow contains a single job called "build" | ||
| submissions_rerun: | ||
| # The type of runner that the job will run on | ||
| runs-on: ubuntu-20.04 | ||
|
|
||
| # Steps represent a sequence of tasks that will be executed as part of the job | ||
| steps: | ||
| # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
| - uses: actions/checkout@v3 | ||
|
|
||
| # Add REPO_NAME in env variables | ||
| - name: Setup repo name as env variable | ||
| run: echo "REPO_NAME=${{ github.event.repository.name }}" >> $GITHUB_ENV | ||
|
|
||
| - name: Load workflow config | ||
| run: | | ||
| cat ${{ env.CONFIG_FILE }} >> $GITHUB_ENV | ||
| echo ${GITHUB_ENV} | ||
|
|
||
| # Get INGInious source code | ||
| - name: Cache INGInious install | ||
| id: cache-inginious | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ${{ env.INGINIOUS }} | ||
| key: ${{ runner.os }}-inginious | ||
|
|
||
| - name: Get INGInious | ||
| if: steps.cache-inginious.outputs.cache-hit != 'true' | ||
| run: git clone https://github.com/UCL-INGI/INGInious.git ${INGINIOUS} | ||
|
|
||
| # Get INGInious containers | ||
| - name: Cache INGInious containers | ||
| id: cache-inginious-containers | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ${{ env.CONTAINERS }} | ||
| key: ${{ runner.os }}-inginious-containers | ||
|
|
||
| - name: Get INGInious containers | ||
| if: steps.cache-inginious-containers.outputs.cache-hit != 'true' | ||
| run: git clone https://github.com/UCL-INGI/INGInious-containers ${CONTAINERS} | ||
|
|
||
| # Get APT dependencies | ||
| # see https://github.com/actions/cache/issues/324 | ||
| - name: "[TMP] Chown APT cache" | ||
| if: steps.cache-apt.outputs.cache-hit != 'true' | ||
| run: sudo chown ${USER}:${USER} -R /var/cache/apt | ||
|
|
||
| - name: Cache APT | ||
| id: cache-apt | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: /var/cache/apt | ||
| key: ${{ runner.os }}-apt | ||
|
|
||
| # see https://github.com/actions/cache/issues/324 | ||
| - name: Install APT dependencies | ||
| if: steps.cache-apt.outputs.cache-hit != 'true' | ||
| run: | | ||
| sudo apt-get install -y libtidy5deb1 libzmq3-dev | ||
| sudo chown ${USER}:${USER} -R /var/cache/apt | ||
|
|
||
| # Add python3.11 because the syntax "tuple[type, type]" is not supported by the shipped python version | ||
| - name: Add Python3.11 | ||
| if: steps.cache-apt.outputs.cache-hit != 'true' | ||
| run: | | ||
| sudo apt install -y software-properties-common | ||
| sudo add-apt-repository ppa:deadsnakes/ppa | ||
| sudo apt update | ||
| sudo apt-get install -y python${{env.PYTHON_VER}} python${{env.PYTHON_VER}}-venv | ||
| python${{env.PYTHON_VER}} -m ensurepip --upgrade | ||
|
|
||
| # Get PIP dependencies | ||
| - name: Cache PIP | ||
| id: cache-pip | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: | | ||
| ~/.cache/pip | ||
| ~/.local/lib/python${{env.PYTHON_VER}} | ||
| key: ${{ runner.os }}-pip | ||
|
|
||
| - name: Install PIP dependencies and INGInious | ||
| if: steps.cache-pip.outputs.cache-hit != 'true' | ||
| run: | | ||
| pip${{env.PYTHON_VER}} install --user nose==1.3.7 selenium==3.141.0 coverage pyvirtualdisplay pytest | ||
| pip${{env.PYTHON_VER}} install --user ${INGINIOUS} | ||
| if [[ ! -z ${PLUGIN_URLS} ]]; then pip${{env.PYTHON_VER}} install --upgrade ${PLUGIN_URLS}; fi | ||
| pip${{env.PYTHON_VER}} install --user --upgrade markupsafe==2.0.1 | ||
|
|
||
| - name: Start services | ||
| run: | | ||
| sudo systemctl start mongod | ||
| sudo systemctl start docker | ||
|
|
||
| - name: Install INGInious | ||
| if: steps.cache-inginious.outputs.cache-hit != 'true' | ||
| run: | | ||
| cd ${INGINIOUS} | ||
| python${{env.PYTHON_VER}} inginious-install --default | ||
|
|
||
| - name: Add current repo in course list | ||
| run: ln -s ${GITHUB_WORKSPACE} ${INGINIOUS}/tasks/${REPO_NAME} | ||
|
|
||
| # Build INGInious containers | ||
| - name: Cache INGInious images | ||
| id: cache-inginious-images | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ${{ env.INGINIOUS_IMAGES }} | ||
| key: ${{ runner.os }}-inginious-images | ||
|
|
||
| - name: Build INGInious images | ||
| if: steps.cache-inginious-images.outputs.cache-hit != 'true' | ||
| run: python${{env.PYTHON_VER}} ${GITHUB_WORKSPACE}/.github/workflows/inginious-task-tester-container-builder.py | ||
|
|
||
| - name: Load INGInious Images | ||
| if: steps.cache-inginious-images.outputs.cache-hit == 'true' | ||
| run: docker load --input ${INGINIOUS_IMAGES} | ||
|
|
||
| - name: Re-playing old submissions | ||
| run: python${{env.PYTHON_VER}} ${INGINIOUS}/utils/task_tester/inginious-test-task -p ${PLUGIN_NAMES} -c ${INGINIOUS}/configuration.yaml ${REPO_NAME} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Here containers are iteratively built based on what the environment file contains. A choice has to made be made, either to:
inginious-installto solve dependencies automatically.I'm OK with choosing the first option. The second can also be implemented later, as this is not blocking.
In the second case it would be nice to refactor the base code and allow to use it outside of
inginious-install. This way, in case we add support for external Dockerfiles some day, those scripts would be ready too.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.
As we discussed some time ago, the best solution would be building and pushing INGInious containers automatically on a registry (e.g. DockerHub and/or GitHub.). We could then simply pull the images from there rather than rebuilding them when the cache is not filled. This would also ensure uniformity between all the CI instances.
I will open a Feature Request on the main repo for that.
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.
Should I consider this as a choice for option 1 and that the PR is ready for merge then ?