Lab 9 – GitHub Actions Workflow

Intro

For my ninth lab, I have to set up GitHub Action for my text ssg project. Then pick another student that has GitHub Actions setup and create a PR to his repo.
In my previous I had a bit of experience with GitHub Action, I had a chance …


This content originally appeared on DEV Community and was authored by Kevan Y

Intro

For my ninth lab, I have to set up GitHub Action for my text ssg project. Then pick another student that has GitHub Actions setup and create a PR to his repo.
In my previous I had a bit of experience with GitHub Action, I had a chance to set up with my mentor a GitHub Action to enable e2e testing with Cypress on the new build application when a PR is created, to have continuous integration.

Setup GitHub Action

First of all, I create a folder called .github/workflows, this folder contains the file for setup for GitHub Action.

I created a file called ci_workflow.yml and put

name: CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [16.x]

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
    - name: npm install and test
      run: |
        npm install
        npm run test-silent

To make it simple, this file means, on push to main or create PR to be pushed to main will run this workflow.
The job of this workflow is to run a node-version 16.x on a ubuntu-latest system, and install all my application dependencies and run a test.
If test fails it will return -1, if pass it will return 0.
Image description

Add more test cases to another student repo

I pick Andre repo, I created an issue stating, to separate generate HTML into a function, then add test case for that function.
After finishing my fix. I created a PR, I see that the workflow Andre setup is working correctly.
Image description

Conclusion

GitHub action is a powerful tool, it enables developers to shift some manual work into automation. Yet I still have a lot to learn of GitHub Actions.


This content originally appeared on DEV Community and was authored by Kevan Y


Print Share Comment Cite Upload Translate Updates
APA

Kevan Y | Sciencx (2021-11-18T20:14:29+00:00) Lab 9 – GitHub Actions Workflow. Retrieved from https://www.scien.cx/2021/11/18/lab-9-github-actions-workflow/

MLA
" » Lab 9 – GitHub Actions Workflow." Kevan Y | Sciencx - Thursday November 18, 2021, https://www.scien.cx/2021/11/18/lab-9-github-actions-workflow/
HARVARD
Kevan Y | Sciencx Thursday November 18, 2021 » Lab 9 – GitHub Actions Workflow., viewed ,<https://www.scien.cx/2021/11/18/lab-9-github-actions-workflow/>
VANCOUVER
Kevan Y | Sciencx - » Lab 9 – GitHub Actions Workflow. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/18/lab-9-github-actions-workflow/
CHICAGO
" » Lab 9 – GitHub Actions Workflow." Kevan Y | Sciencx - Accessed . https://www.scien.cx/2021/11/18/lab-9-github-actions-workflow/
IEEE
" » Lab 9 – GitHub Actions Workflow." Kevan Y | Sciencx [Online]. Available: https://www.scien.cx/2021/11/18/lab-9-github-actions-workflow/. [Accessed: ]
rf:citation
» Lab 9 – GitHub Actions Workflow | Kevan Y | Sciencx | https://www.scien.cx/2021/11/18/lab-9-github-actions-workflow/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.