{"id":19140088,"url":"https://github.com/circleci/lunch-n-learn","last_synced_at":"2025-04-19T10:32:28.255Z","repository":{"id":25965762,"uuid":"105053568","full_name":"circleci/lunch-n-learn","owner":"circleci","description":null,"archived":true,"fork":false,"pushed_at":"2024-02-05T22:19:18.000Z","size":2322,"stargazers_count":10,"open_issues_count":3,"forks_count":27,"subscribers_count":64,"default_branch":"master","last_synced_at":"2025-02-22T19:12:31.236Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/circleci.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-09-27T18:21:21.000Z","updated_at":"2024-10-28T16:47:19.000Z","dependencies_parsed_at":"2024-02-05T23:31:22.962Z","dependency_job_id":"cf789e99-9381-4129-ac6a-a816c1b1e706","html_url":"https://github.com/circleci/lunch-n-learn","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circleci%2Flunch-n-learn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circleci%2Flunch-n-learn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circleci%2Flunch-n-learn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circleci%2Flunch-n-learn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/circleci","download_url":"https://codeload.github.com/circleci/lunch-n-learn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249675722,"owners_count":21309339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T07:16:13.140Z","updated_at":"2025-04-19T10:32:26.890Z","avatar_url":"https://github.com/circleci.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# CircleCI Lunch \u0026 Learn\n\u003cimg src=\"images/continuous-integration-with-circle-ci.png\"\u003e\n\n# CircleCI 101 - Lunch \u0026 Learn  \u003cimg src=\"images/lunch-learn-brown-bag-apple-notebooks.jpg\" width=\"50\" height=\"50\" /\u003e\n\n## Prereqs \n\n* Some basic knowledge of git and an existing GitHub.com account *(also fine for people to create an account at the beginning of class)*\n* Some basic terminal or bash know-how is helpful. Prior experience using the command line comes in handy. We will be using a JavaScript project in our example. But no worries, there is no need to know all the ins-and-outs of JavaScript :relieved:\n* It is necessary to have your GitHub.com SSH Keys setup for the SSH-ing into your build section. The information you need for that is [here](https://help.github.com/articles/connecting-to-github-with-ssh/)\n\n## What is Continuous Integration? \n\n**Continuous Integration** is a practice that encourages developers to integrate their code into a `master` branch of a shared repository early and often. Instead of building out features in isolation and integrating them at the end of a development cycle, code is integrated with the shared repository by each developer multiple times throughout the day.\n\n**Continuous Integration** is a key step to digital transformation.\n\n**What?**    \nEvery developer commits daily to a shared mainline.  \nEvery commit triggers an automated build and test.  \nIf build and test fails, it’s repaired quickly - within minutes.  \n\n**Why?**    \nImprove team productivity, efficiency, happiness.\nFind problems and solve them, quickly.\nRelease higher quality, more stable products.\n\n## CircleCI\n\n**CircleCI** - Our mission is to empower technology-driven organizations to do their best work.  \nWe want to make engineering teams more productive through intelligent automation.\n\n## Advantages of Continuous Integration\n\nContinuous Integration allows organizations to: \n* Improve team productivity and efficiency\n* Accelerate time to market\n* Release higher quality, more stable products\n* Increase customer satisfaction\n* Keep developers happy, and shipping code\n\n*CircleCI provides Enterprise-class support + services, with the flexibility of a startup.  \nWe work where you work: Linux, macOS, Android - SaaS or behind your firewall.  \nLeverage the opportunities created by your modern Git repos.  \nSet up in minutes out of the box, or fully customize to suit your needs.* \n\n## First CircleCI Build\n#### :computer: Let's try out something simple to start off with\n### Creating a repository \n* Navigate to your account on GitHub.com \n  * Go to the **Repositories** tab and then select **New**\n  * Alternatively you can navigate directly to https://github.com/new\n\u003cimg src=\"images/GH_Repo-New-Banner.png\"\u003e\n\u003cimg src=\"images/create-repo-circle-101-initialise-readme.png\"\u003e\n\n### Adding a .yml file\n\nCircleCI uses a [YAML](https://en.wikipedia.org/wiki/YAML) file to identify how you want your testing environment setup and what tests you want to run.\nOn CircleCI 2.0, this file must be called `config.yml` and must be in a hidden folder called `.circleci` (on Mac, Linux, and Windows systems, files and folders whose names start with a period are treated as system files that are hidden from users by default).\n\n * To create the file and folder on GitHub, click the **\"Create new file\"** button the repo page and type `.circleci/config.yml`.\n  \n * You should now have in front of you a blank `config.yml` file in a `.circleci` folder.\n\n* To start out with a simple config.yml, copy the text below into the file editing window on GitHub:\n\n```yml\nversion: 2\njobs:\n  build:\n    docker:\n      - image: circleci/ruby:2.4.1\n    steps:\n      - checkout\n      - run: echo \"A first hello\"\n```\n      \nThe `- image: circleci/ruby:2.4.1` text tells CircleCI what Docker image to use when it builds your project. Circle will use the image to boot up a \"container\" — a virtual computing environment where it will install any languages, system utilities, dependencies, web browsers, etc., that your project might need in order to run.   (CircleCI provides images for most every language)[https://circleci.com/docs/2.0/circleci-images/] based on populare community images.\n\n### Setting up your build on CircleCI\n\nFor this step, you will need a CircleCI account. Visit https://circleci.com/signup and click \"Start with GitHub\". You will need to give CircleCI access to your GitHub account in order to run your builds. \n\nIf you already have a CircleCI account then you can navigate to your dashboard: https://circleci.com/dashboard\n\nNext, you will be given the option of \"following\" any projects you have access to that are already building on CircleCI (this would typically apply to developers connected to a company or organization's GitHub/Bitbucket account). Since this probably doesn't apply to you, click \"Skip - I don't want to follow any projects.\" On the next screen, you'll be able to add the repo you just created as a new project on Circle.\n\nTo add your new repo, ensure that your GitHub account is selected in the dropdown in the upper-left, find the repository you just created below, and click the \"Setup project\" button next to it.\n\n\u003cimg src=\"images/CircleCI-add-new-project-list.png\"\u003e\n\nOn the next screen, you're given some options for configuring your project on CircleCI.  The options help you generate a sample config.yml yo start with.  For now leave everything as-is for now and just click the \"Start building\" button a bit down the page on the right.\n\n\u003cimg src=\"images/CircleCI-2.0-start-building.png\"\u003e\n\n### Running your first CircleCI build!\n\nYou should see your build start to run automatically—and pass! So, what just happened? Click on the green button and let's investigate.\n\n1. **Spin up environment:** CircleCI used the `circleci/ruby:2.4.1` Docker image to launch a virtual computing environment.\n\n2. **Checkout code:** CircleCI checked out your GitHub repository and \"cloned\" it into the virtual environment launched in step 1\n\n3. **echo:** this was the only other instruction in your `config.yml` file: CircleCI ran the echo command with the input \"A first hello\" ([echo](https://linux.die.net/man/1/echo) does exactly what you'd think it would do)\n\nEven though there was no actual source code in your repo, and no actual tests configured in your `config.yml`, CircleCI considers your build to have \"succeeded\" because all steps completed successfully (returned an [exit code](https://en.wikipedia.org/wiki/Exit_status) of 0). Most customers' projects are far more complicated, oftentimes with multiple Docker images and multiple steps, including a large number of tests—here's an example. You can learn more about all the possible steps one might put in a `config.yml` file [here](https://circleci.com/docs/2.0/configuration-reference).\n\n### Breaking your build!\n\nEdit your `config.yml` file (you can just do this in the GitHub editor for simplicity) and replace `echo \"A first hello\"` with `notacommand`. Commit and push this change (or just hit \"Commit\" in the GitHub editor) to trigger a new build and see what happens!\n\n\n### Using Workflows\n\nTo see Workflows in action we can edit our `.circle/config.yml` file. Once you have the file in edit mode in your browser window, select the text from `build` and onwards in you file and copy and paste the text to duplicate that section.\n\nThat should look similar to the code block below:\n\n```yml\nversion: 2\njobs:\n  build:\n    docker:\n      - image: circleci/ruby:2.4.1\n    steps:\n      - checkout\n      - run: echo \"A first hello\"\n  build:\n    docker:\n      - image: circleci/ruby:2.4.1\n    steps:\n      - checkout\n      - run: echo \"A first hello\"      \n```\n\nNext we need to rename our two builds so that they have different names. In my example below I imaginatively picked `build` and `test`. Change the contents of the echo statements to something different. To make the build take a longer period of time we can add a system sleep command. \n\nWe need to add a `workflows` section to our config file. The workflows section can be placed anywhere in the file. Typically it is found either at the top or the bottom of the file. \n\n\n```yml\nversion: 2\njobs:\n  build:\n    docker:\n      - image: circleci/ruby:2.4.1\n    steps:\n      - checkout\n      - run: echo \"A first hello\"\n      - run: sleep 5\n  test:\n    docker:\n      - image: circleci/ruby:2.4.1\n    steps:\n      - checkout\n      - run: echo \"A more familiar hi\"\n      - run: sleep 5\nworkflows:\n  version: 2\n  build_and_test:\n    jobs:\n      - build\n      - test\n```\n\nCommit these changes to your repository and navigate back over to the CircleCI dashboard. \n\n\u003cimg src=\"images/workflows-circle-101-running.png\"\u003e\n\nAnd drilling a little deeper into our workflow...\n\n\u003cimg src=\"images/inside-workflows-circle-101-running.png\"\u003e\n\nSince we want our jobs to run sequentially, we add the `requires` directive.\n\n\n```yml\nversion: 2\njobs:\n  build:\n    docker:\n      - image: circleci/ruby:2.4.1\n    steps:\n      - checkout\n      - run: echo \"A first hello\"\n      - run: sleep 5\n  test:\n    docker:\n      - image: circleci/ruby:2.4.1\n    steps:\n      - checkout\n      - run: echo \"A more familiar hi\"\n      - run: sleep 5\nworkflows:\n  version: 2\n  build_and_test:\n    jobs:\n      - build\n      - test:\n          # only run this job if build succeeds\n          requires:\n            - build \n```\n\n### Fan-out / Fan-in Workflows\nSometimes you'll have more lengthy jobs (integration or browser testing) that can be broken into parallel tracks. If all these jobs pass, you can merge back into final steps (like deployment).  This technique is commonly reffered to as fan-out/fan-in.\n\n```yml\nversion: 2\njobs:\n  build:\n    docker:\n      - image: circleci/ruby:2.4.1\n    steps:\n      - checkout\n      - run: echo \"A first hello\"\n      - run: sleep 5\n      \n      \n  testa:\n    docker:\n      - image: circleci/ruby:2.4.1\n    steps:\n      - checkout\n      - run: echo \"A more familiar hi\"\n      - run: sleep 5\n  testb:\n    docker:\n      - image: circleci/ruby:2.4.1\n    steps:\n      - checkout\n      - run: echo \"A localized Salut\"\n      - run: sleep 5\n      \n      \n  deploy:\n    docker:\n      - image: circleci/ruby:2.4.1\n    steps:\n      - checkout\n      - run: echo \"A final goodbye\"\n      - run: sleep 5\n      \n      \nworkflows:\n  version: 2\n  build_and_test:\n    jobs:\n      - build\n      - testa:\n          requires:\n            - build \n      - testb:\n          requires:\n            - build \n      - deploy:\n          requires:\n            - testa\n            - testb\n```\n\nYou can read more about workflows here: https://circleci.com/docs/2.0/workflows/#overview\n\n\n\n### Adding some changes to use Workspaces \n\nEach Workflow has an associated Workspace which can be used to transfer files to downstream jobs as the workflow progresses. You can use workspaces to pass along data that is unique to this run and which is needed for downstream jobs. Try updating `config.yml` to the following:\n\n```yml\nversion: 2\njobs:\n  build:\n    docker:\n      - image: circleci/ruby:2.4.1\n    steps:\n      - checkout\n      - run: mkdir -p my_workspace\n      - run: echo \"Hello World\" \u003e my_workspace/echo-output\n      - persist_to_workspace:\n          # Must be an absolute path, or relative path from working_directory\n          root: my_workspace\n          # Must be relative path from root\n          paths:\n            - echo-output      \n  testa:\n    docker:\n      - image: circleci/ruby:2.4.1\n    steps:\n      - attach_workspace:\n          # Must be absolute path or relative path from working_directory\n          at: my_workspace\n\n      - run: cat my_workspace/echo-output\n          \n  testb:\n    docker:\n      - image: circleci/ruby:2.4.1\n    steps:\n      - attach_workspace:\n          # Must be absolute path or relative path from working_directory\n          at: my_workspace\n\n      - run: |\n          # this will fail intentionally, we'll use SSH to debug and fix\n          if [[ $(cat my_workspace/echo-output) == \"Trying out workspaces\" ]]; then\n            echo \"It worked!\";\n          else\n            echo \"Nope!\"; exit 1\n          fi   \n          \n  deploy:\n    docker:\n      - image: circleci/ruby:2.4.1\n    steps:\n      - attach_workspace:\n          # Must be absolute path or relative path from working_directory\n          at: my_workspace\n\n      - run: |\n          echo \"Deploying message!\"\n          cat my_workspace/echo-output\n\nworkflows:\n  version: 2\n  build_and_test:\n    jobs:\n      - build\n      - testa:\n          requires:\n            - build \n      - testb:\n          requires:\n            - build \n      - deploy:\n          requires:\n            - testa\n            - testb\n```\n\n**NOTE**: Uh-oh, our `testb` job failed, blocking our deployment.  Can you use SSH debugging (below) to find the right fix?  Hint: Try to run the `at my_workspace/echo-output` yourself, what is the output?\n     \n     \nYou can read more about Workspaces here: https://circleci.com/docs/2.0/workflows/#using-workspaces-to-share-data-among-jobs\n\n### SSH'ing into your build\n\n\u003cimg src=\"images/SSH-screen.jpg\" width=\"100\" height=\"100\" /\u003e\n\nFor those who are comfortable with the terminal, you can SSH directly into your CircleCI jobs to troubleshoot issues with your builds by rerunning your build with the SSH enabled option. \n\n*Note that you will need to add your SSH keys to your GitHub account:\nhttps://help.github.com/articles/connecting-to-github-with-ssh/*\n\n\u003cimg src=\"images/rebuild-with-SSH.png\"\u003e\n\n\u003cimg src=\"images/SSH-build-terminal-string.png\"\u003e\n\nCopy the `ssh` string from the enabling SSH section of your build. Open a terminal and paste in the `ssh` string. \n\nUsing some of the following commands see if you can find and view the contents of the file we created using workspaces\n\n```\npwd     #  print what directory, find out where you are in the file system\nls -al   # list what files and directories are in the current directory\ncd \u003cdirectory_name\u003e    # change directory to the \u003cdirectory_name\u003e directory \ncat \u003cfile_name\u003e    # show me the contents of the file \u003cfile_name\u003e\n```\n\n## Further resources/links :link:\n\nBlog post on how to validate the CircleCI `config.yml` on every commit with a git hook - *extra credit* :apple:\nhttps://circleci.com/blog/circleci-hacks-validate-circleci-config-on-every-commit-with-a-git-hook/\n\n### CircleCI\n\n* The CircleCI blog and how to follow it\n  * https://circleci.com/blog/\n* Relavant blog post  \n  * https://circleci.com/blog/what-is-continuous-integration/\n* Our other social media and GitHub\n  * https://github.com/circleci\n  * https://twitter.com/circleci\n  * https://www.facebook.com/circleci\n  \n### Continuous Integration\n\n* https://martinfowler.com/articles/continuousIntegration.html\n* https://en.wikipedia.org/wiki/Continuous_integration#Best_practices\n  \n### YAML\n* https://en.wikipedia.org/wiki/YAML#Advanced_components\n\n### Terraform\n* https://blog.gruntwork.io/an-introduction-to-terraform-f17df9c6d180\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcircleci%2Flunch-n-learn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcircleci%2Flunch-n-learn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcircleci%2Flunch-n-learn/lists"}