Please, see latest news in issue #140 (from April 25).
This page describes how the on-site tests will look like and eventually will also contain description of the (big) homework assignment. Small homework assignments are mentioned in the respective lab pages.
Please, have a look at the course guide page for details how the grading works.
On-site tests
This is the schedule for the on-site tests. The test will be held at the beginning of the lab (duration of the test is 45 minutes).
Week (date) | Topic |
---|---|
08 (April 7 - April 11) | T1: Git versioning system |
12 (May 5 - May 7 + May 15) | T2: Shell scripting |
14 (May 19 - May 23) | T3: make build tool |
You are expected to come to the lab you have enrolled to.
Because of state holiday on May 8, the T2 examination for Thursday labs will be postponed by a week. We are aware it is not optimal but the schedule for this semester has virtually no complete week (i.e., teaching in all days of a week) during the second half of the semester.
Your solution will be submitted through GitLab or through other Git repository: make sure you can perform a clone via a command-line client.
You are allowed to use our webpages, off-line manpages and you can consult your notes and solutions to examples that are part of the lab materials.
You are not allowed to use any other devices (cell phones, your own laptops etc.), consult other on-line resources (the machines will have restricted access to the Internet anyway) or communicate your solution to other students (and vice versa).
In other words, the on-site tests require that you can solve the tasks on your own with technical documentation only.
Any attempt to bypass the above rules (e.g. trying to search StackOverflow on your cell phone) means failing the course on the spot.
You are free to ask for clarification from your teacher if you do not understand the assignment, obviously. We can provide limited hints if it is clear that you are heading in the right direction and need only a little push.
Please, see also the general rules in the course guide.
Notes for the Git CLI exam
You will be expected to perform the following tasks in Git from the command-line
(some might be required to execute on the remote machine linux.ms.mff.cuni.cz
).
- Configure your Git environment (author and e-mail)
- Clone a repository (from
gitolite3@linux.ms.mff.cuni.cz
or from GitLab or generic HTTPS) - Create a commit
- Create a branch
- Switch between branches
- Merge a branch (and solve any conflicts)
- Push changes (branches) to server
Ensure that you can clone from gitolite3@linux.ms.mff.cuni.cz
when using
the school machines.
Only authentication via public key will be available (i.e. upload your keys
to keys/key.[0-9].pub
files in your repository before the exam as explained
in Lab 05).
The focus of the exam is on working with Git. You will not be required to write any script on your own but we will be working with a repository containing the following script for printing simple bar charts in the console. You will be required to make some small modifications (such as fixing typos) but we will always guide you to the right place in the code.
import argparse
import sys
def parse_config():
args = argparse.ArgumentParser(description='Console bar plot')
args.add_argument('--columns', default=60, type=int, metavar='N')
return args.parse_args()
def load_input(inp):
values = []
for line_raw in inp:
line = line_raw.strip()
if line.startswith('#') or not line:
continue
try:
val = float(line)
except ValueError:
print(f"WARNING: ignoring invalid line '{line}'.", file=sys.stderr)
continue
values.append(val)
return values
def print_barplot(values, scale, symbol):
for val in values:
print(symbol * round(val / scale))
def main():
config = parse_config()
values = load_input(sys.stdin)
if not values:
sys.exit(0)
coef = max(values) / config.columns
print_barplot(values, coef, '#')
if __name__ == '__main__':
main()
Notes for the Shell scripting exam
The following list capture the topics (constructs, commands, …) you are expected to know for the exam. The list is not exhaustive (for example, we do not mention all the commands from our mini manual but covers all the major parts.
- Construct a short pipeline with basic utilities such as
cut
,uniq
,paste
,bc
orsort
. - Use I/O redirection.
- Iterate through lines of a file in a manner of
while read ...; do ...; done < input.txt
. - Use
if
,for
andwhile
constructs. - Use
test
or[
for controlling shell loops and conditions. - Capture standard output via
$( cmd )
. - Source external scripts via
source
or.
(dot). - Use shell variables and shell functions to better capture the intent of data flow.
- Understand
getopts
argument parsing. - Use basic regular expressions for searching (
grep
) or trivial replacements (viased
).
Hints on Git setup are mentioned above.
The format of the exam will follow this pattern. You will receive an almost complete implementation of a certain assignment. Your task will be to implement the missing functions to complete the assignment.
The assignment will be split into different shell functions that you will implement. We will provide some basic (automated) tests that will be checking correctness of the individual functions (i.e. while it is recommended to read the whole script to understand the intent of it, it will be possible to implement some of the functions in isolation).
While the code in repository t02-example
will be used during the exam,
the example below can be used for further practice.
Quizzes
Quizzes will be given on labs 02, 03, 04, 05, 06 and 07.
Small homework tasks
- First (forum reaction) (until 2025-03-09)
- Second (Git over SSH with keys) (until 2025-03-23)
- Third (regular expressions) (until 2025-05-04)
- Fourth (process signals) (until 2025-05-11)
Big homework: project setup
Setup a CI for Python based project and prepare it for further distribution. This will include the following tasks (explained in more detail below).
- Make the source code into proper Python package.
- Create GitLab CI job for pytest (after merging their implementation/fixes).
- Create GitLab CI job for BATS tests (after some fixes and another Git merge).
We expect you will use external tools to drive your implementation but you must understand all the parts before submitting it and you must mark all parts that were not authored by you personally (and if you are using tools such as ChatGPT, you must submit the whole log of your communication with the tool).
Context
In this task you will be working with a simple Python project that is able to
render Jinja templates
(install Jinja2
package, not Jinja
).
As a trivial example (which you can also find in the examples
subdirectory
of the project repository) it will be able to perform the following
transformation.
We will have the following array (list) in JSON:
[
{
"name": "Introduction to Linux",
"code": "NSWI177",
"homepage": "https://d3s.mff.cuni.cz/teaching/nswi177/"
},
{
"name": "Operating Systems",
"code": "NSWI200",
"homepage": "https://d3s.mff.cuni.cz/teaching/nswi200/"
}
]
We will have the following input file:
Our courses
===========
Below is a list of (almost) all of our courses.
And we will have the following template. Note that control structures of the
template use {%
(or {%-
to strip surrounding whitespace) and {{
for
variable expansion.
{{ content }}
{%- for course in data -%}
* [{{ course.name }} ({{ course.code }})]({{ course.homepage }}) {{ NL }}
{%- endfor %}
When executed with our renderer (exact command is in the project README), we will get the following output.
Our courses
===========
Below is a list of (almost) all of our courses.
* [Introduction to Linux (NSWI177)](https://d3s.mff.cuni.cz/teaching/nswi177/)
* [Operating Systems (NSWI200)](https://d3s.mff.cuni.cz/teaching/nswi200/)
Source code
The source code for the above implementation was already prepared for you
and soon you will have access to a new project under teaching/nswi177/2025
subtree in GitLab where you will work.
The repository also contains several tests. There are unit tests in Python (using pytest) as well as higher-level tests (let us call them integration tests even that might be a bit overstated) written in BATS.
The invocation is described in the project README.
The assignment
Your main task is to setup basic CI on GitLab for this project and prepare the project for distribution.
The CI must execute the Python unit tests and fail the job on any error.
The preparation for distribution means that after your changes we will be
able to install the templater via pip
and have the templater
available as nswi177-jinja-templater
command.
In other words, the following commands would install the templater into a fresh virtual environment and the invocation of the last command would print a short help from our program (we assume we are in an empty directory that is not related in any way to any clone of your project).
python3 -m venv templater-venv
. ./templater-venv/bin/activate
pip install git+ssh://git@gitlab.mff.cuni.cz/teaching/nswi177/2025/project-LOGIN
nswi177-jinja-templater --help
And for the CI we expect that your project would have a job unittests
running
the Python tests.
The CI should use the python:3.13-alpine
image and should install the
versions from requirements.txt
file.
We expect that pytest
(and perhaps other test-related libraries) will
not be mentioned in the requirements.txt
but rather inside
requirements-dev.txt
file.
You will notice that the tests are not passing as some of the Jinja filters are not implemented.
Do not worry, though. Your coworker Alice already implemented them in her
branch in her repository gitolite3@linux.ms.mff.cuni.cz:templater-alice
.
Merge her implementation into your repository to get the full implementation.
If you do everything correctly, your CI job log would look like this (we have blurred the used commands for obvious reasons).
Then you will extend the CI to also execute the BATS tests.
We expect that you will add a new job called integrationtests
that installs
the package (so that the nswi177-jinja-templater
command is available) and
run all the BATS files in the tests
subdirectory
(recall that simple pip install .
should work like a charm).
For unittests
you install dependencies from requirements.txt
for best
reproducibility while for integrationtests
we install the whole package,
thus usually with relaxed requirements on the exact versions of the dependencies.
You will need to install bats
via apk add
first (it is okay to install
this package on every CI run).
Note that the current implementation in common.bash
invokes the program via
call to env PYTHONPATH=src python3 -m nswi177.templater
– change this to
call nswi177-jinja-templater
instead.
You will also need to replace --kill-after
switch for the timeout
command
to plain -k
as the long variant is not supported in Alpine.
The amount of BATS tests is quite low so you should also merge the work of your co-workers Bob and Charlie into your repository. Again, perform a normal merge and not a rebase when integrating their work.
Bob has his repository at gitolite3@linux.ms.mff.cuni.cz:templater-bob
while
Charlie put his copy to our website to
https://d3s.mff.cuni.cz/f/teaching/nswi177/202425/templater-charlie.git
.
In case of conflicts make sure you resolve them correctly – you certainly do not want to drop any of the tests unless they are the same.
Submission and grading
Submit your solution into the project-LOGIN
repository on GitLab.
We will check that the project can be installed via
pip install git+https://gitlab.../project-LOGIN/
and that your CI configuration
is correct (after all the merges your jobs should be in the green).
We will check that the Python code can be executed after
pip install -r requirements.txt
via python3 -m src.nswi177.templater
(or via python -m nswi177.templater
if the package itself is also installed)
and that the Pytests can be run after installing from requirements-dev.txt
.
When you copy fragments from sites such as StackOverflow we expect
you will comment them directly in the appropriate sources, communication with
AI-driven sites should be stored into exam/project/ai.log
file in your normal
submission repository (student-LOGIN
), again a plain text file with clearly
marked portions with your input and with the answers.
The submission deadline is 2025-06-01.