From 75e1ef14c6968b8ab9340463a368e78a2d067394 Mon Sep 17 00:00:00 2001 From: Sai Sankeerth Date: Tue, 23 Jan 2024 18:23:39 +0530 Subject: [PATCH] chore: add sonarcloud scan, add lint command & add verification GHA Signed-off-by: Sai Sankeerth --- .github/workflows/tests.yml | 8 ++++++++ .github/workflows/verify.yml | 36 ++++++++++++++++++++++++++++++++++++ package.json | 1 + 3 files changed, 45 insertions(+) create mode 100644 .github/workflows/verify.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e251b74..94e8e66 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,3 +21,11 @@ jobs: - name: Run Tests run: npm run test + + - name: SonarCloud Scan + if: always() + uses: SonarSource/sonarcloud-github-action@v2.1.1 + env: + GITHUB_TOKEN: ${{ secrets.PAT }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..4caef8d --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,36 @@ +name: Verify + +on: + pull_request: + +jobs: + formatting-lint: + name: Check for formatting & lint errors + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4.1.1 + with: + # Make sure the actual branch is checked out when running on pull requests + ref: ${{ github.head_ref }} + + - name: Setup Node + uses: actions/setup-node@v3.7.0 + with: + node-version-file: .nvmrc + cache: 'npm' + + - name: Install Dependencies + run: npm ci + + - name: Run Lint Checks + run: | + npm run lint + + - run: git diff --exit-code + + - name: Error message + if: ${{ failure() }} + run: | + echo 'Eslint check is failing Ensure you have run `npm run lint` and committed the files locally.' diff --git a/package.json b/package.json index 362d885..307cfeb 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "lint:fix": "eslint . --fix", "lint:check": "eslint . || exit 1", "format": "prettier --write '**/*.ts' '**/*.js' '**/*.json'", + "lint": "npm run format && npm run lint:fix", "prepare": "husky install", "jest:scenarios": "jest e2e.test.ts --verbose", "test:scenario": "jest test/scenario.test.ts --verbose",