t0ottio13 / github-actions-for-ci

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

CI for Node #2

Closed t0ottio13 closed 2 years ago

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

Templated workflow success!

Great job adding the templated workflow. Adding that file to this branch is enough for GitHub Actions to begin running CI on your repository. This takes a couple of minutes, so let's take this opportunity to learn about some of the components of the workflow file you just added. We'll dive deeper into some of the key elements of this file in future steps of the course.

Step 2: Run a templated workflow

I'll respond when GitHub Actions finishes running the workflow. You can follow along in the Actions tab, or by clicking Details on the pending status below.


Actions workflow not running? Click here When a GitHub Actions workflow is running, you should see some checks in progress, like the screenshot below. ![checks in progress in a merge box](https://user-images.githubusercontent.com/16547949/66080348-ecc5f580-e533-11e9-909e-c213b08790eb.png) If the checks don't appear or if the checks are stuck in progress, there's a few things you can do to try and trigger them: - Refresh the page, it's possible the workflow ran and the page just hasn't been updated with that change - Try making a commit on this branch. Our workflow is triggered with a `push` event, and committing to this branch will result in a new `push` - Edit the workflow file on GitHub and ensure there are no red lines indicating a syntax problem
github-learning-lab[bot] commented 2 years ago

Running - and failing - workflow

The workflow ran! But it failed :sob:. But, that's OK. Every time CI fails, it's an opportunity to learn from what's causing it. By running CI with GitHub Actions, we have access to the logs for the attempted build. These are found:

If you navigate over to the build logs, you may notice that the error is "No tests found".

screenshot of build log showing a missing `__test__` directory

Learning how to read build logs and isolate the cause of the problem is an art on its own. We'll try and cover some of the basics here. In our case, the source of the error is the npm test command. The npm test command looks for a testing framework. We want to use Jest, as we mentioned earlier. Jest requires unit tests in a directory named __test__. A __test__ directory doesn't exist on this branch.

Step 3: Add your first test

Not to worry, I've got you covered! Navigate to the open pull request titled Add Jest tests and merge it into this branch. That'll get us the test files we need. I'll respond when you merge the Add Jest tests pull request into this branch.

:keyboard: Activity: Add your first test script for CI to pick up

  1. Navigate to the open pull request titled Add Jest tests
  2. Merge the pull request
github-learning-lab[bot] commented 2 years ago

Waiting on tests

Great! Now that the testing framework is properly configured, we should get a response from it soon. This time, you'll practice reading the logs on your own. Just like before, you can follow along as GitHub Actions runs your job by going to the Actions tab or by clicking on "Details" in the merge box below.

When the tests finish, you'll see a red X :x: or a green check mark :heavy_check_mark: in the merge box. At that point, you'll have access to logs for the build job and its associated steps.

Step 4: Read an Actions log

By looking at the logs, can you identify which tests failed? To find it, go to one of the failed builds and scrolling through the log. Look for a section that lists all the unit tests. We're looking for the name of the test with an "x".

screenshot of a sample build log with the names of the tests blurred out

:keyboard: Activity: Tell the bot which test is failing so we can fix it

  1. Navigate to the log output
  2. Identify a name of a failing test
  3. Comment the name of the failing test here

I'll respond when you enter the name of at least one failing test. You can either copy and paste that portion of the log directly, or type the name of the test as a comment.

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

Let's go to the next step.