diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0aa4c1b --- /dev/null +++ b/.gitignore @@ -0,0 +1,93 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +*.pyc diff --git a/README.md b/README.md index e8097d4..54ad06f 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ HR
HR
- Scenarios
Scenarios
+ Challenges
Challenges
@@ -4929,24 +4929,26 @@ you can show how you'd be able to mitigate that problem. Not only this will tell you what is expected from you, it will also provide big hint on the type of work you are going to do in the first months of your job. -## Scenarios +## Challenges -Scenarios are questions which don't have verbal answer and require you one of the following: +Challenges require you one of the following: * Set up environments * Write scripts * Design and/or develop infrastructure projects + * Fix existing applications -These questions usually given as an home task to the candidate and they can combine several topics together. -Below you can find several scenario questions: +These type of questions usually given as an home task to the candidate and they can combine several topics together. +Below you can find several challenges: -* [Writing a Dockerfile and running a container](scenarios/write_dockerfile_run_container.md) -* [Elasticsearch & Kibana on AWS](scenarios/elk_kibana_aws.md) -* [Ansible, Minikube and Docker](scenarios/ansible_minikube_docker.md) -* [Cloud Slack bot](scenarios/cloud_slack_bot.md) -* [Jenkins: writing scripts](scenarios/jenkins_scripts.md) -* [Jenkins: writing pipelines](scenarios/jenkins_pipelines.md) -* [CI for open source project](scenarios/ci_for_open_source_project.md) +* [Writing a Dockerfile and running a container](challenges/write_dockerfile_run_container.md) +* [Elasticsearch & Kibana on AWS](challenges/elk_kibana_aws.md) +* [Ansible, Minikube and Docker](challenges/ansible_minikube_docker.md) +* [Cloud Slack bot](challenges/cloud_slack_bot.md) +* [Jenkins: writing scripts](challenges/jenkins_scripts.md) +* [Jenkins: writing pipelines](challenges/jenkins_pipelines.md) +* [CI for open source project](challenges/ci_for_open_source_project.md) +* [Flask, Containers and CI](challenges/flask_container_ci/README.md) ## Credits diff --git a/scenarios/ansible_minikube_docker.md b/challenges/ansible_minikube_docker.md similarity index 100% rename from scenarios/ansible_minikube_docker.md rename to challenges/ansible_minikube_docker.md diff --git a/scenarios/ci_for_open_source_project.md b/challenges/ci_for_open_source_project.md similarity index 100% rename from scenarios/ci_for_open_source_project.md rename to challenges/ci_for_open_source_project.md diff --git a/scenarios/cloud_slack_bot.md b/challenges/cloud_slack_bot.md similarity index 100% rename from scenarios/cloud_slack_bot.md rename to challenges/cloud_slack_bot.md diff --git a/scenarios/elk_kibana_aws.md b/challenges/elk_kibana_aws.md similarity index 100% rename from scenarios/elk_kibana_aws.md rename to challenges/elk_kibana_aws.md diff --git a/challenges/flask_container_ci/README.md b/challenges/flask_container_ci/README.md new file mode 100644 index 0000000..d4fd190 --- /dev/null +++ b/challenges/flask_container_ci/README.md @@ -0,0 +1,34 @@ +Your mission, should you choose to accept it, involves fixing the app in this directory, containerize it and set up a CI for it. +Please read carefully all the instructions. + +## Installation + +1. Create a virtual environment with `python3 -m venv challenge_venv` +2. Activate it with `source challenge_venv/bin/activate` +3. Install requirements.txt `pip install -r requirements.txt` + +## Run the app + +1. Run `export FLASK_APP=app/app.py` +1. To run the app execute `flask run`. If it doesn't works, fix it + + +## Containers + +Using Docker or Podman, containerize the flask app so users can run the following two commands: + +``` +docker build -t app:latest /path/to/Dockerfile +docker run -d -p 5000:5000 app +``` + +1. You can use any image base you would like +2. Containrize only what you need for running the application, nothing else. + +## CI + +Great, now that we have a working app and also can run it in a container, let's set up a CI for it so it won't break again in the future + +1. The CI should run the tests in the app directory +2. There should be some kind of test for the Dockerfile you wrote +2. Add additional unit test (or another level of tests) diff --git a/challenges/flask_container_ci/app/app.py b/challenges/flask_container_ci/app/app.py new file mode 100644 index 0000000..140a6cd --- /dev/null +++ b/challenges/flask_container_ci/app/app.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python +# coding=utf-8 + +from flask import Flask +app = Flask(__name__) + +@app.route('/') +def hello_world(): + return 'Hello, World!' diff --git a/challenges/flask_container_ci/app/config.py b/challenges/flask_container_ci/app/config.py new file mode 100644 index 0000000..fffb65a --- /dev/null +++ b/challenges/flask_container_ci/app/config.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python +# coding=utf-8 + +import os + +basedir = os.path.abspath(os.path.dirname(__file__)) + +SECRET_KEY = 'shhh' +CSRF_ENABLED = True + +SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'app.db') + diff --git a/challenges/flask_container_ci/app/tests.py b/challenges/flask_container_ci/app/tests.py new file mode 100644 index 0000000..1aa522b --- /dev/null +++ b/challenges/flask_container_ci/app/tests.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +# coding=utf-8 + +import os +import unittest + +from config import basedir +from app import app +from app import db + +class TestCase(unittest.TestCase): + + def setUp(self): + app.config['TESTING'] = True + app.config['WTF_CSRF_ENABLED'] = False + app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'test.db') + self.app = app.test_client() + db.create_all() + + def tearDown(self): + db.session.remove() + db.drop_all() + +if __name__ == '__main__': + unittest.main() diff --git a/scenarios/jenkins/scripts/jobs_with_string.groovy b/challenges/jenkins/scripts/jobs_with_string.groovy similarity index 100% rename from scenarios/jenkins/scripts/jobs_with_string.groovy rename to challenges/jenkins/scripts/jobs_with_string.groovy diff --git a/scenarios/jenkins/scripts/old_builds.groovy b/challenges/jenkins/scripts/old_builds.groovy similarity index 100% rename from scenarios/jenkins/scripts/old_builds.groovy rename to challenges/jenkins/scripts/old_builds.groovy diff --git a/scenarios/jenkins_pipelines.md b/challenges/jenkins_pipelines.md similarity index 100% rename from scenarios/jenkins_pipelines.md rename to challenges/jenkins_pipelines.md diff --git a/scenarios/jenkins_scripts.md b/challenges/jenkins_scripts.md similarity index 100% rename from scenarios/jenkins_scripts.md rename to challenges/jenkins_scripts.md diff --git a/scenarios/solutions/elk_kibana_aws.md b/challenges/solutions/elk_kibana_aws.md similarity index 100% rename from scenarios/solutions/elk_kibana_aws.md rename to challenges/solutions/elk_kibana_aws.md diff --git a/scenarios/write_dockerfile_run_container.md b/challenges/write_dockerfile_run_container.md similarity index 100% rename from scenarios/write_dockerfile_run_container.md rename to challenges/write_dockerfile_run_container.md diff --git a/scripts/count_questions.sh b/scripts/count_questions.sh index 97b7df0..9ef8593 100755 --- a/scripts/count_questions.sh +++ b/scripts/count_questions.sh @@ -2,4 +2,4 @@ # We dont care about non alphanumerics filenames so we just ls | grep to shorten the script. -echo $(( $(ls ./scenarios/ | grep ".*md" -c) + $(grep \ -c README.md) )) +echo $(( $(ls ./challenges/ | grep ".*md" -c) + $(grep \ -c README.md) ))