Skip to content

Conversation

@github-learning-lab
Copy link
Contributor

In this pull request, I've added some tests to help ensure the project builds. This is one example of how you can customize specific validations to run when your CI starts a build. I need you to add a run action to your .circleci/config.yml file.

In this example, we'll build the project with bundle exec jekyll build. Depending on the programming language and project, you might use a different command, like yarn run android or nvm package. You can find more specific information on CircleCI configuration in their documentation.

Step 5: Add validation

Build your site.

⌨️ Activity: Add some automated validation to your project

  1. In this pull request, add the following code to the placeholder in your .circleci/config.yml file. You can do this by editing the file from the Files changed tab, or by scrolling down and accepting the suggested change.
 bundle exec jekyll build
  1. Commit your change.

I'll respond below with your next step.

Sometimes I respond too fast for the page to update! If you perform an expected action and don't see a response, wait a few seconds and refresh the page for your next steps.

@github-learning-lab github-learning-lab bot mentioned this pull request Mar 30, 2022
Co-authored-by: github-learning-lab[bot] <37936606+github-learning-lab[bot]@users.noreply.github.com>
@github-learning-lab github-learning-lab bot requested a review from NooraAz March 30, 2022 20:04
@github-learning-lab
Copy link
Contributor Author

Now that you've added some validation tests to your CI build, it's time to turn on branch protection. Protected branches ensure that collaborators cannot make irrevocable changes to specific branches. This also allows you to enable CI required status checks to pass before merging.

Why use protected branches? Protected branches allow contributors to create branches and pull requests in your repository, while making sure those changes are throughly vetted before merging. When a repository employs a continuous integration service like CircleCI, branches can be protected based on their build statuses so the review process can be largely automated, giving contributors self-efficacy. Project maintainers also benefit by focusing their attention on gray areas and processes that can't be easily automated.

screen shot 2018-12-13 at 3 32 04 pm

I've changed the protections for the main branch throughout the course so far to help keep you on track. Now, it's time for you to make some changes.

Step 6: Protect the main branch

⌨️ Activity: Protect a branch based on the CI build status

  1. Navigate to the Branches section of the Settings for this repository.
  2. Under Branch protection rules, click the Edit button next to main.
  3. Select Require status checks to pass before merging.
  4. Uncheck Require branches to be up to date before merging.
    • This is automatically checked, and can be a good idea. For this project, we'll uncheck it to reduce the extra commits and builds.
  5. Select the ci/circleci:build option.
  6. Click Save changes.
  7. Return to your pull request and Approve the pull request.

I'll respond below with your next step.

@github-learning-lab
Copy link
Contributor Author

Awesome, nice work getting those branch protections in place 🎉

But, right before you enabled your branch protections, something happened. A contributor committed invalid syntax on main and broke your CI build. Luckily, your new test caught it and you turned on branch protections. These types of errors won't make it into future builds.

Note: If your build is still processing, you may not see the failed test yet. If you wait a few minutes, it should be done soon.

Looking at your build status, click on the Details link as shown below:

screen shot 2018-12-13 at 3 42 44 pm

Notice that you get the following error:

  Liquid Exception: Liquid syntax error (line 1): Unknown tag 'site' in docs/01_getting_ready_for_class.md

Jekyll uses Liquid, an open-source templating language. Liquid loads data dynamically and implements conditional logic. Some of the Liquid syntax in one of the files is incorrect.

Step 7: Fix the broken build

Let's find the broken syntax and fix the build!

⌨️ Activity: Fix the build in your codebase

  1. Apply the suggested change.

I'll respond below with your next step.

Co-authored-by: github-learning-lab[bot] <37936606+github-learning-lab[bot]@users.noreply.github.com>
@github-learning-lab
Copy link
Contributor Author

Nice job finding and fixing that Liquid syntax!

It might take a moment, but notice as your build is complete that all checks have passed.

Step 8: Merge code with a successful build

Now that your pull request has a successful build, let's merge it!

⌨️ Activity: Merge the pull request

  1. Click Merge pull request, and delete your branch.

I'll respond below with your next step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants