From 908edf9321be5342426127d081997bde116ff23b Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Mon, 18 Sep 2023 09:28:15 +0300 Subject: [PATCH] fix(tests): Added Github action to run tests (#341) --- .github/workflows/test.yml | 48 ++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 49 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ff17778 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,48 @@ +name: Run tests + +on: + push: + pull_request: + +jobs: + test: + strategy: + matrix: + node: [16.x, 18.x, 20.x] + os: [ubuntu-20.04] + runs-on: ${{ matrix.os }} + # Service containers to run with `container-job` + services: + # Label used to access the service container + redis: + # Docker Hub image + image: redis + # 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: + - 6379:6379 + steps: + - uses: actions/checkout@v4 + + - name: Start MongoDB + uses: supercharge/mongodb-github-action@1.7.0 + with: + mongodb-version: 4.4 + mongodb-port: 27017 + mongodb-db: wildduck-test + + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + - run: which mongo + - run: npm install + - name: Run tests + run: npm run runtest + env: + APPCONF_dbs_redis: redis://127.0.0.1:6379/1 + APPCONF_dbs_mongodb: 'mongodb://127.0.0.1:27017/wildduck-test?authSource=admin' diff --git a/package.json b/package.json index 17f5af3..3d9f9fb 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "main": "app.js", "scripts": { "test": "grunt", + "runtest": "NODE_ENV=test grunt", "start": "node app.js", "show": "NODE_CONFIG_ONLY=true node app.js", "certs": "mkdir -p keys && cd keys && openssl req -x509 -newkey rsa:2048 -nodes -subj \"/C=US/ST=Oregon/L=Portland/O=Company Name/OU=Org/CN=www.example.com\" -keyout private.key -out server.crt -days 365"