chernandezUV / continuous-integration-circle

https://lab.github.com/githubtraining/continuous-integration-with-circleci
MIT License
0 stars 0 forks source link

Add external links to the 'docs' directory #5

Closed github-learning-lab[bot] closed 4 years ago

github-learning-lab[bot] commented 4 years ago

With the addition of links to our code base, we should add a unit test as one of our CircleCI jobs that run whenever it builds.

Let's add a test using HTMLProofer to test for any broken links, images, or HTML. By adding this to our testlinks unit test, HTMLProofer will test our code before it gets merged.

CircleCI allows us to configure multiple jobs using a feature called Workflows. Since we're interested in performing two jobs (a build, and a test for links), we'll use Workflows.

I've already added some things necessary for HTMLProofer test to run, and implemented the use of the Workflows feature. Next, replace the placeholder text with the following:

bundle exec htmlproofer ./_site --check-html

Step 9: Add an HTMLProofer unit test

Let's make sure all links are valid by adding a link checker unit test.

:keyboard: Activity: Check for broken links using CircleCI

  1. In this pull request, replace the REPLACE-ME-WITH-SCRIPT placeholder text with bundle exec htmlproofer ./_site --check-html. You can do this by editing the file from the Files changed tab, or by scrolling down and accepting the suggested change.

I'll respond below with your next step.

github-learning-lab[bot] commented 4 years ago

Nice work! We've added a unit test to check for broken links. When a broken link was committed to our pull request, the test caught it and let us know the build had failed.

screen shot 2018-12-13 at 4 51 01 pm

Notice how the two parts build and testlinks both show as CircleCI checks in our build, but the build unit test succeeds while the testlinks build fails due to a broken link. Also, notice that even though the testlinks test fails, we are still able to merge in the pull request. The branch protection only requires a build test before merging.

When adding tests, or jobs, you can decide which ones must pass before allowing the pull request to merge. This is the nature of managing your pipeline as code using Workflows.

screen shot 2018-12-13 at 5 01 36 pm

Step 10: Fix the broken link

Even though it's not required, let's fix the broken link so both CircleCI checks are passing. You can click on the Details link next to the failed testlinks CircleCI test for more information. By doing so, you'll find the following error:

External link https://help.github.com/setupgithub failed: 404 No error

:keyboard: Activity: Fix the broken link

  1. In this pull request, change https://help.github.com/setupgithub to https://help.github.com/articles/set-up-git/. You can do this by editing the file from the Files changed tab, or by scrolling down and accepting the suggested change.

I'll respond below with your next step.

github-learning-lab[bot] commented 4 years ago

Nice work!

It might take a moment, but once both the build and testlinks tests are passing, it's time to merge this pull request.

Step 11: Merge the unit test

:keyboard: Activity: Add the testlinks unit test to master

  1. Review and Approve the pull request.
  2. Click Merge pull request, and delete your branch.

I'll respond below with your next step.

github-learning-lab[bot] commented 4 years ago

I created a new issue, look for my next response there.