Skip to content

Commit

Permalink
fix(circleci): update ci (#264)
Browse files Browse the repository at this point in the history
* fix(circleci): update ci

* chore(test): remove old test files

* chore(deps): update husky

* chore(deps): fix faker deprecation

* chore(deps): update deps and change npm install method

* chore(deps): update deps
  • Loading branch information
WikiRik committed May 11, 2021
1 parent 9f24b1b commit 4f7764e
Show file tree
Hide file tree
Showing 14 changed files with 2,686 additions and 5,208 deletions.
95 changes: 57 additions & 38 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
orbs:
slack: circleci/slack@3.4.2
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
version: 2.1
jobs:
test:
machine:
image: ubuntu-2004:202010-01
image: ubuntu-2004:202101-01
steps:
- checkout
- run: docker run --name postgres -e POSTGRES_PASSWORD='5ecr3t' -p 5432:5432 -d postgres:13
- run: docker run --name postgres -e POSTGRES_PASSWORD='5ecr3t' -p 5432:5432 -d postgres:10.16
- run:
name: Install Node
command: |
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
- run: npm install
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
Expand All @@ -26,50 +29,56 @@ jobs:
- store_artifacts:
path: ~/reports
build:
machine:
image: ubuntu-2004:202010-01
docker:
- image: cimg/base:2021.03
steps:
- checkout
- setup_remote_docker:
version: 20.10.2
- run: docker-compose -f docker/docker-compose.yml -f docker/docker-compose.dev.yml build --no-cache core
eslint:
machine:
image: ubuntu-2004:202010-01
docker:
- image: cimg/node:14.16.0
steps:
- checkout
- run:
name: Install Node
command: |
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
- run: npm install
- node/install-packages
- run: mkdir -p ~/reports
- run: npm run lint -- --format junit --output-file ~/reports/eslint.xml
- store_test_results:
path: ~/reports
- store_artifacts:
path: ~/reports
yamllint:
machine:
image: ubuntu-2004:202010-01
docker:
- image: cimg/python:3.9.2
steps:
- checkout
- run: pip install yamllint
- run: yamllint -d .yamllint.yml .
shellcheck:
docker:
- image: cimg/base:2021.03
steps:
- checkout
- shellcheck/install
- shellcheck/check
audit:
docker:
- image: cimg/node:14.16.0
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:
machine:
image: ubuntu-2004:202010-01
docker:
- image: cimg/node:14.16.0
steps:
- checkout
- run:
name: Install Node
command: |
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
- run: npm install
- setup_remote_docker:
version: 20.10.2
- 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: docker login --username $DOCKER_LOGIN --password $DOCKER_PASSWORD
Expand All @@ -81,24 +90,34 @@ jobs:

workflows:
version: 2
test:
jobs:
- test
eslint:
linters:
jobs:
- eslint
- yamllint
- shellcheck
- docker/hadolint:
dockerfiles: $(find . -name '*Dockerfile*')
build:
jobs:
- build:
filters:
branches:
ignore: master
yamllint:
test:
jobs:
- yamllint
- 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",
"extends": "airbnb-base",
"rules": {
"no-underscore-dangle": "off",
"no-param-reassign": ["error", { "props": false }],
Expand Down
2 changes: 2 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignored:
- DL3025
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint-staged
2 changes: 0 additions & 2 deletions .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@ ignore: |
rules:
document-start: disable
line-length: disable
truthy: disable
comments-indentation: disable
15 changes: 7 additions & 8 deletions docker/core/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
FROM node:14
# FIXME use alpine
FROM node:14.16.1

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

RUN apt-get update
RUN apt-get install netcat -y

COPY ./docker/core/bootstrap.sh /usr/app/scripts/bootstrap.sh
COPY ./docker/core/wait.sh /usr/app/scripts/wait.sh
COPY . /usr/app/src
RUN mkdir /usr/app/src/state

RUN chown -R node:node /usr/app

Expand All @@ -21,8 +17,11 @@ USER node
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
ENV PATH="/home/node/.npm-global/bin:${PATH}"

RUN npm install -g --loglevel warn nodemon bunyan && npm cache clean --force
RUN npm install --loglevel warn
# FIXME remove nodemon for production
RUN npm install -g nodemon@2.0.7 \
&& npm install -g bunyan@1.8.15 \
&& npm cache clean --force \
&& npm ci

CMD sh /usr/app/scripts/bootstrap.sh && nodemon -e "js,json" lib/run.js

Expand Down
10 changes: 0 additions & 10 deletions docker/core/wait.sh

This file was deleted.

Loading

0 comments on commit 4f7764e

Please sign in to comment.