Skip to content

Commit

Permalink
fix(deps): update to Node 16 and upgrade deps and CI config (#387)
Browse files Browse the repository at this point in the history
* fix(deps): update to Node 16 and upgrade deps and CI config

* ci(test): add unit tests

* chore(docker-compose): revert docker-compose version

* chore(deps): update deps

Co-authored-by: WikiRik <WikiRik@users.noreply.github.com>
  • Loading branch information
WikiRik and WikiRik committed Dec 1, 2021
1 parent fca142d commit e8d05fd
Show file tree
Hide file tree
Showing 97 changed files with 19,960 additions and 3,135 deletions.
176 changes: 145 additions & 31 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
orbs:
slack: circleci/slack@3.4.2 # FIXME update to v4
node: circleci/node@4.2.0
shellcheck: circleci/shellcheck@2.2.2
docker: circleci/docker@1.5.0
codecov: codecov/codecov@3.2.0
docker: circleci/docker@1.6.0
node: circleci/node@4.7.0
shellcheck: circleci/shellcheck@2.2.4
slack: circleci/slack@4.4.4
version: 2.1
jobs:
test:
machine:
image: ubuntu-2004:202101-01
docker:
- image: cimg/node:16.13.0
- image: circleci/postgres:10.18
environment:
POSTGRES_PASSWORD: config.test.postgres.password
parallelism: 4
steps:
- checkout
- run: docker run --name postgres -e POSTGRES_PASSWORD='5ecr3t' -p 5432:5432 -d postgres:10.16
- run:
name: Install Node
command: |
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
echo ' [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
nvm install v14.16.0
nvm alias default v14.16.0
- node/install-packages
- run: mkdir -p ~/reports/jest
- run:
name: Run tests
command: JEST_JUNIT_OUTPUT_DIR=$HOME/reports/jest npm test -- --reporters=default --reporters=jest-junit
- run: ./node_modules/.bin/codecov
command: |
TEST=$(circleci tests glob test/**/*.js | circleci tests split --split-by=timings)
JEST_JUNIT_OUTPUT_DIR=$HOME/reports/jest npm run test:ci $TEST -- --reporters=default --reporters=jest-junit
- codecov/upload
- store_test_results:
path: ~/reports
- store_artifacts:
path: ~/reports
build:
docker:
- image: cimg/base:2021.03
- image: cimg/base:2021.10
steps:
- checkout
- setup_remote_docker:
version: 20.10.2
version: 20.10.7
- run: docker-compose -f docker/docker-compose.yml -f docker/docker-compose.dev.yml build --no-cache core
eslint:
docker:
- image: cimg/node:14.16.0
- image: cimg/node:16.13.0
steps:
- checkout
- node/install-packages
Expand All @@ -50,43 +49,158 @@ jobs:
path: ~/reports
yamllint:
docker:
- image: cimg/python:3.9.2
- image: cimg/python:3.10.0
steps:
- checkout
- run: pip install yamllint
- run: yamllint -d .yamllint.yml .
shellcheck:
docker:
- image: cimg/base:2021.03
- image: cimg/base:2021.10
steps:
- checkout
- shellcheck/install
- shellcheck/check
audit:
docker:
- image: cimg/node:14.16.0
- image: cimg/node:16.13.0
steps:
- checkout
- run: npm audit --production
- slack/status:
fail_only: true
failure_message: The audit check for \`$CIRCLE_PROJECT_REPONAME\` has failed.
- slack/notify:
event: fail
custom: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":x: The audit check for `$CIRCLE_PROJECT_REPONAME` has failed."
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Project*\n$CIRCLE_PROJECT_REPONAME"
},
{
"type": "mrkdwn",
"text": "*Job Number*\n$CIRCLE_BUILD_NUM"
}
]
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Visit Job"
},
"url": "${CIRCLE_BUILD_URL}"
}
]
}
]
}
docker-build-and-push:
docker:
- image: cimg/node:16.13.0
steps:
- checkout
- setup_remote_docker:
version: 20.10.2
version: 20.10.7
- node/install-packages
- run: npx semantic-release
- run: docker build --tag aegee/core:$(node -p "require('./package.json').version") --tag aegee/core:latest -f docker/core/Dockerfile .
- run: echo export PACKAGE_VERSION=$(node -p "require('./package.json').version") >> $BASH_ENV
- run: docker build --tag aegee/core:$PACKAGE_VERSION --tag aegee/core:latest -f docker/core/Dockerfile .
- run: docker login --username $DOCKER_LOGIN --password $DOCKER_PASSWORD
- run: docker push aegee/core:$(node -p "require('./package.json').version")
- run: docker push aegee/core:$PACKAGE_VERSION
- run: docker push aegee/core:latest
- slack/status:
success_message: The Docker image for \`$CIRCLE_PROJECT_REPONAME\` with tags \`$(node -p "require('./package.json').version")\` and \`latest\` has been pushed to Dockerhub.
failure_message: The Docker image for \`$CIRCLE_PROJECT_REPONAME\` build and push has failed.
- slack/notify:
event: pass
custom: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":white_check_mark: The Docker image for `$CIRCLE_PROJECT_REPONAME` with tags `$PACKAGE_VERSION` and `latest` has been pushed to Dockerhub."
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Project*\n$CIRCLE_PROJECT_REPONAME"
},
{
"type": "mrkdwn",
"text": "*Job Number*\n$CIRCLE_BUILD_NUM"
}
]
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Visit Job"
},
"url": "${CIRCLE_BUILD_URL}"
}
]
}
]
}
- slack/notify:
event: fail
custom: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":octagonal_sign: The Docker image for `$CIRCLE_PROJECT_REPONAME` build and push has failed."
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Project*\n$CIRCLE_PROJECT_REPONAME"
},
{
"type": "mrkdwn",
"text": "*Job Number*\n$CIRCLE_BUILD_NUM"
}
]
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Visit Job"
},
"url": "${CIRCLE_BUILD_URL}"
}
]
}
]
}
workflows:
version: 2
Expand Down
Empty file modified .husky/commit-msg
100644 → 100755
Empty file.
Empty file modified .husky/pre-commit
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'header-max-length': [0, 'always', 72],
'header-max-length': [0]
}
};
4 changes: 2 additions & 2 deletions docker/core/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# FIXME use alpine
FROM node:14.18.1
FROM node:16.13.0

RUN mkdir -p /usr/app/src \
&& mkdir -p /usr/app/media \
Expand All @@ -18,7 +18,7 @@ ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH="/home/node/.npm-global/bin:${PATH}"

# FIXME remove nodemon for production
RUN npm install -g nodemon@2.0.7 \
RUN npm install -g nodemon@2.0.14 \
&& npm install -g bunyan@1.8.15 \
&& npm cache clean --force \
&& npm ci
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: "3.4"
### OMS STATUTORY #######################################
### CORE #######################################
services:
core:
build:
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.4"
services:
postgres-core:
restart: always
image: postgres:10.15
image: postgres:10.18
volumes:
- postgres-core:/var/lib/postgresql/data
expose:
Expand Down
4 changes: 2 additions & 2 deletions models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const constants = require('../lib/constants');
const { Sequelize, sequelize } = require('../lib/sequelize');
const config = require('../config');

const NAME_REGEX = new RegExp('^[\\p{L}. \\-\']*$', 'u');
const USERNAME_REGEX = new RegExp('^[a-zA-Z0-9._-]*$');
const NAME_REGEX = /^[\p{L}. -']*$/u;
const USERNAME_REGEX = /^[a-zA-Z0-9._-]*$/;

const User = sequelize.define('user', {
username: {
Expand Down
Loading

0 comments on commit e8d05fd

Please sign in to comment.