Automatizácia
Základy softvérového inžinierstva
Sergej Chodarev (sergejx.net)
We are programmers
Our job is to automate
Don't Use Manual Procedures
A computer will execute the same instructions, in the same order, time after time.
— The Pragmatic Programmer
Shell Programming
- sequence of commands
- variables
- conditions
- loops
Example
#!/bin/sh
if [ ! -e pyvenv ]; then
python3 -m venv pyvenv
fi
pyvenv/bin/pip install --upgrade --requirement=requirements.txt
pyvenv/bin/it4kt-builder serve --open-browser "$@"
Shebang #!
-
Put at first line:
#!/bin/sh
-
Make it executable:
chmod +x my-script.sh
Different Languages
#!/bin/bash
#!/usr/bin/env python3
#!/usr/bin/env ruby
make
- classical automation tool
- files based
Makefile
targets: prerequisites
recipe
recipe…
Running
make target
- builds prerequisites
- compares timestamps
- rebuilds if prerequisites are newer
Compilers and Interpreters
- C:
gcc
, clang
- Java:
javac
(compiler), java
(virtual machine)
- JavaScript:
node
- TypeScript:
tsc
python
, ruby
Linters
- static analysers
- finding bugs, stylistic issues, suspicious constructs
lint
– original linter for C (1978)
- C/C++:
cppcheck
- Java:
checkstyle
- JavaScript:
eslint
- Python:
ruff
- Ruby:
rubocop
Development Process
git clone ...
cd project_dir
- some setup command
- start coding
- run compiler, linter, tests
Package Management
- JavaScript:
npm
- Python:
pip
, virtualenv
, uv
- Ruby:
gem
, bundler
- Java:
mvn
, gradle
Dependencies
- reproducible builds
- fixed version numbers
- “lock” file
package-lock.json
Pipfile.lock
requirements.txt
- etc.
Dependencies
- not only libraries
- tools
- operating system
Option: Virtualization
- virtual machine for each application
- own OS, disk, network settings
- overhead
Containers
Containers
Containers — standardized units for development, shipment and deployment
- isolate from the environment
Docker
- de-facto standard for containerization
- kernel-level virtualization
- running process
- isolated from the rest of the system
- separate environment and filesystem
- share only Linux kernel