GitHub Actions provide a convenient way to run your application tests. You can also run a test matrix with different dependency versions. For example, a test matrix can consist of three Node.js and two MongoDB versions. The test suite will then run against all combinations of Node.js and MongoDB versions.
This tutorial shows you how to create a job name representing the combined dependencies. You’ll create a job name in the format of Node {node-version} - MongoDB {mongodb-version}
.
GitHub Actions Series Overview
- Getting Started With Node.js
- Create a Testing Matrix
- Using MongoDB
- Using Redis
- Using MongoDB Replica Sets
- Run on Pull Request
- Customize the Job Name
- Run a Workflow When Creating a Tag
- Testing Against an Exact Node.js Version
- Trigger Builds on Schedule (Cron)
- How to Test Lerna Monorepos
- How to Add Comments in YAML Files
- Clone Another Repository
- Run on Push or Pull Request, but Not Both
- Limit Concurrency and Cancel In-Progress Jobs
- Test Against the Latest Node.js Version
Customize the Job Name
By default, GitHub Actions use the job key as an identifier in the web UI. The identifier in the following example is test
because it’s the only key in the list of jobs in the YAML configuration.
You can change the name for a job by providing a name
property. You can access all the metadata in the job configuration.
The following workflow configuration assigns a job name consisting of the Node.js and MongoDB version:
name: Run tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 13.x]
mongodb-version: [4.0, 4.2]
name: Node.js ${{ matrix.node-version }} - MongoDB ${{ matrix.mongodb-version }}
steps:
- name: …
The testing matrix defines two versions of the Node.js and MongoDB dependencies. Using a customized name lets you identify which combination failed in your test suite.
The following screenshot shows GitHub’s web UI before using a custom job name:
And here’s the GitHub web UI using a job name consisting of the used Node.js and MongoDB version:
The explicit naming helps you to quickly identify individual jobs in the testing matrix.