NodeJS Continuous Integration #141
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
name: NodeJS Continuous Integration | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
# see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
ci_to_main: | |
runs-on: ubuntu-latest | |
container: | |
image: 'ubuntu:24.04' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Update apt and install required packages | |
run: | | |
apt update --yes | |
apt install --yes sudo | |
sudo apt install --yes --no-install-recommends npm | |
- name: Import MongoDB's public key for the package management system | |
run: | | |
sudo apt install --yes --no-install-recommends curl gnupg | |
sudo rm -f /etc/ssl/certs/ca-bundle.crt | |
sudo apt reinstall --yes ca-certificates | |
sudo update-ca-certificates | |
curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \ | |
sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \ | |
--dearmor | |
- name: Install MongoDB | |
run: | | |
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list | |
sudo apt-get update | |
sudo apt-get install -y mongodb-org | |
- name: Check Mongo version | |
run: mongod --version | |
- name: Start MongoDB | |
run: sudo nohup mongod --quiet --config /etc/mongod.conf & | |
- name: Create database | |
run: | | |
# this sleep is added to avoid race condition without this we sometimes get the following error: | |
# connecting to: mongodb://127.0.0.1:27017 | |
# 2023-05-30T13:02:52.975+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused | |
# 2023-05-30T13:02:52.976+0000 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : | |
# connect@src/mongo/shell/mongo.js:257:13 | |
# @(connect):1:6 | |
# exception: connect failed | |
sleep 10 | |
mongosh --eval 'db.getSiblingDB("lnp2pbot").createCollection("mycollection")' | |
- run: npm install @types/node @types/i18n @types/mocha | |
- run: npx tsc | |
- run: npm ci | |
- name: Run tests | |
env: | |
DB_USER: '' | |
DB_PASS: '' | |
DB_HOST: '127.0.0.1' | |
DB_PORT: '27017' | |
DB_NAME: 'lnp2pbot' | |
run: npm test |