-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # .github/workflows/test.yml # lib/active_graph/version.rb
- Loading branch information
Showing
13 changed files
with
188 additions
and
13 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,47 @@ | ||
name: E2E Test | ||
|
||
on: | ||
push: | ||
branches: [ '11' ] | ||
pull_request: | ||
branches: [ '11' ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
e2e_test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
ruby: [ jruby-9.4.5.0, ruby-3.2.3 ] | ||
neo4j: [ 5.16.0 ] | ||
active_model: [ 7.1.3 ] | ||
# jruby will fail till bug https://github.com/jruby/jruby-openssl/issues/290 is fixed | ||
env: | ||
ACTIVE_MODEL_VERSION: ${{ matrix.active_model }} | ||
JRUBY_OPTS: --debug -J-Xmx1280m -Xcompile.invokedynamic=false -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-noverify -Xcompile.mode=OFF | ||
steps: | ||
- name: Start neo4j | ||
run: docker run --name neo4j --env NEO4J_AUTH=neo4j/password --env NEO4J_ACCEPT_LICENSE_AGREEMENT=yes --env NEO4J_dbms_directories_import= -p7687:7687 -p7474:7474 -v `pwd`/tmp:/var/lib/neo4j/import --rm neo4j:${{ matrix.neo4j }}-enterprise & | ||
|
||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ${{ matrix.ruby }} | ||
|
||
- name: Wait for neo4j | ||
run: while [ $((curl localhost:7474/ > /dev/null 2>&1); echo $?) -ne 0 ]; do sleep 1; done | ||
|
||
- name: Setup test rails app | ||
run: ./e2e_tests/setup.sh | ||
|
||
- name: Install dependencies | ||
run: bundle update | ||
|
||
- name: Run tests | ||
run: bundle exec rspec -Oe2e_tests/.e2e_rspec e2e_tests/ |
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
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,3 @@ | ||
--color | ||
--tty | ||
--require ./e2e_tests/spec_helper.rb |
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,19 @@ | ||
load_migration('blah_migration.rb') | ||
|
||
describe 'Migration Generator' do | ||
describe 'generated migration file' do | ||
it 'inherits from ActiveGraph::Migrations::Base' do | ||
expect(BlahMigration).to be < ActiveGraph::Migrations::Base | ||
end | ||
|
||
it 'defines up method' do | ||
migration = CreateUser.new(nil) | ||
expect(migration.method(:up)).to be_present | ||
end | ||
|
||
it 'defines down method' do | ||
migration = CreateUser.new(nil) | ||
expect(migration.method(:up)).to be_present | ||
end | ||
end | ||
end |
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,29 @@ | ||
load 'myapp/app/models/user.rb' | ||
load_migration('create_user.rb') | ||
|
||
describe 'Model Generator' do | ||
describe 'generated model class' do | ||
it 'includes ActiveGraph::Node' do | ||
expect(User < ActiveGraph::Node).to be true | ||
end | ||
|
||
it 'declares correct property' do | ||
expect(User.attributes['name'].type).to be String | ||
end | ||
end | ||
|
||
describe 'generated migration file' do | ||
it 'inherits from ActiveGraph::Migrations::Base' do | ||
expect(CreateUser).to be < ActiveGraph::Migrations::Base | ||
end | ||
|
||
it 'can be run/rollback without issue' do | ||
migration = CreateUser.new(nil) | ||
migration.down rescue nil # we make sure migration is not run before | ||
expect do | ||
migration.up | ||
migration.down | ||
end.not_to raise_error | ||
end | ||
end | ||
end |
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,47 @@ | ||
#!/bin/sh | ||
|
||
gem install rails -v $ACTIVE_MODEL_VERSION --no-document | ||
|
||
if [[ -n "$ACTIVEGRAPH_PATH" ]] | ||
then | ||
sed 's|.*gem '"'"'activegraph'"'"'.*|gem '"'"'activegraph'"'"', path: "'"$ACTIVEGRAPH_PATH"'"|' docs/activegraph.rb > template.tmp | ||
else | ||
echo "SHA=$(git rev-parse "$GITHUB_SHA")" >> $GITHUB_ENV | ||
sed 's/.*gem '"'"'activegraph'"'"'.*/gem '"'"'activegraph'"'"', github: "neo4jrb\/activegraph", ref: "'"$(git rev-parse "$GITHUB_SHA")"'"/' docs/activegraph.rb > template.tmp | ||
fi | ||
|
||
rails \_$ACTIVE_MODEL_VERSION\_ new myapp -O -m ./template.tmp | ||
rm -f ./template.tmp | ||
cd myapp | ||
|
||
if [[ -n "$E2E_PORT" ]] | ||
then | ||
sed 's/7687/'$E2E_PORT'/' config/environments/development.rb > dev_env.tmp | ||
mv dev_env.tmp config/environments/development.rb | ||
fi | ||
|
||
if [[ -n "$E2E_NO_CRED" ]] | ||
then | ||
sed "s/'neo4j'/''/" config/environments/development.rb > dev_env.tmp | ||
mv dev_env.tmp config/environments/development.rb | ||
sed "s/'password'/''/" config/environments/development.rb > dev_env.tmp | ||
mv dev_env.tmp config/environments/development.rb | ||
fi | ||
|
||
bundle exec rails generate model User name:string | ||
bundle exec rails generate migration BlahMigration | ||
bundle exec rake neo4j:migrate | ||
|
||
if echo 'puts "hi"' | bundle exec rails c | ||
then | ||
echo "rails console works correctly" | ||
else | ||
exit 1 | ||
fi | ||
|
||
bundle exec rails s -d | ||
until $(curl --output /dev/null --silent --head --fail localhost:3000); do | ||
printf '.' | ||
sleep 1 | ||
done | ||
kill `cat tmp/pids/server.pid` |
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 @@ | ||
require 'active_graph' | ||
require 'find' | ||
|
||
server_url = ENV['NEO4J_URL'] || 'bolt://localhost:7687' | ||
ActiveGraph::Base.driver = Neo4j::Driver::GraphDatabase.driver(server_url, Neo4j::Driver::AuthTokens.basic('neo4j', 'password')) | ||
|
||
def load_migration(suffix) | ||
Find.find('myapp/db/neo4j/migrate') do |path| | ||
load path if path =~ /.*#{suffix}$/ | ||
end | ||
end |
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module ActiveGraph | ||
VERSION = '12.0.0.beta.3' | ||
VERSION = '12.0.0.beta.4' | ||
end |
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