From 2437b3835f745f6b094ef7acb1c3e46ad5e808bd Mon Sep 17 00:00:00 2001
From: Siddharth VP <siddharthvp@gmail.com>
Date: Sun, 17 Dec 2023 01:59:53 +0530
Subject: [PATCH] workflows: split CodeQL, upgrade action packages

---
 .github/workflows/ci-pull-request.yml | 28 +++++-----------
 .github/workflows/ci-push.yml         | 46 ++++++++++++---------------
 .github/workflows/code-ql.yml         | 31 ++++++++++++++++++
 .github/workflows/docs-deploy.yml     |  2 +-
 .github/workflows/npm-publish.yml     |  4 +--
 5 files changed, 62 insertions(+), 49 deletions(-)
 create mode 100644 .github/workflows/code-ql.yml

diff --git a/.github/workflows/ci-pull-request.yml b/.github/workflows/ci-pull-request.yml
index c1ece95..57e3597 100644
--- a/.github/workflows/ci-pull-request.yml
+++ b/.github/workflows/ci-pull-request.yml
@@ -6,39 +6,27 @@ on:
     paths:
       - 'src/**'
       - 'tests/**'
+      - 'package.json'
+      - 'package-lock.json'
       - '.github/workflows/ci-pull-request.yml'
 
 jobs:
   build:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - name: Use Node.js 16.x
-        uses: actions/setup-node@v3
+        uses: actions/setup-node@v4
         with:
           node-version: 16
       - run: npm ci
       - run: npm run lint
       - run: npm run build
-      - uses: actions/upload-artifact@v3
+      - uses: actions/upload-artifact@v4
         with:
           name: build
           path: build
 
-  code_ql:
-    runs-on: ubuntu-latest
-    name: CodeQL
-    needs: build
-    steps:
-      - uses: actions/checkout@v3
-      - uses: actions/download-artifact@v3
-      - name: Initialize CodeQL
-        uses: github/codeql-action/init@v2
-        with:
-          languages: javascript
-      - name: Perform CodeQL Analysis
-        uses: github/codeql-action/analyze@v2
-
   test:
     runs-on: ubuntu-latest
     strategy:
@@ -46,13 +34,13 @@ jobs:
         node-version: [10.x, 12.x, 14.x, 16.x]
     needs: build
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - name: Use Node.js ${{ matrix.node-version }}
-        uses: actions/setup-node@v3
+        uses: actions/setup-node@v4
         with:
           node-version: ${{ matrix.node-version }}
       - name: Setup MediaWiki instance using Docker for integration tests
         run: npm run setuplocalwiki
       - run: npm ci
-      - uses: actions/download-artifact@v3
+      - uses: actions/download-artifact@v4
       - run: npm run test:localwiki && npm run test:nowiki
diff --git a/.github/workflows/ci-push.yml b/.github/workflows/ci-push.yml
index 7b1e385..cbc489c 100644
--- a/.github/workflows/ci-push.yml
+++ b/.github/workflows/ci-push.yml
@@ -8,6 +8,8 @@ on:
     paths:
       - 'src/**'
       - 'tests/**'
+      - 'package.json'
+      - 'package-lock.json'
       - '.github/workflows/ci-push.yml'
   schedule:
     - cron: '0 5 * * 1'
@@ -17,15 +19,15 @@ jobs:
   build:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - name: Use Node.js 16.x
-        uses: actions/setup-node@v3
+        uses: actions/setup-node@v4
         with:
           node-version: 16
       - run: npm ci
       - run: npm run lint
       - run: npm run build
-      - uses: actions/upload-artifact@v3
+      - uses: actions/upload-artifact@v4
         with:
           name: build
           path: build
@@ -34,20 +36,6 @@ jobs:
         env:
           AUTH_JSON: ${{secrets.AUTH_JSON}}
 
-  code_ql:
-    runs-on: ubuntu-latest
-    name: CodeQL
-    needs: build
-    steps:
-      - uses: actions/checkout@v3
-      - uses: actions/download-artifact@v3
-      - name: Initialize CodeQL
-        uses: github/codeql-action/init@v2
-        with:
-          languages: javascript
-      - name: Perform CodeQL Analysis
-        uses: github/codeql-action/analyze@v2
-
   test:
     runs-on: ubuntu-latest
     strategy:
@@ -55,31 +43,34 @@ jobs:
         node-version: [10.x, 12.x, 16.x, 18.x]
     needs: build
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - name: Use Node.js ${{ matrix.node-version }}
-        uses: actions/setup-node@v3
+        uses: actions/setup-node@v4
         with:
           node-version: ${{ matrix.node-version }}
       - name: Setup MediaWiki instance using Docker for integration tests
         run: npm run setuplocalwiki
       - run: npm ci
-      - uses: actions/download-artifact@v3
+      - uses: actions/download-artifact@v4
       - run: npm run test
         env:
           AUTH_JSON: ${{secrets.AUTH_JSON}}
-      - uses: actions/upload-artifact@v3
+      - uses: actions/upload-artifact@v4
         with:
-          name: coverage
+          name: coverage_${{ matrix.node-version }}
           path: coverage
 
   coveralls:
     runs-on: ubuntu-latest
     needs: test
     steps:
-      - uses: actions/checkout@v3
-      - uses: actions/download-artifact@v3
+      - uses: actions/checkout@v4
+      - uses: actions/download-artifact@v4
+        with:
+          name: coverage_18.x
+          path: coverage
       - name: Coveralls
-        uses: coverallsapp/github-action@master
+        uses: coverallsapp/github-action@v2
         with:
           github-token: ${{ secrets.GITHUB_TOKEN }}
 
@@ -88,7 +79,10 @@ jobs:
     runs-on: ubuntu-latest
     needs: test
     steps:
-      - uses: actions/download-artifact@v3
+      - uses: actions/download-artifact@v4
+        with:
+          name: coverage_18.x
+          path: coverage
       - name: Zip coverage report
         run: |
           mv coverage/lcov-report/* coverage
diff --git a/.github/workflows/code-ql.yml b/.github/workflows/code-ql.yml
new file mode 100644
index 0000000..5bfa677
--- /dev/null
+++ b/.github/workflows/code-ql.yml
@@ -0,0 +1,31 @@
+name: CodeQL
+
+on:
+  pull_request:
+    branches: [master]
+    paths:
+      - 'src/**'
+      - 'tests/**'
+  push:
+    branches: [master]
+    paths:
+      - 'src/**'
+      - 'tests/**'
+  schedule:
+    - cron: '0 5 * * 1'
+  workflow_dispatch:
+
+jobs:
+  code_ql:
+    runs-on: ubuntu-latest
+    name: CodeQL
+    needs: build
+    steps:
+      - uses: actions/checkout@v4
+      - uses: actions/download-artifact@v4
+      - name: Initialize CodeQL
+        uses: github/codeql-action/init@v2
+        with:
+          languages: javascript
+      - name: Perform CodeQL Analysis
+        uses: github/codeql-action/analyze@v2
diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/docs-deploy.yml
index bc7ad35..61083e6 100644
--- a/.github/workflows/docs-deploy.yml
+++ b/.github/workflows/docs-deploy.yml
@@ -15,7 +15,7 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - name: Checkout repository
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
       - name: Install dependencies
         run: |
           npm ci
diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml
index c40e3b5..099bf55 100644
--- a/.github/workflows/npm-publish.yml
+++ b/.github/workflows/npm-publish.yml
@@ -8,8 +8,8 @@ jobs:
   publish-npm:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v3
-      - uses: actions/setup-node@v3
+      - uses: actions/checkout@v4
+      - uses: actions/setup-node@v4
         with:
           node-version: 16
           registry-url: https://registry.npmjs.org/