Node.js CI #173
This file contains 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
# Workflow for linting, building, testing, CodeQL analysis, and reporting of code coverage | |
name: Node.js CI | |
on: | |
push: | |
branches: [master] | |
paths: | |
- 'src/**' | |
- 'tests/**' | |
- 'package.json' | |
- 'package-lock.json' | |
- '.github/workflows/ci-push.yml' | |
schedule: | |
- cron: '30 12 * * 0' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- run: npm ci | |
- run: npm run lint | |
- run: npm run build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
path: build | |
- name: Test usage with TypeScript | |
run: npm run test:ts | |
env: | |
AUTH_JSON: ${{secrets.AUTH_JSON}} | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [10.x, 12.x, 16.x, 18.x] | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
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@v4 | |
- run: npm run test | |
env: | |
AUTH_JSON: ${{secrets.AUTH_JSON}} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: coverage_${{ matrix.node-version }} | |
path: coverage | |
coveralls: | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: coverage_18.x | |
path: coverage | |
- name: Coveralls | |
uses: coverallsapp/github-action@v2 | |
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@v4 | |
with: | |
name: coverage_18.x | |
path: coverage | |
- name: Zip coverage report | |
run: | | |
mv coverage/lcov-report/* coverage | |
zip -r coverage.zip coverage | |
- name: Upload coverage reports to Toolforge | |
uses: appleboy/scp-action@9ba62064d28ce0897a970e72cdfe30b9fde2fe48 | |
with: | |
source: ${{github.workspace}}/coverage/* | |
strip_components: 3 | |
target: /data/project/mwn/www/static/coverage | |
rm: true | |
host: login.toolforge.org | |
username: ${{ secrets.TOOLFORGE_USERNAME }} | |
key: ${{ secrets.TOOLFORGE_PRIVATE_KEY }} | |
mirror: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # all branches and tags | |
- name: Mirror to Gitlab | |
run: | | |
mkdir -p ~/.ssh | |
echo -e "$KEY" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config | |
git remote add gitlab "git@gitlab.wikimedia.org:sd/mwn.git" | |
git push gitlab master --force-with-lease | |
git push gitlab --tags | |
rm -rf ~/.ssh | |
env: | |
KEY: ${{ secrets.GITLAB_PRIVATE_KEY }} |