Skip to content

Node.js CI

Node.js CI #138

Workflow file for this run

# Workflow for linting, building, testing, CodeQL analysis, and reporting of code coverage
name: Node.js CI
on:
push:
branches: [master]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/ci-push.yml'
schedule:
- cron: '0 5 * * 1'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm run lint
- run: npm run build
- uses: actions/upload-artifact@v3
with:
name: build
path: build
- name: Test usage with TypeScript
run: npm run test:ts
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:
matrix:
node-version: [10.x, 12.x, 16.x, 18.x]
needs: build
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
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
- run: npm run test
env:
AUTH_JSON: ${{secrets.AUTH_JSON}}
- uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage
coveralls:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# Upload coverage report to toolforge as well
upload_coverage:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/download-artifact@v3
- name: Zip coverage report
run: |
mv coverage/lcov-report/* coverage
zip -r coverage.zip coverage
- name: Upload coverage reports to Toolforge
uses: garygrossgarten/github-action-scp@8a27854bb4f124a497a67316e83783efda770119
with:
local: /home/runner/work/mwn/mwn/coverage.zip
remote: /data/project/mwn/coverage.zip
host: login.toolforge.org
username: ${{ secrets.TOOLFORGE_USERNAME }}
privateKey: ${{ secrets.TOOLFORGE_PRIVATE_KEY }}
rmRemote: true
- name: Coverage
uses: garygrossgarten/github-action-ssh@915e492551885a89131e21d85f2e043c96abff80
with:
command: |
cd /data/project/mwn
rm -rf www/static/coverage
unzip coverage.zip -d www/static
host: login.toolforge.org
username: ${{ secrets.TOOLFORGE_USERNAME }}
privateKey: ${{ secrets.TOOLFORGE_PRIVATE_KEY }}