Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix(circleci): add audit, shellcheck and hadolint (#447)" #485

Merged
merged 1 commit into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 19 additions & 47 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
orbs:
slack: circleci/slack@3.4.2 # FIXME update to v4
slack: circleci/slack@3.4.2
node: circleci/node@4.1.0
shellcheck: circleci/shellcheck@2.2.2
docker: circleci/docker@1.5.0
version: 2.1
jobs:
test:
machine:
image: ubuntu-2004:202101-01
image: ubuntu-2004:202010-01
steps:
- checkout
- run: docker run --name postgres -e POSTGRES_PASSWORD='5ecr3t' -p 5432:5432 -d postgres:10.15
- run: docker run --name postgres -e POSTGRES_PASSWORD='5ecr3t' -p 5432:5432 -d postgres:13
- 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.15.1
nvm alias default v14.15.1
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
echo 'export PATH=/usr/bin:$PATH' >> $BASH_ENV
which node && node -v
- node/install-packages
- run: mkdir -p ~/reports/jest
- run:
Expand All @@ -30,15 +28,15 @@ jobs:
path: ~/reports
build:
docker:
- image: cimg/base:2021.02
- image: cimg/base:2020.11
steps:
- checkout
- setup_remote_docker:
version: 20.10.2
version: 19.03.13
- run: docker-compose -f docker/docker-compose.yml -f docker/docker-compose.dev.yml build --no-cache statutory
eslint:
docker:
- image: cimg/node:14.15.4
- image: cimg/node:14.15
steps:
- checkout
- node/install-packages
Expand All @@ -50,34 +48,18 @@ jobs:
path: ~/reports
yamllint:
docker:
- image: cimg/python:3.9.1
- image: cimg/python:3.9.0
steps:
- checkout
- run: pip install yamllint
- run: yamllint -d .yamllint.yml .
shellcheck:
docker:
- image: cimg/base:2021.02
steps:
- checkout
- shellcheck/install
- shellcheck/check
audit:
docker:
- image: cimg/node:14.15.4
steps:
- checkout
- run: npm audit --production
- slack/status:
fail_only: true
failure_message: The audit check for \`$CIRCLE_PROJECT_REPONAME\` has failed.
docker-build-and-push:
docker:
- image: cimg/node:14.15.4
- image: cimg/node:14.15
steps:
- checkout
- setup_remote_docker:
version: 20.10.2
version: 19.03.13
- node/install-packages
- run: npx semantic-release
- run: docker build --tag aegee/statutory:$(node -p "require('./package.json').version") --tag aegee/statutory:latest -f docker/statutory/Dockerfile .
Expand All @@ -90,34 +72,24 @@ jobs:

workflows:
version: 2
linters:
test:
jobs:
- test
eslint:
jobs:
- eslint
yamllint:
jobs:
- yamllint
- shellcheck
- docker/hadolint:
dockerfiles: $(find . -name '*Dockerfile*')
build:
jobs:
- build:
filters:
branches:
ignore: master
test:
jobs:
- test
docker-build-and-push:
jobs:
- docker-build-and-push:
filters:
branches:
only: master
audit:
triggers:
- schedule:
cron: "0 0 * * 5"
filters:
branches:
only: master
jobs:
- audit
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"node": true,
"jest": true
},
"extends": "airbnb-base",
"extends": "airbnb",
"rules": {
"no-underscore-dangle": "off",
"no-param-reassign": ["error", { "props": false }],
Expand Down
2 changes: 2 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ ignore: |
rules:
document-start: disable
line-length: disable
truthy: disable
comments-indentation: disable
4 changes: 2 additions & 2 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const lodash = require('lodash');
const deepAssign = require('deep-assign');

const config = {
default: {
Expand Down Expand Up @@ -70,7 +70,7 @@ let appConfig = config.default || {};

// If we have the environment config, overwrite the config's fields with its fields
if (config[env]) {
appConfig = lodash.merge(appConfig, config[env]);
appConfig = deepAssign(appConfig, config[env]);
}

module.exports = appConfig;
2 changes: 1 addition & 1 deletion docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
context: ./${PATH_STATUTORY}/..
dockerfile: ./docker/statutory/Dockerfile
image: aegee/statutory:dev
command: "nodemon -e 'js,json' lib/run.js | bunyan --color"
command: sh -c "sh /usr/app/scripts/bootstrap.sh && nodemon -e 'js,json' lib/run.js | bunyan"
volumes:
- ./${PATH_STATUTORY}/../config:/usr/app/src/config
- ./${PATH_STATUTORY}/../lib:/usr/app/src/lib
Expand Down
24 changes: 10 additions & 14 deletions docker/statutory/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
# FIXME use alpine
FROM node:14.15.4

RUN mkdir -p /usr/app/src \
&& mkdir -p /usr/app/media \
&& mkdir -p /usr/app/scripts

WORKDIR /usr/app/src
RUN apt-get update
RUN apt-get install netcat -y

COPY package.json /usr/app/src
COPY ./docker/statutory/bootstrap.sh /usr/app/scripts/bootstrap.sh
COPY ./docker/statutory/wait.sh /usr/app/scripts/wait.sh
COPY . /usr/app/src

RUN chown -R node:node /usr/app

WORKDIR /usr/app/src

USER node

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 bunyan@1.8.15
RUN npm cache clean --force
RUN npm install

COPY --chown=node:node ./docker/statutory/bootstrap.sh /usr/app/scripts/bootstrap.sh
COPY --chown=node:node . /usr/app/src
RUN mkdir /usr/app/src/state
RUN npm install -g --loglevel warn nodemon bunyan && npm cache clean --force
RUN npm install --loglevel warn

# FIXME split up in ENTRYPOINT and CMD
CMD ["sh", "/usr/app/scripts/bootstrap.sh && nodemon -e 'js,json' lib/run.js"]
CMD sh /usr/app/scripts/bootstrap.sh && nodemon -e "js,json" lib/run.js

EXPOSE 8084
2 changes: 0 additions & 2 deletions docker/statutory/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@ echo "Creating database..."
npm run db:create
echo "Migrating database..."
npm run db:migrate

sh -c "${@}"
10 changes: 10 additions & 0 deletions docker/statutory/wait.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

echo "Waiting for bootstrap"

while ! nc -z localhost 8084; do
sleep 0.1
done

echo "Bootstrap finished"

4 changes: 2 additions & 2 deletions lib/events.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const moment = require('moment');
const lodash = require('lodash');
const deepAssign = require('deep-assign');

const errors = require('./errors');
const constants = require('./constants');
Expand Down Expand Up @@ -166,7 +166,7 @@ exports.listUserAppliedEvents = async (req, res) => {
select: constants.EVENT_PUBLIC_FIELDS
};

const queryObj = lodash.merge(defaultQueryObj, {
const queryObj = deepAssign(defaultQueryObj, {
where: {
'$applications.user_id$': req.user.id
},
Expand Down
Loading