Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Francesco Menghi
Francesco Menghi

Posted on • Edited on

     

First look at GitHub Actions

GitHub Actions is aContinuous Integration tool built into GitHub that provides an easy way to automate code testing and more.

The Setup

I setup a new action to runJest tests on"ubuntu-latest" using bothNode 14 andNode 16 every time a new Pull Request is created or a new commit is added.
I tested it with a newPR and this is what showed up at the bottom:

GitHub Actions

This worked very well so I decided to also add actions to runPrettier andESLint automatically. I looked through howTelescope implements Continuous Integration and I created a similar setup forstatic-dodo.

Here is my full GitHub Actions code (created in.github/workflows/:

name:Node.js CIon:push:branches:[main]pull_request:branches:[main]jobs:prettier:name:Prettier Checkruns-on:ubuntu-lateststeps:-uses:actions/checkout@v2-uses:actions/setup-node@v2-name:Install dependencies and run prettier-checkrun:|npm installnpm run prettier-checkeslint:name:ESLint Checkruns-on:ubuntu-lateststeps:-uses:actions/checkout@v2-uses:actions/setup-node@v2-name:Install dependencies and run eslintrun:|npm installnpm run eslintbuild:runs-on:ubuntu-lateststrategy:matrix:node-version:[14.x,16.x]steps:-uses:actions/checkout@v2-name:Use Node.js ${{ matrix.node-version }}uses:actions/setup-node@v2with:node-version:${{ matrix.node-version }}cache:"npm"-run:npm ci-run:npm test
Enter fullscreen modeExit fullscreen mode

The code is written inYAML and even though it is my first time using it, it is very descriptive and easy to read and learn.
Every time I add a new commit to the repo, the GitHub actions now starts automatically and adds a nice green check mark when all the automated tests passed successfully.

GitHub Actions Done

Thoughts

GitHub Actions is an amazing tool: it allows programmers to setup automation to always be sure that everything still works as more and more lines of codes are added to a project. I just scratched the surface of what is possible to accomplish with it but I will definitely continue using it going forward and hopefully lean some new tricks along the way!

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Location
    Toronto, Canada
  • Joined

More fromFrancesco Menghi

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp