Skip to content

Latest commit

 

History

History
175 lines (131 loc) · 5.23 KB

README.md

File metadata and controls

175 lines (131 loc) · 5.23 KB

Step 0

Pre-Commit Hooks

Run the below 2 codes right after clone this repo from your terminal.

pip install -r common.txt
pre-commit install

The steps ensure to work pre commit hooks before you push the code to the repo. By running "pre-commit install", it executes .pre-commit-config.yaml file, then, the yaml file sets up the git hook scripts. After the command, 'pre-commit' runs automatically on "git commit"

pre-commit

The picture is actually running for this repo. So, the file checks 7 points (6 ids under the hooks and black) Once, you change code on this repo and commit the changes through
  • git commit -m 'First Commit' on terminal
  • Click the "Commit" panel (the left side on Pycharm)

Either way, it runs automatically like the below figure.

pre-commit-results

More information about
pre-commit: https://pre-commit.com/
black: https://github.com/psf/black

*additional material for code convention:
Docstring: https://peps.python.org/pep-0257/
Type Hints: https://peps.python.org/pep-0484/
Unit Test: https://docs.python.org/3/library/unittest.html and start with test_

Step 1

Jenkins

Before downloading, Jenkins should check your PC system.
If you don't have JAVA, you need to download JAVA and Git Bah.
Then you check [System properties -> Environment Variables -> path], System variables has JAVA-HOME and right Path condition.

How to run Jenkins at localhost

  • Download Jenkins
  1. Run the below code from your terminal (Pycharm) where Jenkins is located. User\Desktop(Jenkins folder location)
java -jar jenkins.war
  1. Open browser, Type below port number for Jenkins
localhost:8080

When using Jenkins, do steps 1 and 2 every time.

How to ues Jenkins

When you open the dashboard, click New Item

Jenkins

Look at the picture above

  • An item name = your project name
  • Click Pipeline

Next step is What do you want to build.

Please follow the picture below

Jenkins-configure1

What do you want to run

  • Set * * * * * (every minute) run

Jenkins-configure2

"Make Pipeline script and explanation of the syntax"

  • Click try sample "Pipeline"
  • stage is title
  • echo is comment

Jenkins-configure3

Click "Build Now" you got the picture below

stageView

If the build is red, it's a failure.
You should check the "#number" -> "console output". Then fix your code update and run it again.

Next step, click the "Pipeline Syntax"

  • Checkout: Check out from version control
  • SCM -> Git
  • Repositories -> Git clone URL
  • Credentials -> private access ID & password
  • Save it, get script
  • bat -> for windows command (This time, build docker)

pipline

This time, created three builds.

  • First is "check it" for connect Git success.
  • Second is "build" for create Git clone.
  • Third is "unit test" for run unit test command.

stageview2

More information about
CI/CD :https://www.simplilearn.com/tutorials/devops-tutorial/continuous-delivery-and-continuous-deployment

Step 2

Docker

Docker is a tool for running your applications inside containers and similar in concept to virtual machines (can be run on any OS).
Containers are great for continuous integration and continuous delivery (CI/CD) workflows.

  • Download and install Docker

You should create Dockerfile on your Pycharm.
Docker file name MUST be 'Dockerfile'.

  • Dockerfile works top to bottom
  • Dockerfile reserved word are the picture below

docker

Created Dockerfile is the picture below

dockerfile

How to run docker

  • Name and optionally a tag in the name:tag format (latest = NEW)
docker build -t test:latest .
docker images

An image is a read-only template with instructions for creating a Docker container.

docker images

When you push your code to the master branch on GitHub, GitHub will call Jenkins, and Jenkins runs Docker for unit testing through the above settings.

images

More information about
Docker: https://docs.docker.com/get-started/overview/