This repository has been archived by the owner on Nov 10, 2021. It is now read-only.
forked from likecoin/puttyimages-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔀 Add continuous integration pipeline
- The continuous deployment setup is against with oursky/puttimages-web to https://puttyimages.pandawork.com - It comes with example unit and integration test - Test are run at Travis-CI - It includes seeding data for kick start dev and test refs #5
- Loading branch information
Showing
24 changed files
with
2,480 additions
and
215 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"presets": [ | ||
"babel-preset-backpack" | ||
], | ||
"env": { | ||
"test": { | ||
"presets": [ | ||
["env"] | ||
] | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,6 @@ dist | |
|
||
# Backpack build | ||
build | ||
|
||
# tests | ||
coverage |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: ipfs-pv-claim | ||
namespace: likecoin | ||
labels: | ||
app: puttyimages | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 10Gi | ||
--- | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: pgsql-pv-claim | ||
namespace: likecoin | ||
labels: | ||
app: puttyimages | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 10Gi | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: puttyimages-ipfs | ||
namespace: likecoin | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: puttyimages-ipfs | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: puttyimages-ipfs | ||
spec: | ||
containers: | ||
- name: ipfs | ||
image: ipfs/go-ipfs:v0.4.15 | ||
ports: | ||
- containerPort: 8080 | ||
volumeMounts: | ||
- name: ipfs-persistent-storage | ||
mountPath: /data/ipfs | ||
volumes: | ||
- name: ipfs-persistent-storage | ||
persistentVolumeClaim: | ||
claimName: ipfs-pv-claim | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: puttyimages-db | ||
namespace: likecoin | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: puttyimages-db | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: puttyimages-db | ||
spec: | ||
containers: | ||
- name: pgsql | ||
image: postgres:10.4 | ||
ports: | ||
- containerPort: 5432 | ||
volumeMounts: | ||
- name: pgsql-persistent-storage | ||
mountPath: /data | ||
volumes: | ||
- name: pgsql-persistent-storage | ||
persistentVolumeClaim: | ||
claimName: pgsql-pv-claim | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: puttyimages-web | ||
namespace: likecoin | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: puttyimages-web | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: puttyimages-web | ||
spec: | ||
containers: | ||
- name: web | ||
image: oursky/puttyimages-web:latest | ||
ports: | ||
- containerPort: 3000 | ||
env: | ||
- name: HOST | ||
value: 0.0.0.0 | ||
- name: IPFS_HOST | ||
value: ipfs | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: web | ||
name: web | ||
namespace: likecoin | ||
spec: | ||
ports: | ||
- port: 80 | ||
protocol: TCP | ||
targetPort: 3000 | ||
selector: | ||
app: puttyimages-web | ||
sessionAffinity: None | ||
type: ClusterIP | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: ipfs | ||
namespace: likecoin | ||
labels: | ||
app: puttyimages-ipfs | ||
spec: | ||
ports: | ||
- port: 8080 | ||
selector: | ||
app: puttyimages-ipfs | ||
clusterIP: None | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: db | ||
namespace: likecoin | ||
labels: | ||
app: puttyimages-db | ||
spec: | ||
ports: | ||
- port: 5432 | ||
selector: | ||
app: puttyimages-db | ||
clusterIP: None | ||
--- | ||
apiVersion: extensions/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
labels: | ||
app: puttyimages | ||
name: puttyimages | ||
namespace: likecoin | ||
annotations: | ||
ingress.kubernetes.io/proxy-body-size: 10m | ||
spec: | ||
rules: | ||
- host: puttyimages.pandawork.com | ||
http: | ||
paths: | ||
- path: / | ||
backend: | ||
serviceName: web | ||
servicePort: 80 | ||
tls: | ||
- hosts: | ||
- puttyimages.pandawork.com |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
language: generic | ||
services: | ||
- docker | ||
sudo: required | ||
install: | ||
- docker-compose build | ||
script: | ||
- docker-compose up -d | ||
- docker-compose exec nuxt npm run lint | ||
- docker-compose exec nuxt npm run sequelize db:migrate | ||
- docker-compose exec nuxt npm run sequelize db:seed:all | ||
- docker-compose exec nuxt npm test | ||
- docker-compose down | ||
deploy: | ||
- provider: script | ||
script: ./scripts/deploy-docker-hub.sh | ||
skip_cleanup: true | ||
on: | ||
repo: oursky/puttyimages-web | ||
branch: master | ||
after_deploy: | ||
- ./scripts/trigger-github-deploy.sh | ||
env: | ||
global: | ||
# DOCKER_USERNAME | ||
- secure: PC9cYzOPyVQAfx+kFoHC5gGvnvcgQiOPQeNZv/to+S+Sh9g7NE+ATrLZLDJDQlCePhOSB+2HA1n/cmMXhyT4D3eiYXSlCbkme5Zr78Ss+FkSVPxNdp4O6FxC4qiACeCpNQ4090HI+SfJOcZdF6DAMR0Sgff4qKd0w03bsRTdkKtfPnUkhB3/R86rzXkNFGSSHcp802yVdNIDoyY5P/5zasKCN/oslw1WhhmwMC8Mh63rNSnTAFru1101wbUMGUr1wMluoygsYDW6A5/kzgNBQyJVV4eH7CSD29COSLyjGUyf+iGYBMSWfJ4bCOjKkvv6lgSiah8Bf65W26PGZ/zzSwF/3h+X+Pprlp1Aj16SIzGB+pRg4zvPMGKs1NmEANrpkBPGBLnaPlfXocTI5WImX4ykFz9qCZtjQl7U7U67sSshevyebmvVrfD2i+65iRHecnEMjTf9doHtYg0V1Rr82q8Am4vW/U5vTq3kIx2xBsgsPed0bYaoUv9EEiJIS9NSWx6caNCC+A4b0t4rHAapspwAJBbotuhZKDMSfsNygfdyhff6bbXALsHtrwb0ocpxPkH8igbp/phzdiUmzW34TiXJZKES5o10wUhbDgPJDETWAsgsC1+svd2tczEvaXy8Sk2n4X+TilrLPVt57ugPDZee5MSDAm8wq4NjBj7r46s= | ||
# DOCKER_PASSWORD | ||
- secure: d8zIElU2Hx15AVsWE/8rN6gyaHPMwGNZrLp3DRtTj36X1vDbGlLkR9KsR09lgAUSkK94xHVP0GxbKtUOrk/ZYg2ZGAvEYLrq/HNE2CQa+3AiDuooDcfcfvExr2QrpS9scgX28foblLY3KmZ8YvxPISQ3W2fWe6iSdPYx01AvlFYk9DsEhQtQ7PEKpJgd7FKhWokwj4mKCevtShCwBRAAwIB++LdmIKuJSwpRDBw5jVvVoUda9EGbMnStAk1xFmbu6p0zZOhnIkkr4EhnN1s2/T5lHTVupLnF3uAusmUAhC5c3RLYNmNB+9MzcSKBmhXv6TaeDmGovxN9VW10mIhsDAQqARqNNjXxeG2ZpSrKa/RUQYkTVv5fFi2896Btubva1caExE1tpM/yQL5YHnwQrMJty8/Yi8gSWbaRVXnY27YHHwt5Y9hFtQkqkIj8ceRcUTJGAtCvjnPXeISlQduJOZLIqZaIOSCdIfQUGEYVC9/GReTj0N9NfMz0MCH4indEGMzRDyqz4glzLiUYHST/Ct2twAeigFxWGKnMlFoImRa8wAHUJeh5M4+iygGcv5D/OLJn9E3HRnBigPQuJTF2R4KghJA3Y6wXGr0FTCfDrnjcJYoF8u8zGl4HJfYMFRF94zBGYRoy5/WZlHBEtFpT2682NXmR1Ufz1igDBpGw8E0= | ||
# GITHUB_TOKEN | ||
- secure: lK4h+uffcxiu9cpffJGsR+W2v5B1dpfXIhPcmw7ao7/YkPi0kBWpLXEUlSUUWozG+kk2Fxw0xk3yuGOsv8cV1rH/EChrWB8Z8B60OX92WJNBCmjQmdvxFcyrSnJyikrBjw0CuHypv6/vPqdQfBlia/Y2rGmdvMTdEd8fUdwD5XK2zVz+fisQboiurNx05YkNW3LV0cSAxPP9Nk9Sm4PcHLzgClss0/Ol2AamkiLfWNArddVqui5v2PtEVW4Tt+MnlSSGWqD6k5pkjibim3vCXSkkrmidYW1P2VQyjyKqYhBeFPpMlF8w544nEWGzAbFvWs8we+5PTndjERWd1g67FndGoqSehZmXNJ0k3a/jMSe8T+opIqxV2nnyM1GB3Fqm+mqVGSChM3mRu8YO3E8bm1wJQuiFlLthnENELuCHEOZsH61Xm99q3mut1wOodLnIOtr3/7HOODayI2i4Twy8tsmtiuZkVj97SYwPRqNPueeCwx2Aib7z9I6UeayC1a/2xPVrA7MITYybCs0SdW412IzzJkokZBphEBIgZDoBuvHjE67vPPj2OJso+wHUvjSEUgfQYfV6RZB4UPXWPy7bCFENljgN8wwANUxyjfNAmpOe8wOIyOFoNVbZzaUd9bVxbUkFZXt2q3kjoWFN1T5Soea+CpiFrCxmDUFvSzqr8RE= |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.PHONY: test | ||
|
||
docker_compose_test := docker-compose --project-name puttyimages_test | ||
|
||
test: | ||
$(docker_compose_test) down -v | ||
$(docker_compose_test) build 1>/dev/null 2>&1 | ||
$(docker_compose_test) up -d | ||
$(docker_compose_test) exec nuxt npm run lint | ||
$(docker_compose_test) exec nuxt npm run sequelize db:migrate | ||
$(docker_compose_test) exec nuxt npm run sequelize db:seed:all | ||
$(docker_compose_test) exec nuxt npm run test | ||
$(docker_compose_test) stop |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
let mockFiles = {}; | ||
|
||
const IPFSApi = { | ||
setMockFiles(files) { | ||
mockFiles = files; | ||
}, | ||
files: { | ||
cat: jest.fn().mockImplementation((path) => Promise.resolve(mockFiles[path])), | ||
}, | ||
}; | ||
|
||
module.exports = IPFSApi; |
25 changes: 25 additions & 0 deletions
25
__tests__/integration/api/__snapshots__/users.test.js.snap
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`get user info by id 1`] = ` | ||
Object { | ||
"id": 1, | ||
"name": "Alexandre", | ||
} | ||
`; | ||
|
||
exports[`get users list 1`] = ` | ||
Array [ | ||
Object { | ||
"id": 1, | ||
"name": "Alexandre", | ||
}, | ||
Object { | ||
"id": 2, | ||
"name": "Pooya", | ||
}, | ||
Object { | ||
"id": 3, | ||
"name": "Sébastien", | ||
}, | ||
] | ||
`; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const axios = require('axios'); | ||
|
||
const host = process.env.HOST || '127.0.0.1'; | ||
const port = process.env.PORT || 3000; | ||
|
||
module.exports = { | ||
get: (url) => axios.get(`http://${host}:${port}/api/${url}`), | ||
post: (url, data) => axios.post(`http://${host}:${port}/api/${url}`, data), | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const api = require('./api'); | ||
|
||
test('get users list', async () => { | ||
const response = await api.get('users'); | ||
expect(response.data).toMatchSnapshot(); | ||
}); | ||
|
||
test('get user info by id', async () => { | ||
const response = await api.get('users/1'); | ||
expect(response.data).toMatchSnapshot(); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const ipfs = require('ipfs-api'); | ||
|
||
const MOCK_FILE_INFO = { | ||
'/file': 'file content', | ||
}; | ||
|
||
test('should cat file', () => { | ||
ipfs.setMockFiles(MOCK_FILE_INFO); | ||
expect(ipfs.files.cat).not.toHaveBeenCalled(); | ||
|
||
return ipfs.files.cat('/file').then((file) => { | ||
expect(file).toEqual('file content'); | ||
expect(ipfs.files.cat).toHaveBeenCalledTimes(1); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const sequelize = require('sequelize'); | ||
|
||
const models = require('../../server/models'); | ||
|
||
test('get sequelize instance', async () => { | ||
expect(models.sequelize).toBeInstanceOf(sequelize); | ||
expect(models.Sequelize).toBeInstanceOf(Function); | ||
const User = models.user; | ||
expect(new User()).toBeInstanceOf(sequelize.Model); | ||
if (User.associate) { | ||
expect(User.associate).toBeInstanceOf(Function); | ||
} | ||
}); |
Oops, something went wrong.