Skip to content

Commit

Permalink
Merge pull request #141 from fga-eps-mds/develop
Browse files Browse the repository at this point in the history
Release 2
  • Loading branch information
rafaelmakaha authored Dec 16, 2020
2 parents a1e621b + 1e2e3ac commit cafa406
Show file tree
Hide file tree
Showing 60 changed files with 19,875 additions and 4,545 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SECRET=oin1o2i3noinsad
PLANT_NET_API_KEY=2a10LNqc85Sv9x3K88MjTkO

61 changes: 30 additions & 31 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"jest": true,
"node": true
},
"extends": [
"airbnb-base",
"plugin:prettier/recommended"
],
"parserOptions": {
"ecmaVersion": 12
},
"rules": {
"no-console": "off",
"no-underscore-dangle": "off",
"max-len": [
"warn",
{
"code": 80,
"tabWidth": 2,
"comments": 80,
"ignoreComments": false,
"ignoreTrailingComments": true,
"ignoreUrls": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreRegExpLiterals": true
}
]
"extends": [
"airbnb-base",
"plugin:prettier/recommended"
],
"parser": "babel-eslint",
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"jest": true,
"node": true
},
"rules": {
"class-methods-use-this": "off",
"no-console": "off",
"no-underscore-dangle": "off",
"max-len": [
"warn",
{
"code": 80,
"tabWidth": 2,
"comments": 80,
"ignoreComments": false,
"ignoreTrailingComments": true,
"ignoreUrls": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreRegExpLiterals": true
}
]
}
}
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Continuous Integration - Pull Requests Lint and Tests

on:
push:
branches:
- master
- develop
pull_request:

jobs:
lint:
name: CI Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Modules
run: npm install
- name: ESLint
env:
CI: true
run: npm run lint:js:fix

test:
name: CI Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Modules
run: npm install
- name: Run Tests
run: npm run test

sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Generate SonarCloud-formated test coverage report
env:
NODE_ENV: test
run: |
sudo npm install -g yarn jest
yarn install
yarn jest --coverage
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

build:
name: CI Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build container
run: docker-compose build
81 changes: 81 additions & 0 deletions .github/workflows/homologDeploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Homolog Continuous Delivery

on:
push:
branches:
- develop
pull_request:
branches:
- develop
jobs:
test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: '14'
- name: Install Modules
run: |
npm install -g yarn
yarn install
- name: Run test
run: yarn test

coverage:
needs: [test]
name: coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: '14'
- name: Install Modules
run: |
npm install -g yarn
yarn install
- name: Collect code coverage
uses: paambaati/codeclimate-action@v2.7.2
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: yarn coverage
debug: true

build:
name: Push Docker image to GitHub Packages
#needs: test
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Push to GitHub Packages
uses: elgohr/Publish-Docker-Github-Action@master
with:
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ghcr.io
name: fga-eps-mds/2020.1-gaiadex-backend
default_branch: develop
tags: homolog

deploy-backend:
name: Deploy Backend package to Heroku
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Deploy Backend package to Heroku
uses: gonuit/heroku-docker-deploy@v1.2.0 # This is the action
env:
GITHUB_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
with:
email: ${{secrets.EMAIL}}
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: gaiadex-backend-homolog
dockerfile_name: homologDockerfile
dockerfile_directory: ./
22 changes: 0 additions & 22 deletions .github/workflows/linters.yml

This file was deleted.

69 changes: 69 additions & 0 deletions .github/workflows/productionDeploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Production Continuous Delivery

on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
test:
name: Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Modules
run: npm install
- name: Test & publish code coverage
uses: paambaati/codeclimate-action@v2.7.4
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
with:
coverageCommand: npm run test
build:
name: Push Docker image to GitHub Packages
#needs: test
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Push to GitHub Packages
uses: elgohr/Publish-Docker-Github-Action@master
with:
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ghcr.io
name: fga-eps-mds/2020.1-gaiadex-backend
default_branch: master
tags: production
deploy:
name: Deploy Backend package to Heroku
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Deploy Backend package to Heroku Production
uses: gonuit/heroku-docker-deploy@v1.2.0 # This is the action
env:
GITHUB_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
with:
email: ${{secrets.EMAIL}}
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: gaiadex-backend-production
dockerfile_name: productionDockerfile
dockerfile_directory: ./
tagged-release:
name: "Tagged Release"
needs: deploy
runs-on: "ubuntu-latest"
steps:
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: false
files: |
LICENSE.txt
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/node_modules
.env
package-lock.json
yarn.lock
/coverage
test-report.xml
yarn-error.log
12 changes: 0 additions & 12 deletions .stickler.yml

This file was deleted.

Binary file added __tests__/assets/plant.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions __tests__/defaultModels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module.exports = {
defaultUser1: {
username: 'joaozin',
password: 'porta_amarela',
passwordConfirmation: 'porta_amarela',
email: 'astro@email.com',
},

defaultUser2: {
username: 'username',
password: 'password',
passwordConfirmation: 'password',
email: 'email@email.com',
},

defaultPlant1: {
scientificName: 'Butia archeri Glassman',
family_name: 'Arecaceae',
gender_name: 'Butia',
specie_name: 'Butia archeri',
common_name: 'butiazinho',
usage:
'A espécie é conhecida popularmente como butiazinho, coqueirinho-do-campo, butiá-do-campo, butiá-do-cerrado ou palmeira-butiá. Em alguns locais do Cerrado, as folhas desta palmeirinha são utilizadas para a confecção de vassouras, daí atribui-se também o nome popular de palmeira-de-vassoura.',
first_User: ' julceia',
collection_count: '108',
extinction: '0',
profile_picture:
'https://static.inaturalist.org/photos/68945583/large.jpeg?1587849882',
gbifID: '28601793778',
stateProvince: 'Distrito Federal',
topicos: [],
},

defaultPlant2: {
scientificName: 'PlantaVela',
familyName: 'FamiliaVelha',
genderName: 'Male',
specieName: 'EspeciesAntigas',
commonName: 'Velha',
usage: 'Esta planta e muito antiga',
firstUser: 'AqueleSenhor',
collectionCount: 1,
extinction: false,
profilePicture:
'https://cdn.pixabay.com/photo/2017/08/18/20/44/flower-2656484_960_720.jpg',
gbifID: '1234566767',
stateProvince: 'antiga_provincia',
},
};
21 changes: 21 additions & 0 deletions __tests__/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const NodeEnvironment = require('jest-environment-node');

const MemoryDatabaseServer = require('../src/lib/MemoryDatabaseServer');

class CustomEnvironment extends NodeEnvironment {
async setup() {
await super.setup();

this.global.__DB_URL__ = await MemoryDatabaseServer.getConnectionString();
}

async teardown() {
await super.teardown();
}

runScript(script) {
return super.runScript(script);
}
}

module.exports = CustomEnvironment;
Loading

0 comments on commit cafa406

Please sign in to comment.