Giter Club home page Giter Club logo

week1-devops's Introduction

Week 1 - Project

Goal

To Establish a Robust and Reliable Development process by settting version control using Git, implementing comprehensive Unit Tests, and setting up effective workflows to ensure that only properly tested code is merged from other branches into the Master branch.

Requirements


Link to setup Python 3.9 - https://www.python.org/downloads/

Link to setup Git the first time - https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup

Use a Editor of your choice

Link to get pip3 - https://pip.pypa.io/en/stable/installation/

Step 1 - Get the inital start code onto your system

Git clone initial code from this Github Repo - https://github.com/vj-m/week1-devops/tree/initial_starter_code

git clone [email protected]:vj-m/week1-devops.git

Step 2 - Add Unit Tests

def test_add():
    assert add(1,1) == 2

def test_sub():
    assert sub(1,1) == 0

def test_mul():
    assert mul(1,1) == 1

def test_div():
    assert div(2,1) == 2

Step 3 - Create a workflow

1.) Create a directory called .github/workflows within the directory containing .git 2.) And create a workflow ‘YAML’ file, let's call it ci_cd_wf.yml 3.) Git add and push changes (This automatically invokes the Git actions and sets up the CI/CD Pipeline which on push to the master branch)

name : test

on:
  push:
    branches:
      - main

jobs:
  test:
    runs-on : ubuntu-latest

    steps:
      - name: Check out repo code
        uses: actions/checkout@v3

      - name: Setup Python
        uses: actions/setup-python@v3
        with:
          python-version: "3.x"

      - name: Install Dependencies
        run: |
          python -m pip install -r requirements.txt
      - name: Run tests
        run: |
          python -m pytest calculator.py

Step 4 - Check our Gitflow with a new branch


1.) Create a new feature branch to check a case where the push to master or PR fails by making a purposeful mistake in the code to fail a test

2.) Create a new feature branch called test

def test_add():
    assert add(1,1) == 0


We have changed the test_add method to assert a False

3.) Git add, push and commit

Step 5 - Fix all the errors to make a successful build


1.) Change back the test_add function

2.) Add, commit, and push the new changes to the master branch again

As the first week of the project comes to a close, it's important to reflect on the progress made so far.

Future Scope Recommendations -


Now that the initial code is in place, it's time to focus on improving its quality. One way to do this is to add more checks such as linters, code coverage, and code quality checks.

Another recommended step is to add 'runs on' actions like a pull request. This allows for a more streamlined workflow and can help ensure that the code changes are thoroughly tested before being merged into the main branch.

As you move forward into Week 2 of the project, keep these next steps in mind. By continually improving the quality of your code, you'll be setting yourself up for success in the long run.

Appendix


This repository has three branches -

'main' branch contains the file code for the project

'initial_starter_code' contains the inital code to start with

'test' - The state of the project with a wrong test added for reference - this is supposed to fail the merge to master process in our workflow


week1-devops's People

Contributors

jassassin68 avatar vj-m avatar yudhiesh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.