From d0077929cdbd8dc3309f458c24e4a79490f3af5f Mon Sep 17 00:00:00 2001 From: Mathew <77069472+Matte22@users.noreply.github.com> Date: Thu, 22 Feb 2024 13:28:34 -0500 Subject: [PATCH] test: Create Workflow for unit testing. (#92) --- .github/workflows/sonarcloud.yml | 2 +- .github/workflows/unit-testing.yml | 38 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/unit-testing.yml diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 71f6c9e..be37743 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -40,7 +40,7 @@ jobs: -Dsonar.projectName=NUWCDIVNPT_stigman-watcher -Dsonar.organization=nuwcdivnpt -Dsonar.inclusions=**/*.js - -Dsonar.exclusions=**/node_modules/**, + -Dsonar.exclusions=**/node_modules/**,**/test/**,**/coverage/** # This will fail the action if Quality Gate fails (leaving out for now ) diff --git a/.github/workflows/unit-testing.yml b/.github/workflows/unit-testing.yml new file mode 100644 index 0000000..e029a47 --- /dev/null +++ b/.github/workflows/unit-testing.yml @@ -0,0 +1,38 @@ +name: Run Unit Tests and Upload Coverage Artifact +on: + workflow_dispatch: + push: + branches: + - main + paths: + - "lib/**" + - "index.js" + - "test/**" + pull_request: + branches: + - main + paths: + - "lib/**" + - "index.js" + - "test/**" + +jobs: + build_test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install app dependencies + run: npm ci + - name: Run tests + run: npm test + - name: Upload coverage to github + uses: actions/upload-artifact@v3 + if: ${{ always() }} + with: + name: coverage + path: coverage \ No newline at end of file