Node.js based forum software built for the modern web
Github actions lint demo (#8812)
Peter Jaszkowiaka3fa31329810
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yamlnew file mode 100644index 0000000000..d812450608--- /dev/null+++ b/.github/workflows/test.yaml@@ -0,0 +1,204 @@+name: Lint and test++on:+ push:+ branches:+ - master+ - develop+ pull_request:+ branches:+ - master+ - develop++defaults:+ run:+ shell: bash++jobs:+ test:+ name: Lint and test+ strategy:+ fail-fast: false+ matrix:+ os: [ubuntu-latest]+ node: [10, 12, 14]+ database: [mongo-dev, mongo, redis, postgres]+ include:+ # only run coverage once+ - os: ubuntu-latest+ node: 14+ coverage: true+ # test under development once+ - database: mongo-dev+ test_env: development+ # only run eslint once+ - os: ubuntu-latest+ node: 14+ database: mongo-dev+ lint: true+ runs-on: ${{ matrix.os }}+ env:+ TEST_ENV: ${{ matrix.test_env || 'production' }}++ services:+ postgres:+ image: 'postgres:10-alpine'+ env:+ POSTGRES_USER: postgres+ POSTGRES_PASSWORD: postgres+ # Set health checks to wait until postgres has started+ options: >-+ --health-cmd pg_isready+ --health-interval 10s+ --health-timeout 5s+ --health-retries 5+ ports:+ # Maps port 5432 on service container to the host+ - 5432:5432++ redis:+ image: 'redis:2.8.9'+ # Set health checks to wait until redis has started+ options: >-+ --health-cmd "redis-cli ping"+ --health-interval 10s+ --health-timeout 5s+ --health-retries 5+ ports:+ # Maps port 6379 on service container to the host+ - 6379:6379++ mongo:+ image: 'mongo:3.2'+ ports:+ # Maps port 27017 on service container to the host+ - 27017:27017++ steps:+ - uses: actions/checkout@v2++ - run: cp install/package.json package.json++ - name: Install Node+ uses: actions/setup-node@v1+ with:+ node-version: ${{ matrix.node }}++ - name: NPM Install+ uses: bahmutov/npm-install@v1+ with:+ useLockFile: false++ - name: Setup on MongoDB+ if: startsWith(matrix.database, 'mongo')+ env:+ SETUP: >-+ {+ "url": "http://127.0.0.1:4567",+ "secret": "abcdef",+ "admin:username": "admin",+ "admin:email": "[email protected]",+ "admin:password": "hAN3Eg8W",+ "admin:password:confirm": "hAN3Eg8W",++ "database": "mongo",+ "mongo:host": "127.0.0.1",+ "mongo:port": 27017,+ "mongo:username": "",+ "mongo:password": "",+ "mongo:database": "nodebb"+ }+ CI: >-+ {+ "host": "127.0.0.1",+ "port": 27017,+ "database": "ci_test"+ }+ run: |+ node app --setup="${SETUP}" --ci="${CI}"++ - name: Setup on PostgreSQL+ if: startsWith(matrix.database, 'postgres')+ env:+ SETUP: >-+ {+ "url": "http://127.0.0.1:4567",+ "secret": "abcdef",+ "admin:username": "admin",+ "admin:email": "[email protected]",+ "admin:password": "hAN3Eg8W",+ "admin:password:confirm": "hAN3Eg8W",++ "database": "postgres",+ "postgres:host": "127.0.0.1",+ "postgres:port": 5432,+ "postgres:username": "postgres",+ "postgres:password": "postgres",+ "postgres:database": "nodebb"+ }+ CI: >-+ {+ "host": "127.0.0.1",+ "database": "ci_test",+ "port": 5432,+ "username": "postgres",+ "password": "postgres"+ }+ run: |+ node -e "const { Client } = require('pg'); const c = new Client({ host: '127.0.0.1', port: 5432, user: 'postgres', password: 'postgres' }); c.connect().then(() => c.query('CREATE DATABASE nodebb')).then(() => c.query('CREATE DATABASE ci_test')).then(() => c.end())"+ node app --setup="${SETUP}" --ci="${CI}"++ - name: Setup on Redis+ if: startsWith(matrix.database, 'redis')+ env:+ SETUP: >-+ {+ "url": "http://127.0.0.1:4567/forum",+ "secret": "abcdef",+ "admin:username": "admin",+ "admin:email": "[email protected]",+ "admin:password": "hAN3Eg8W",+ "admin:password:confirm": "hAN3Eg8W",++ "database": "redis",+ "redis:host": "127.0.0.1",+ "redis:port": 6379,+ "redis:password": "",+ "redis:database": 0+ }+ CI: >-+ {+ "host": "127.0.0.1",+ "database": 1,+ "port": 6379+ }+ run: |+ node app --setup="${SETUP}" --ci="${CI}"++ - name: Run ESLint+ if: matrix.lint+ run: npm run lint++ - name: Node tests+ run: npm test++ - name: Extract coverage info+ run: npm run coverage++ - name: Test coverage+ uses: coverallsapp/[email protected]+ if: matrix.coverage+ with:+ github-token: ${{ secrets.GITHUB_TOKEN }}+ flag-name: ${{ matrix.os }}-node-${{ matrix.node }}-db-${{ matrix.database }}+ parallel: true++ finish:+ needs: test+ runs-on: ubuntu-latest+ steps:+ - name: Coveralls Finished+ uses: coverallsapp/[email protected]+ with:+ github-token: ${{ secrets.GITHUB_TOKEN }}+ parallel-finished: truediff --git a/.travis.yml b/.travis.ymldeleted file mode 100644index e302e25b74..0000000000--- a/.travis.yml+++ /dev/null@@ -1,47 +0,0 @@-services:- - mongodb- - redis-server- - postgresql-before_install:- - cp install/package.json package.json- - sudo apt-get update- - sudo apt-get --yes remove postgresql\*- - sudo apt-get install -y postgresql-12 postgresql-client-12- - sudo cp /etc/postgresql/{9.6,12}/main/pg_hba.conf- - sudo service postgresql restart 12-before_script:- - sleep 15 # wait for mongodb to be ready- - "mongo mydb_test --eval 'db.createUser({user:\"travis\", pwd: \"test\", roles: []});'"- - sh -c "if [ '$DB' = 'mongodb' ]; then node app --setup=\"{\\\"url\\\":\\\"http://127.0.0.1:4567\\\",\\\"secret\\\":\\\"abcdef\\\",\\\"database\\\":\\\"mongo\\\",\\\"mongo:host\\\":\\\"127.0.0.1\\\",\\\"mongo:port\\\":27017,\\\"mongo:username\\\":\\\"\\\",\\\"mongo:password\\\":\\\"\\\",\\\"mongo:database\\\":0,\\\"admin:username\\\":\\\"admin\\\",\\\"admin:email\\\":\\\"[email protected]\\\",\\\"admin:password\\\":\\\"hAN3Eg8W\\\",\\\"admin:password:confirm\\\":\\\"hAN3Eg8W\\\"}\" --ci=\"{\\\"host\\\":\\\"127.0.0.1\\\",\\\"port\\\":27017,\\\"database\\\":\\\"travis_ci_test\\\"}\"; fi"- - sh -c "if [ '$DB' = 'redis' ]; then node app --setup=\"{\\\"url\\\":\\\"http://127.0.0.1:4567/forum\\\",\\\"secret\\\":\\\"abcdef\\\",\\\"database\\\":\\\"redis\\\",\\\"redis:host\\\":\\\"127.0.0.1\\\",\\\"redis:port\\\":6379,\\\"redis:password\\\":\\\"\\\",\\\"redis:database\\\":0,\\\"admin:username\\\":\\\"admin\\\",\\\"admin:email\\\":\\\"[email protected]\\\",\\\"admin:password\\\":\\\"hAN3Eg8W\\\",\\\"admin:password:confirm\\\":\\\"hAN3Eg8W\\\"}\" --ci=\"{\\\"host\\\":\\\"127.0.0.1\\\",\\\"port\\\":6379,\\\"database\\\":1}\"; fi"- - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'create database nodebb;' -U postgres; psql -c 'create database travis_ci_test;' -U postgres; node app --setup=\"{\\\"url\\\":\\\"http://127.0.0.1:4567\\\",\\\"secret\\\":\\\"abcdef\\\",\\\"database\\\":\\\"postgres\\\",\\\"postgres:host\\\":\\\"127.0.0.1\\\",\\\"postgres:port\\\":5433,\\\"postgres:password\\\":\\\"\\\",\\\"postgres:database\\\":\\\"nodebb\\\",\\\"admin:username\\\":\\\"admin\\\",\\\"admin:email\\\":\\\"[email protected]\\\",\\\"admin:password\\\":\\\"hAN3Eg8W\\\",\\\"admin:password:confirm\\\":\\\"hAN3Eg8W\\\"}\" --ci=\"{\\\"host\\\":\\\"127.0.0.1\\\",\\\"port\\\":5433,\\\"username\\\":\\\"postgres\\\",\\\"database\\\":\\\"travis_ci_test\\\"}\"; fi"-after_success:- - "npm run coveralls"-language: node_js-sudo: false-dist: xenial-env:- global:- - PGUSER=postgres- - PGPORT=5433- - CXX=g++-4.8- jobs:- - "DB=mongodb TEST_ENV=production"- - "DB=mongodb TEST_ENV=development"- - "DB=redis TEST_ENV=production"- - "DB=postgres TEST_ENV=production"-addons:- apt:- sources:- - ubuntu-toolchain-r-test- - mongodb-4.0-xenial- packages:- - g++-4.8- - mongodb-org-server-node_js:- - "14"- - "12"-branches:- only:- - master- - developdiff --git a/install/package.json b/install/package.jsonindex 79957d4e8e..e58fc770b3 100644--- a/install/package.json+++ b/install/package.json@@ -12,8 +12,8 @@"scripts": {"start": "node loader.js","lint": "npx eslint --cache ./nodebb .",- "pretest": "npm run lint","test": "npx nyc --reporter=html --reporter=text-summary npx mocha",+ "coverage": "nyc report --reporter=text-lcov > ./coverage/lcov.info","coveralls": "nyc report --reporter=text-lcov | coveralls && rm -r coverage"},"nyc": {diff --git a/loader.js b/loader.jsindex 982d6374e8..1a3233a876 100644--- a/loader.js+++ b/loader.js@@ -1,6 +1,6 @@'use strict';-var nconf = require('nconf');+var nconf = require('nconf');var fs = require('fs');var url = require('url');var path = require('path');@@ -18,7 +18,7 @@ nconf.argv().env().file({file: pathToConfig,});-var pidFilePath = path.join(__dirname, 'pidfile');+var pidFilePath = path.join(__dirname, 'pidfile');var outputLogFilePath = path.join(__dirname, nconf.get('logFile') || 'logs/output.log');