From f8f80a1a54c729bcd2927edadc1f18514fe151f0 Mon Sep 17 00:00:00 2001 From: Gligor Kotushevski Date: Wed, 1 Mar 2023 09:08:30 +1300 Subject: [PATCH 1/3] adding validate github action to pull requests raised to the master branch --- .github/workflows/validate.yml | 49 ++++++++++++++++++++++++++++++++++ package.json | 4 +-- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/validate.yml diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 00000000..9bf31e12 --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,49 @@ +name: Validate + +on: + pull_request: + branches: [master] + +jobs: + validate: + strategy: + matrix: + version: [12, 14, 16, 18] + os: [ubuntu-latest, windows-latest] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Retrieve dependencies from cache + id: cacheNpm + uses: actions/cache@v3 + with: + path: | + ~/.npm + node_modules + key: npm-v${{ matrix.version }}-${{ matrix.os }}-${{ github.ref }}-${{ hashFiles('package.json') }} + restore-keys: | + npm-v${{ matrix.version }}-${{ matrix.os }}-${{ github.ref }}- + npm-v${{ matrix.version }}-${{ matrix.os }}-refs/heads/master- + + - name: Install Node.js and npm + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.version }} + + - name: Install dependencies + if: steps.cacheNpm.outputs.cache-hit != 'true' + run: | + npm ci + + - name: Validate lint rules + run: npm run lint + + - name: Run tests and report code coverage + uses: gligorkot/jest-reporter-action@v0.5.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + test-command: npm run test:ci + env: + CI: true diff --git a/package.json b/package.json index 94c83ca4..06a2f036 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,8 @@ "lint:fix": "eslint src/**/*.ts --fix", "pretest": "npm run lint", "test": "jest", - "test:ci": "npm run test -- --ci", - "test:coverage": "npm run test -- --coverage", + "test:ci": "npm run test:coverage -- --ci", + "test:coverage": "npm run test -- --config ./jest.config.js", "clean:int": "rm -rf integrationTests/configurations/**/.serverless integrationTests/configurations/**/node_modules integrationTests/configurations/**/local.settings.json", "pretest:int": "npm run clean:int", "test:int": "clvr", From c9d39c2c030426cb51d92965d230a4943eb114a9 Mon Sep 17 00:00:00 2001 From: Gligor Kotushevski Date: Wed, 1 Mar 2023 09:12:32 +1300 Subject: [PATCH 2/3] adding required runs-on os for matrix strategy --- .github/workflows/validate.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 9bf31e12..571418ad 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -11,6 +11,7 @@ jobs: version: [12, 14, 16, 18] os: [ubuntu-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - name: Checkout repository uses: actions/checkout@v3 From 8065a75178ab427526501a09f017e6eba49c1f8f Mon Sep 17 00:00:00 2001 From: Gligor Kotushevski Date: Wed, 1 Mar 2023 09:17:22 +1300 Subject: [PATCH 3/3] removing the report coverage part as github action doesn't have access to the github token --- .github/workflows/validate.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 571418ad..f1fc01aa 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -41,10 +41,5 @@ jobs: - name: Validate lint rules run: npm run lint - - name: Run tests and report code coverage - uses: gligorkot/jest-reporter-action@v0.5.0 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - test-command: npm run test:ci - env: - CI: true + - name: Run tests + run: npm run test:ci