Closed github-learning-lab[bot] closed 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.
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.
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
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.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.
testlinks
unit test to master
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:
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
REPLACE-ME-WITH-SCRIPT
placeholder text withbundle 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.