Feat/content security US-3 and US-4 #4759
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # =============================================================== | |
| # 🧪 JavaScript Unit Tests (Vitest) | |
| # =============================================================== | |
| # Authors: Gabriel Costa, Mihai Criveti | |
| # - runs Vitest unit tests for browser-side JavaScript | |
| # - uses jsdom environment to test non-modular browser scripts | |
| # - installs dependencies from package.json / package-lock.json | |
| # --------------------------------------------------------------- | |
| name: JavaScript Tests (Vitest) | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, ready_for_review] | |
| branches: ["main"] | |
| paths: | |
| - "mcpgateway/static/**" | |
| - "tests/**" | |
| - "package.json" | |
| - "package-lock.json" | |
| - ".github/workflows/vitest.yml" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| vitest: | |
| if: github.event_name != 'pull_request' || !github.event.pull_request.draft | |
| name: vitest | |
| runs-on: ubuntu-slim | |
| timeout-minutes: 15 | |
| steps: | |
| # ----------------------------------------------------------- | |
| # 0️⃣ Checkout | |
| # ----------------------------------------------------------- | |
| - name: ⬇️ Checkout source | |
| uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5 | |
| with: | |
| persist-credentials: false | |
| fetch-depth: 1 | |
| # ----------------------------------------------------------- | |
| # 1️⃣ Node.js Setup | |
| # ----------------------------------------------------------- | |
| - name: 📦 Install Node.js 20 | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y ca-certificates curl gnupg | |
| sudo mkdir -p /etc/apt/keyrings | |
| curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \ | |
| | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg | |
| echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" \ | |
| | sudo tee /etc/apt/sources.list.d/nodesource.list > /dev/null | |
| sudo apt-get update | |
| sudo apt-get install -y nodejs | |
| node --version | |
| npm --version | |
| # ----------------------------------------------------------- | |
| # 2️⃣ Upgrade npm to minimum required version | |
| # ----------------------------------------------------------- | |
| - name: 🔧 Upgrade npm to minimum required version | |
| run: sudo npm install -g npm@^11.10.0 | |
| # ----------------------------------------------------------- | |
| # 3️⃣ Install Dependencies | |
| # ----------------------------------------------------------- | |
| - name: 📥 Install dependencies | |
| run: npm ci | |
| # ----------------------------------------------------------- | |
| # 4️⃣ Run Vitest | |
| # ----------------------------------------------------------- | |
| - name: 🧪 Run Vitest | |
| run: npx vitest run |