Autoplay



Transcripted Summary

After we check our first workflow with GitHub, now it's time to ask what if we wanted to run with different Node.js versions?

So here we will open again Run TestCafe GitHub Actions.

We'll go to the examples and here we can find the section "Target Multiple Node.js Versions and Operating System".

For example, here we will use something called the strategy and matrix.

We need to run on ubuntu-latest and windows-latest with Node.js version 8, 10, and 12.

We can create an additional workflow and use it with multiple Node.js.

We can copy this workflow because we don't need to change anything else.


name: Target Multiple Node.js Versions and Operating Systems
on: [push]

jobs:
  build:
    name: Run Tests Across Node.js Versions and Operating Systems
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
        node: [8, 10, 12]
    steps:
      - uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node }}
      - uses: actions/checkout@v1
      - name: Run TestCafe Tests
        uses: DevExpress/testcafe-action@latest
        with:
          args: "chrome tests"

We can go to GitHub Actions again, and click on "New workflow".

Then we can create or set up your workflow by yourself and here we can just remove this code and put it in our code.

We can just name it multipleNodeJS.yml.

Here we are running on multiple.

Also on every push, "Run Tests across Node.js Versions and Operating Systems" with the matrix os and the run-ons will be replaced - once with the ubuntu-latest, one with the windows-latest.

And also we will have different workflows run in parallel with different Node.js versions.

And here we have a node version - also, it gets the values from the node matrix here.

And "Run TestCafe Tests".

We will not change anything else because we will still be running with the same command.

For example, chrome tests and also, if you want to run anything else, we can add it in the TestCafe command line.

Let's commit this change in master, or we can create one additional branch.

This is for creating a multipleNodeJS.yml file.

And then we can start opening the PR or the pull request.

Here we can find what we are targeting from this PR.



This is the main workflow that we created in the previous demo.

This is the one that we set up with one single Node.js.

This is the "Target Multiple Node.js" with different operating systems.

If we go to the details for these runs, we will have that one is running in ubuntu-latest with Node.js version 8.



If you click in this one, it's Ubuntu and version 10.

This one is Ubuntu and version 12.

And also for Windows, we have 8 and 10 and 12.

So we will wait until all the test runs on different Node.js versions are finished.

Maybe we can figure out a problem with different versions with Node.js.

After all the matrix strands, we can check the test results.

Here, after all the workflows are finished, we can check the result and all the workflows are passed successfully.



And here we can find all the details.

For example, for Windows latest and Ubuntu, we can also open or check the run TestCafe.

Here we have also, we have five test cases passed.

This is the Assert home page, registration, place order, and so on.

So this is a matrix and this is our main workflow.

Also, we can return back to the PR, to merge this PR in our code.

Here we don't have any problems, and after that, we can just merge the PR.

So here we can check again- this one is still in progress because some checks still haven't been completed yet.

So we need to wait until our main workflow finishes then after that, we can merge this PR.

After all the checks have passed, here we can check that we have seven successful checks, with multiple Nodes and also our default workflow.

Now it's time to merge this PR to confirm the merge and to add our new workflow in our repository.

We can also delete the branch - we don't need it anymore.

There are no additional PRs and here we can find inside the workflow that we will check that we have a multipleNodeJS.yml and also we have nodejs.yml.

To be able to trigger our GitHub workflows on a schedule as a nightly build, we can open the GitHub documentation or GitHub Action documentation and search about events that trigger workflows.



Under the events, we have "Schedule events", which will schedule events to allow us to trigger workflow at scheduled times.

We can remove on time, or on push, and replace it with schedule.

After that, we can add corn time or the cron job.

It will be run at a special time like this one */15 * * * *.

This is a schema.

For example, the first asterisk is for minutes, and the second one is for an hour, the third one is the day, the fourth one is a month, and the last one is a day of the week.

So under here, we can also use an example for this.

For example, this * * * * * will be run every minute of every day.

So in our multiple workflows - we can open it again - this one will not be run in every push, but we need to run it on a schedule and we will leave the default workflow to run on every change in our code.

So we will edit this one.

After that, we can say, on:, and under on we can select schedule, and here it suggests you add the cron.

And for the cron, we should add the string with the value.

For example, if I entered 0 2 * * *.

After that, I will hover on this value.

This means this will be run at two o'clock UTC, or universal time, every day.

So this is actually what we need.

And also, for example, we can change the value here. For example, this is the hour, and for example, we can say this will be run at five o'clock.

We can leave it 2 and after that, we can just start commit, and maybe we can directly commit to the master branch to commit this change.


name: Target Multiple Node.js Versions and Operating Systems
on:
  schedule:
    - cron: "0 2 * * *"

jobs:
  build:
    name: Run Tests Across Node.js Versions and Operating Systems
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, windows-latest]
        node: [8, 10, 12]
    steps:
      - uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node }}
      - uses: actions/checkout@v1
      - name: Run TestCafe Tests
        uses: DevExpress/testcafe-action@latest
        with:
          args: "chrome tests"

This means now we have two workflows.

One will be run on every change in our code, and one will be scheduled every day at 2:00 universal time and run our workflow with TestCafe.

We will open the Actions and here we will find that our Target Multiple Node is not running, but we are just running the normal workflow. So if we open this one, we are running TestCafe with the normal workflow, and we are not triggering any more Multiple Nodes with Node.js.



Resources