Skip to content

Commit 17f3814

Browse files
Merge pull request #14 from ontoportal-lirmm/feature/ecoportal/align-to-agroportal-3.0
Feature: Align to AgroPortal 3.0
2 parents d9dc5c3 + 9e77603 commit 17f3814

File tree

75 files changed

+33904
-1829
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+33904
-1829
lines changed

.dockerignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Git
22
.git
33
.gitignore
4+
.github
45
create_permissions.log
56
# Logs
67
log/*
@@ -9,4 +10,8 @@ tmp/*
910
# Editor temp files
1011
*.swp
1112
*.swo
12-
test/solr
13+
coverage
14+
# Ignore generated test data
15+
test/data/uploaded_ontologies/**/*
16+
test/data/ontology_files/repo/**/*
17+
test/log

.github/workflows/deploy.yml

Lines changed: 65 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,92 @@
1-
# Workflow for deploying ontologies_api to stage/prod systems via capistrano.
2-
# This workflow runs after a successeful execution of the unit test workflow and it
3-
# can also be triggered manually.
1+
# Workflow to deploy OntoPortal API to stage/prod systems
42
#
53
# Required github secrets:
64
#
7-
# CONFIG_REPO - github repo containing config and customizations for the API. Format 'author/private_config_repo'
5+
# CONFIG_REPO - github repo containing config and customizations for API. Format 'author/private_config_repo'
86
# it is used for getting capistrano deployment configuration for stages on the github actions runner and
9-
# PRIVATE_CONFIG_REPO env var is constructed from it which is used by capistrano on the remote servers for pulling configs.
7+
# PRIVATE_CONFIG_REPO env var is constructed from it which is used by capistrano on the API hosts for pulling configs.
108
#
11-
# GH_PAT - github Personal Access Token for accessing PRIVATE_CONFIG_REPO
9+
# GH_PAT - github Personal Access Token for accessing private config repo
1210
#
13-
# SSH_JUMPHOST - ssh jump/proxy host though which deployments have to though if app servers are hosted on private network.
11+
# SSH_JUMPHOST - ssh jump/proxy host though which deployments have to though if API nodes live on private network.
12+
# SSH_JUMPHOST_USER - username to use to connect to the ssh jump/proxy.
1413
#
15-
# DEPLOY_ENC_KEY - key for decrypting deploymnet ssh key residing in config/deploy_id_rsa_enc (see miloserdow/capistrano-deploy)
16-
# this SSH key is used for accessing jump host, UI nodes, and private github repo.
14+
# DEPLOY_ENC_KEY - key for decrypting deploymnet ssh key residing in config/
15+
# this SSH key is used for accessing jump host, API nodes, and private github repo.
1716

1817
name: Capistrano Deployment
1918
# Controls when the action will run.
2019
on:
21-
# Trigger deployment to staging after unit test action completes
22-
workflow_run:
23-
workflows: ["Ruby Unit Tests"]
24-
types:
25-
- completed
26-
branches: [master, develop]
20+
push:
21+
branches:
22+
- stage
23+
- test
2724
# Allows running this workflow manually from the Actions tab
2825
workflow_dispatch:
29-
branches: [master, develop]
3026
inputs:
3127
BRANCH:
32-
description: 'Branch/tag to deploy'
33-
default: develop
28+
description: "Branch/tag to deploy"
29+
options:
30+
- stage
31+
- test
32+
- master
33+
default: stage
3434
required: true
3535
environment:
36-
description: 'target environment to deploy to'
36+
description: "target environment to deploy to"
3737
type: choice
3838
options:
3939
- staging
40-
- production
41-
default: staging
42-
40+
- agroportal
41+
- test
42+
default: stage
4343
jobs:
4444
deploy:
4545
runs-on: ubuntu-latest
46-
# run deployment only if "Ruby Unit Tests" workflow completes sucessefully or when manually triggered
47-
if: ${{ (github.event.workflow_run.conclusion == 'success') || (github.event_name == 'workflow_dispatch') }}
4846
env:
49-
BUNDLE_WITHOUT: default #install gems required primarily for the deployment in order to speed this workflow
47+
BUNDLE_WITHOUT: default #install gems required primarely for deployment in order to speed up workflow
5048
PRIVATE_CONFIG_REPO: ${{ format('[email protected]:{0}.git', secrets.CONFIG_REPO) }}
5149
# Steps represent a sequence of tasks that will be executed as part of the job
5250
steps:
53-
- name: set branch/tag and environment to deploy from inputs
54-
run: |
55-
# workflow_dispatch default input doesn't get set on push so we need to set defaults
56-
# via shell parameter expansion
57-
# https://dev.to/mrmike/github-action-handling-input-default-value-5f2g
58-
USER_INPUT_BRANCH=${{ inputs.branch }}
59-
echo "BRANCH=${USER_INPUT_BRANCH:-develop}" >> $GITHUB_ENV
60-
USER_INPUT_ENVIRONMENT=${{ inputs.environment }}
61-
echo "TARGET=${USER_INPUT_ENVIRONMENT:-staging}" >> $GITHUB_ENV
62-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
63-
- uses: actions/checkout@v3
64-
- uses: ruby/setup-ruby@v1
65-
with:
66-
ruby-version: 2.7.6 # Not needed with a .ruby-version file
67-
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
68-
- name: get-deployment-config
69-
uses: actions/checkout@v3
70-
with:
71-
repository: ${{ secrets.CONFIG_REPO }} # repository containing deployment settings
72-
token: ${{ secrets.GH_PAT }} # `GH_PAT` is a secret that contains your PAT
73-
path: deploy_config
74-
- name: copy-deployment-config
75-
run: cp -r deploy_config/ontologies_api/* .
76-
# add ssh hostkey so that capistrano doesn't complain
77-
- name: Add jumphost's hostkey to Known Hosts
78-
run: |
79-
mkdir -p ~/.ssh
80-
ssh-keyscan -H ${{ secrets.SSH_JUMPHOST }} > ~/.ssh/known_hosts
81-
shell: bash
82-
- uses: miloserdow/capistrano-deploy@master
83-
with:
84-
target: ${{ env.TARGET }} # which environment to deploy
85-
deploy_key: ${{ secrets.DEPLOY_ENC_KEY }} # Name of the variable configured in Settings/Secrets of your github project
51+
- name: set branch/tag and environment to deploy from inputs
52+
run: |
53+
# workflow_dispatch default input doesn't get set on push so we need to set defaults
54+
# via shell parameter expansion
55+
# https://dev.to/mrmike/github-action-handling-input-default-value-5f2g
56+
USER_INPUT_BRANCH=${{ inputs.branch }}
57+
echo "BRANCH=${USER_INPUT_BRANCH:github.head_ref:-master}" >> $GITHUB_ENV
58+
59+
USER_INPUT_ENVIRONMENT=${{ inputs.environment }}
60+
echo "TARGET=${USER_INPUT_ENVIRONMENT:-staging}" >> $GITHUB_ENV
61+
62+
CONFIG_REPO=${{ secrets.CONFIG_REPO }}
63+
GH_PAT=${{ secrets.GH_PAT }}
64+
echo "PRIVATE_CONFIG_REPO=https://${GH_PAT}@github.com/${CONFIG_REPO}" >> $GITHUB_ENV
65+
66+
echo "SSH_JUMPHOST=${{ secrets.SSH_JUMPHOST }}" >> $GITHUB_ENV
67+
echo "SSH_JUMPHOST_USER=${{ secrets.SSH_JUMPHOST_USER }}" >> $GITHUB_ENV
68+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
69+
- uses: actions/checkout@v3
70+
- uses: ruby/setup-ruby@v1
71+
with:
72+
ruby-version: 2.7.8 # Not needed with a .ruby-version file
73+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
74+
- name: get-deployment-config
75+
uses: actions/checkout@v3
76+
with:
77+
repository: ${{ secrets.CONFIG_REPO }} # repository containing deployment settings
78+
token: ${{ secrets.GH_PAT }} # `GH_PAT` is a secret that contains your PAT
79+
path: deploy_config
80+
- name: copy-deployment-config
81+
run: cp -r deploy_config/ontologies_api/${{ inputs.environment }}/* .
82+
# add ssh hostkey so that capistrano doesn't complain
83+
- name: Add jumphost's hostkey to Known Hosts
84+
run: |
85+
mkdir -p ~/.ssh
86+
echo "${{ secrets.SSH_JUMPHOST }}"
87+
ssh-keyscan -H ${{ secrets.SSH_JUMPHOST }} > ~/.ssh/known_hosts
88+
shell: bash
89+
- uses: miloserdow/capistrano-deploy@master
90+
with:
91+
target: ${{ env.TARGET }} # which environment to deploy
92+
deploy_key: ${{ secrets.DEPLOY_ENC_KEY }} # Name of the variable configured in Settings/Secrets of your github project

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ config/environments/*
3636
!config/environments/config.rb.sample
3737

3838
#ignore capistrano deployment
39-
config/deploy/*
4039
config/*.p12
4140

4241
# Ignore generated test data
@@ -56,8 +55,6 @@ test/data/ontology_files/repo/**/*
5655

5756
*.swp
5857

59-
.ruby-version
60-
6158
config/environments/console.rb
6259

6360
config/environments/development.rb.sample

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0.6

Capfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ install_plugin Capistrano::SCM::Git
1616
# https://github.com/capistrano/rails
1717
#
1818
# require 'capistrano/rvm'
19-
# require 'capistrano/rbenv'
19+
require 'capistrano/rbenv'
2020
# require 'capistrano/chruby'
2121
require 'capistrano/bundler'
2222
# require 'capistrano/rails/assets'
2323
# require 'capistrano/rails/migrations'
2424
require 'capistrano/locally'
25-
25+
require 'new_relic/recipes' # announce deployments in NewRelic
2626
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
2727
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG RUBY_VERSION
1+
ARG RUBY_VERSION=3.0
22
ARG DISTRO_NAME=bullseye
33

44
FROM ruby:$RUBY_VERSION-$DISTRO_NAME

Gemfile

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
source 'https://rubygems.org'
2-
3-
gem 'activesupport', '~> 3.2'
2+
gem 'activesupport', '~> 5'
43
# see https://github.com/ncbo/ontologies_api/issues/69
5-
gem 'bigdecimal', '1.4.2'
6-
gem 'faraday', '~> 1.9'
4+
gem 'bigdecimal'
5+
# gem 'faraday', '~> 1.9'
76
gem 'json-schema', '~> 2.0'
8-
gem 'multi_json', '~> 1.0'
7+
gem 'multi_json'
98
gem 'oj'
109
gem 'parseconfig'
1110
gem 'rack'
1211
gem 'rake', '~> 10.0'
12+
gem 'rexml' # Investigate why unicorn fails to start under ruby 3 without adding rexml gem to the Gemfile
1313
gem 'sinatra', '~> 1.0'
1414
gem 'sinatra-advanced-routes'
1515
gem 'sinatra-contrib', '~> 1.0'
1616
gem 'request_store'
1717
gem 'parallel'
1818
gem 'json-ld'
19-
19+
gem 'google-protobuf', '3.25.3'
2020

2121
# Rack middleware
22-
gem 'ffi', '~> 1.15.5'
22+
gem 'ffi', '~> 1.16.3'
2323
gem 'rack-accept', '~> 0.4'
2424
gem 'rack-attack', '~> 6.6.1', require: 'rack/attack'
2525
gem 'rack-cache', '~> 1.13.0'
@@ -35,7 +35,7 @@ gem 'redis-store', '~>1.10'
3535

3636
# Monitoring
3737
gem 'cube-ruby', require: 'cube'
38-
gem 'newrelic_rpm'
38+
gem 'newrelic_rpm', group: [:default, :deployment]
3939

4040
# HTTP server
4141
gem 'unicorn'
@@ -53,16 +53,21 @@ gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'developm
5353
gem 'ontologies_linked_data', git: 'https://github.com/lifewatch-eric/ontologies_linked_data.git', branch: 'master'
5454
gem 'ncbo_cron', git: 'https://github.com/lifewatch-eric/ncbo_cron.git', branch: 'master'
5555

56+
5657
group :development do
58+
# bcrypt_pbkdf and ed35519 is required for capistrano deployments when using ed25519 keys; see https://github.com/miloserdow/capistrano-deploy/issues/42
59+
gem 'shotgun', github: 'palexander/shotgun', branch: 'ncbo'
60+
gem 'rubocop'
61+
end
62+
63+
group :deployment do
5764
# bcrypt_pbkdf and ed35519 is required for capistrano deployments when using ed25519 keys; see https://github.com/miloserdow/capistrano-deploy/issues/42
5865
gem 'bcrypt_pbkdf', '>= 1.0', '< 2.0', require: false
5966
gem 'capistrano', '~> 3', require: false
6067
gem 'capistrano-bundler', require: false
6168
gem 'capistrano-locally', require: false
6269
gem 'capistrano-rbenv', require: false
6370
gem 'ed25519', '>= 1.2', '< 2.0', require: false
64-
gem 'pry'
65-
gem 'shotgun', github: 'palexander/shotgun', branch: 'ncbo'
6671
end
6772

6873

@@ -71,10 +76,13 @@ group :profiling do
7176
end
7277

7378
group :test do
74-
gem 'minitest', '~> 4.0'
79+
gem 'crack', '0.4.5'
80+
gem 'minitest', '~> 5.0'
81+
gem 'minitest-hooks', "~> 1.5"
7582
gem 'minitest-stub_any_instance'
7683
gem 'rack-test'
7784
gem 'simplecov', require: false
7885
gem 'simplecov-cobertura' # for codecov.io
7986
gem 'webmock', '~> 3.19.1'
87+
gem 'webrick'
8088
end

0 commit comments

Comments
 (0)