Saturday, October 29, 2022

What is GitHub?


Agenda

Why use Version (Source) Control Systems

What are Gitand GitHub

Basic GitCommands

Fundamentals of GitHub

Using GitHub in Project Implementation 


Why version control?

 Scenario 1:

Your program is working

You change “just one thing”

Your program breaks

You change it back

Your program is still broken--why?

Has this ever happened to you?


Why version control? (part 2)

Your program worked well enough yesterday

You made a lot of improvements last night...

...but you haven't gotten them to work yet

You need to turn in your program now

Has this ever happened to you?


Version control for teams

Scenario:

You change one part of a program--it works

Your co-worker changes another part--it works

You put them together--it doesn’t work

Some change in one part must have broken something in the other part

What were all the changes?



Teams (part 2)

Scenario:

You make a number of improvements to a class

Your co-worker makes a number of differentimprovements to the sameclass

How can you merge these changes?


Version control systems

A version control system (often called a source code control system) does these things:

Keeps multiple (older and newer) versions of everything (not just source code)

Requests comments regarding every change

Allows “check in” and “check out” of files so you know which files someone else is working on

Displays differences between versions


Benefits of version control

For working by yourself:

Gives you a “time machine” for going back to earlier versions

Gives you great support for different versions (standalone, web app, etc.) of the same basic project

For working with others:

Greatly simplifies concurrent work, merging changes


What are Gitand GitHub

Gitis a free and open source distributedversion control systemdesigned to handle everything from small to very large projects with speed and efficiency

# GitHub is aweb-basedGitrepositoryhosting service, which offers all of the distributed revision control and source code management (SCM) functionality of Gitas well as adding its own features.


How to setup Gitand GitHub

 Download and install the latest version of GitHub Desktop. This will automatically install Gitand keep it up-to-date for you.

https://help.github.com/articles/set-up-git/




BASIC GIT COMMANDS

Introduce yourself to Git

On your computer, open theGitShellapplication.

Enter these lines (with appropriate changes):

gitconfig--global user.name "John Smith"

gitconfig--global user.emailjsmith@seas.upenn.edu

You only need to do this once

If you want to use a different name/email address for a particular project, you can change it for just that project

cdto the project directory

Use the above commands, but leave out the --global



The repository

 Your top-level working directory contains everything about your project

 The working directory probably contains many subdirectories—source code, binaries, documentation, data files, etc.

 One of these subdirectories, named .git, is your repository

 At any time, you can take a “snapshot” of everything (or selected things) in your project directory, and put it in your repository

 This “snapshot” is called a commit object

 The commit object contains (1) a set of files, (2) references to the “parents” of the commit object, and (3) a unique “SHA1” name

 Commit objects do notrequire huge amounts of memory

 You can work as much as you like in your working directory, but the repository isn’t updated until you commitsomething


init and the .git repository

 When you said gitinitin your project directory, or when you cloned an existing project, you created a repository

 The repository is a subdirectory named .gitcontaining various files

 The dot indicates a “hidden” directory

 You do notwork directly with the contents of that directory; various gitcommands do that for you


Making commits

 You do your work in your project directory, as usual

 If you create new files and/or folders, they are not trackedby Gitunless you ask it to do so

 gitadd newFile1 newFolder1 newFolder2 newFile2

 Committing makes a “snapshot” of everything being tracked into your repository

 A message telling what you have done is required

 gitcommit –m “Uncrevulatedthe conundrum bar”

 gitcommit

 This version opens an editor for you the enter the message

 To finish, save and quit the editor

 Format of the commit message

 One line containing the complete summary

 If more than one line, the second line must be blank


Commits and graphs

 A commitis when you tell gitthat a change (or addition) you have made is ready to be included in the project

 When you commit your change to git, it creates a commit object

 A commit object represents the complete state of the project, including all the files in the project

 The very first commit object has no “parents”

 Usually, you take some commit object, make some changes, and create a new commit object; the original commit object is the parent of the new commit object

 Hence, most commit objects have a single parent

 You can also mergetwo commit objects to form a new one

 The new commit object has two parents

Hence, commit objects forms a directed graph

Gitis all about using and manipulating this graph


Commit messages

In git, “Commits are cheap.” Do them often.

When you commit, you must provide a one-line message stating what you have done

Terrible message: “Fixed a bunch of things”

Better message: “Corrected the calculation of median scores”

Commit messages can be very helpful, to yourself as well as to your team members

You can’t say much in one line, so commit often


Typical workflow

 git status

 See what Gitthinks is going on

 Use this frequently!

 Work on your files

git add your editfiles

git commit –m “What I did”




More Commands: Don’t Get Scared.

                                     GitHub Desktop can Help You





What is GitHub?

GitHub is a Software as a service (SaaS) platform from Microsoft that provides Git-based repositories and DevOps tooling for developing and deploying software.

It has a wide range of integrations with other leading tools.

Git : is a version Control system git also its is Distribued Version Control System.

Two types of version control  system.

1) Centralize Version Control System 








2) Distributed Version Control System 
















What does GitHub provide?

GitHub provides a range of services for software development and deployment.

  • Codespaces: Provides a cloud-hosted development environment (based on Visual Studio Code) that can be operated from within a browser or external tools. Eases cross-platform development.
  • Repos: Public and private repositories based upon industry-standard Git commands.
  • Actions: Allows for the creation of automation workflows. These workflows can include environment variables and customized scripts.
  • Packages: The majority of the world's open-source projects are already contained in GitHub repositories. GitHub makes it easy to integrate with this code and with other third-party offerings.
  • Security: Provides detailed code scanning and review features, including automated code review assignment.



What is GitHub Codespaces?

Codespaces is a cloud-based development environment that GitHub hosts. It is essentially an online implementation of Visual Studio Code.

Codespaces allows developers to work entirely in the cloud.

Codespaces even will enable developers to contribute from tablets and Chromebooks.

Because it is based on Visual Studio Code, the development environment is still rich with:

  • Syntax highlighting.
  • Autocomplete.
  • Integrated debugging.
  • Direct Git integration.

Developers can create a codespace (or multiple codespaces) for a repository. Each codespace is associated with a specific branch of a repository.

       


            

FUNDAMENTALS OF GITHUB



Introduce yourself to GitHub

Register on GitHub

 https://github.com/


Authenticating to GitHub Desktop

 https://help.github.com/desktop/guides/getting-started/authenticating-to-github/


Configuring Gitfor GitHub Desktop

 https://help.github.com/desktop/guides/getting-started/configuring-git-for-github-desktop/


Create or add a repository to GitHub

 Create a new repository on GitHub

https://help.github.com/articles/create-a-repo/


 From GitHub Desktop, then Publish to GitHub

https://help.github.com/desktop/guides/contributing/adding-a-repository-from-your-local-computer-to-github-desktop/


 Remember to Publish, otherwise your repository would not appear on the GitHub website.



Commit your changes on GitHub

 From GitHub Website

https://help.github.com/articles/create-a-repo/


 From GitHub Desktop

https://help.github.com/desktop/guides/contributing/committing-and-reviewing-changes-to-your-project/



Creating a branch for your work

 A branch is a parallel version of the main line of development in the repository, or the default branch (usually master). Use branches to

> Develop features

> Fix bugs

> Safely experiment with new ideas

 From the GitHub Website

 https://help.github.com/articles/creating-and-deleting-branches-within-your-repository/

 From the GitHub Desktop

https://help.github.com/desktop/guides/contributing/creating-a-branch-for-your-work/



Synchronizing your branch

 As commits are pushed to your project on GitHub, you can keep your local copy of the project in sync with the remote repository.

https://help.github.com/desktop/guides/contributing/syncing-your-branch/


Viewing the history of your commits

 When you click a commit on the commit timeline, you can see more details about the commit, including a diff of the changes the commit introduced.

 Each commit shows:

>The commit message 

>The time the commit was created

>The committer's username and profile photo (if available)

> The commit's SHA-1 hash (the unique ID)


Revert your commit

If you change your mind about a commit after you create it, you can revert the commit.

 When you revert to a previous commit, the revert is also a commit. In addition, the original commit remains in the repository's history.

 https://help.github.com/desktop/guides/contributing/reverting-a-commit/




Fork & Pull: A Collaborative model

A fork is a copy of a repository that you manage. Forks let you make changes to a project without affecting the original repository. You can fetch updates from or submit changes to the original repository with pull requests.

 A great example of using forks to propose changes is for bug fixes. Rather than logging an issue for a bug you've found, you can:

 Fork the repository.

 Make the fix.

 Submit apull requestto the project owner.



Using GitHub in Project Implementation

In the section of project implementation in your project report, you may describe:

 How you use GitHub in your project.

 How version control helps your quality management.

 How you collaborate with your teammate in GitHub.



References

Some content of the slides are adapted from

https://help.github.com/desktop/guides/getting-started/

https://help.github.com/desktop/guides/contributing/

https://help.github.com/categories/collaborating/

http://www.cis.upenn.edu/~matuszek/cit591-2012/Lectures/git.ppt



Full course on YouTube

https://youtu.be/fNYwmqKvW4g?si=CnkYZeHR3Suzb3G3

Friday, October 28, 2022

Whate is Devops

 What is Devops ?

The Term Devops is a combination of two words i.e Development And Operations.

Devops is a  Methodology that allows a single team to manage the entire application development , testing deployment and operations.

the objective of devops is to shorten the system's development life cycle.

Devops is a software development apprach through which superior Quality   Software can be developed quickly and with more  Reliability.

The contraction of "Dev" and "Ops" refers to replacing siloed Development and Operations. The idea is to create multidisciplinary teams that now work together with shared and efficient practices and tools. Essential DevOps practices include agile planning, continuous integration, continuous delivery, and monitoring of applications. DevOps is a constant journey.


                                                            

     Software development lifecycle 





SDLC Life Cycle How to work 

DEVELOPMENT                                               OPERATIONS  


 Plan                                                                      Deploy 

Code                    INTEGRATION                    Maintenance 

Build                                                                     Monitoring 

Test 

    

                                                               
                                                        


Understand your cycle time

Let us start with a basic assumption about software development. We will describe it with the OODA (Observe, Orient, Decide, Act) loop. Originally designed to keep fighter pilots from being shot out of the sky, the OODA loop is an excellent way to think about staying ahead of your competitors. You start with observing business, market, needs, current user behavior, and available telemetry data. Then you orient with the enumeration of options for what you can deliver, perhaps with experiments. Next, you decide what to pursue, and you act by delivering working software to real users. You can see all occurring in some cycle time.




What is Azure DevOps?

Completed100 XP

Azure DevOps is a Software as a service (SaaS) platform from Microsoft that provides an end-to-end DevOps toolchain for developing and deploying software.

It also integrates with the most-leading tools on the market and is an excellent option for orchestrating a DevOps toolchain.

What does Azure DevOps provide?

Azure DevOps includes a range of services covering the complete development life cycle.

  • Azure Boards: agile planning, work item tracking, visualization, and reporting tool.
  • Azure Pipelines: a language, platform, and cloud-agnostic CI/CD platform-supporting containers or Kubernetes.
  • Azure Repos: provides cloud-hosted private git repos.
  • Azure Artifacts: provides integrated package management with support for Maven, npm, Python, and NuGet package feeds from public or private sources.
  • Azure Test Plans: provides an integrated planned and exploratory testing solution.

Also, you can use Azure DevOps to orchestrate third-party tools.






















Azure CLI and How To Install The Azure CLI

 

What is the Azure CLI?

Completed

The Azure CLI is a command-line program to connect to Azure and execute administrative commands on Azure resources. It runs on Linux, macOS, and Windows, and allows administrators and developers to execute their commands through a terminal or command-line prompt (or script!) instead of a web browser. For example, to restart a virtual machine (VM), you would use the following command:


Azue CLI 

az vm restart -g MyResourceGroup -n MyVm


How to install the Azure CLI

On both Linux and macOS, you'll use a package manager to install the Azure CLI. The recommended package manager differs by OS and distribution:

  • Linux: apt-get on Ubuntu, yum on Red Hat, and zypper on OpenSUSE
  • Mac: Homebrew

The Azure CLI is available in the Microsoft repository, so you'll first need to add that repository to your package manager.

On Windows, you can install the Azure CLI by downloading and running an MSI file.


Using the Azure CLI in scripts

If you want to use the Azure CLI commands in scripts, you need to be aware of any issues around the "shell" (or environment) used for running the script. For example, in a bash shell, you'll use this syntax when setting variables:          

Azure CLI

variable="value"

variable=integer    

If you use a PowerShell environment for running Azure CLI scripts, you'll use this syntax for variables:

You must install the Azure CLI before you can use it to manage Azure resources from a local computer. The installation steps vary for Windows, Linux, and macOS, but once installed, the commands are common across platforms.


Install and run the Azure CLI

Windows

Here, you'll install the Azure CLI on Windows using the MSI installer.

  1. Go to https://aka.ms/installazurecliwindows, and in the browser security dialog box, click Run or Open file.
  2. In the installer, accept the license terms, then click Install.
  3. In the User Account Control dialog, select Yes.

Running the Azure CLI

You run the Azure CLI by opening a bash shell (Linux and macOS), or from the command prompt or PowerShell (Windows).

  1. Start the Azure CLI and verify your installation by running the version check.

        Azure CLI
       az --Version

You've set up your local machines to administer Azure resources with the Azure CLI. You can now use the Azure CLI locally to enter commands or execute scripts. The Azure CLI will forward your commands to the Azure datacenters where they will run inside your Azure subscription.


Work with the Azure CLI

The Azure CLI lets you type commands and execute them immediately from the command line. Recall that the overall goal in the software development example is to deploy new builds of a web app for testing. Let's talk about the sorts of tasks you can do with the Azure CLI.


What Azure resources can be managed using the Azure CLI?

The Azure CLI lets you control nearly every aspect of every Azure resource. You can work with resource groups, storage, virtual machines, Azure Active Directory (Azure AD), containers, machine learning, and so on.

Commands in the CLI are structured in groups and subgroups. Each group represents a service provided by Azure, and the subgroups divide commands for these services into logical groupings. For example, the storage group contains subgroups including accountblob, and queue.

So, how do you find the particular commands you need? One way is to use az find, the AI robot that uses the Azure documentation to tell you more about commands, the CLI and more.


Example: find the most popular commands related to the word blob.


Azure CLI
az find blob

Example: Show me the most popular commands for an Azure CLI command group, such as az vm.
Azure CLI
az find "az vm create"


If you already know the name of the command you want, the --help argument for that command will get you more detailed information on the command, and for a command group, a list of the available subcommands. So, with our storage example, here's how you can get a list of the subgroups and commands for managing blob storage:

azure CLI
az storage blob --help

How to create an Azure resource

When you're creating a new Azure resource, there are typically three steps: connect to your Azure subscription, create the resource, and verify that creation was successful. The following illustration shows a high-level overview of the process.


Connect

Since you're working with a local install of the Azure CLI, you'll need to authenticate before you can execute Azure commands, by using the Azure CLI login command.

Azure CLI

az login

The Azure CLI will typically launch your default browser to open the Azure sign-in page. If this doesn't work, follow the command-line instructions and enter an authorization code at https://aka.ms/devicelogin.

After a successful sign-in, you'll be connected to your Azure subscription.


Create

You'll often need to create a new resource group before you create a new Azure service, so we'll use resource groups as an example to show how to create Azure resources from the CLI.

The Azure CLI group create command creates a resource group. You must specify a name and location. The name must be unique within your subscription. The location determines where the metadata for your resource group will be stored. You use strings like "West US", "North Europe", or "West India" to specify the location; alternatively, you can use single word equivalents, such as westus, northeurope, or westindia. The core syntax is:


Azure  CLI

az group create --name <name> --location <location>



Verify

For many Azure resources, the Azure CLI provides a list subcommand to view resource details. For example, the Azure CLI group list command lists your Azure resource groups. This is useful to verify whether the resource group was successfully created:

azure CLI

az group list


To get a more concise view, you can format the output as a simple table:

Azure CLI

az group list -- output table







Python