From 6cf269c441f0440484ec8938cf8c97363564394c Mon Sep 17 00:00:00 2001 From: Zouhair AMAZZAL Date: Tue, 13 Dec 2022 11:55:37 +0100 Subject: [PATCH] DEV-3896 feat(hello_devops) add subject and tests for into exercise to teach student how to push in gitea repo --- sh/tests/hello_devops_test.sh | 24 ++++++++++ sh/tests/solutions/hello_devops.sh | 3 ++ subjects/devops/hello_devops/README.md | 61 ++++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100755 sh/tests/hello_devops_test.sh create mode 100755 sh/tests/solutions/hello_devops.sh create mode 100644 subjects/devops/hello_devops/README.md diff --git a/sh/tests/hello_devops_test.sh b/sh/tests/hello_devops_test.sh new file mode 100755 index 000000000..62699e274 --- /dev/null +++ b/sh/tests/hello_devops_test.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Unofficial Bash Strict Mode +set -euo pipefail +IFS=' +' + +FILENAME="student/hello_devops.sh" + +# True if FILE exists and is a regular file +if [ -f ${FILENAME} ]; then + # FILE exists and it's not empty + if [ -s ${FILENAME} ]; then + submitted=$(bash $FILENAME) + expected=$(bash solutions/hello_devops.sh) + diff <(echo "$submitted") <(echo "$expected") | cat -t + else + echo "The file exist but is empty" + exit 1 + fi +else + echo "File does not exist" + exit 1 +fi diff --git a/sh/tests/solutions/hello_devops.sh b/sh/tests/solutions/hello_devops.sh new file mode 100755 index 000000000..c7f4c0bdc --- /dev/null +++ b/sh/tests/solutions/hello_devops.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +echo "Hello $USERNAME!" diff --git a/subjects/devops/hello_devops/README.md b/subjects/devops/hello_devops/README.md new file mode 100644 index 000000000..878d40593 --- /dev/null +++ b/subjects/devops/hello_devops/README.md @@ -0,0 +1,61 @@ +## Introduction + +### Instructions + +#### 1- get-ready + +Create in your [Gitea]() account the repository named `((ROOT))`. + +This repository will be the folder where all the exercises must be uploaded. + +Once created, clone that repository on your desktop. + +To do so, open a Unix shell (e.g. Git Bash on Windows), you are going to type commands in it. + +First, tell Git to remember your password (like a web browser would): + +``` +git config --global credential.helper store +``` + +If your username was `01-user` this is the command that will need to be used: + +``` +git clone https://((DOMAIN))/git/01-user/((ROOT)).git +``` + +This command needs to be adapted with **your own username**. + +#### 2- set + +Once the repository is created, use you code editor to write your first shell script called `hello_devops.sh` + +When executed, this script must print `Hello 01-user!`, where `01-user` is your username. + +##### Usage + +If the username is `01-user`: + +```console +$ bash hello_devops.sh +Hello 01-user! +$ +``` + +#### 3- go-say-hello + +After that the `hello_devops.sh` is executing correctly, it needs to be uploaded to the repository with the following commands: + +1. `git add hello_devops.sh` +2. `git commit -m "My very first commit"` +3. `git push` + +Once these steps are applied, the file can now be submitted for grading on the platform by clicking on the "RUN INTRODUCTION TEST" button. + +This action will run the tests on your submitted `hello_devops.sh` file. + +### Recommendation + +Videos designed to give **hints** are assigned. It is strongly suggested to watch them as you go. + +There are subtitles available in French and English.