Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved e2e tests #1724

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/e2e_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
ruby: [ jruby, ruby-3.2.5 ]
neo4j: [ 5.22.0 ]
active_model: [ 7.1.3 ]
# jruby will fail till bug https://github.com/jruby/jruby-openssl/issues/290 is fixed
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is resolved now.

include:
- ruby: jruby
java-version: 17
Expand Down Expand Up @@ -48,7 +47,15 @@ jobs:
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
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
# For pull requests, get the SHA of the last commit in the PR
COMMIT_SHA=$(jq -r '.pull_request.head.sha' < "${{ github.event_path }}")
else
# For push events (like master branch), use the commit SHA
COMMIT_SHA="${{ github.sha }}"
fi
./e2e_tests/setup.sh $COMMIT_SHA

- name: Install dependencies
run: bundle update
Expand Down
15 changes: 10 additions & 5 deletions e2e_tests/setup.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/sh

# Example values of environment variables ACTIVE_MODEL_VERSION=7.1.3 ACTIVEGRAPH_PATH=../ E2E_PORT=7687 E2E_NO_CRED=true
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
sed 's/.*gem '"'"'activegraph'"'"'.*/gem '"'"'activegraph'"'"', github: "neo4jrb\/activegraph", ref: "'"$1"'"/' docs/activegraph.rb > template.tmp
fi

rails \_$ACTIVE_MODEL_VERSION\_ new myapp -O -m ./template.tmp
Expand All @@ -28,18 +28,23 @@ then
mv dev_env.tmp config/environments/development.rb
fi

echo "Generating model"
bundle exec rails generate model User name:string
echo "Generating migration"
bundle exec rails generate migration BlahMigration
echo "Running migration"
bundle exec rake neo4j:migrate

if echo 'puts "hi"' | bundle exec rails c
if echo 'puts "Starting rails console"' | bundle exec rails c
then
echo "rails console works correctly"
echo "Rails console works correctly"
else
echo "Rails console didn't start"
exit 1
fi

bundle exec rails s -d
echo "Starting rails server"
bundle exec rails s &
until $(curl --output /dev/null --silent --head --fail localhost:3000); do
printf '.'
sleep 1
Expand Down
2 changes: 1 addition & 1 deletion lib/active_graph/migrations/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def handle_incomplete_states!
return unless incomplete_states.any?
incomplete_versions = incomplete_states.map(&:migration_id)
fail MigrationError, <<-MSG
There are migrations struck in an incomplete states, that could not be fixed automatically:
There are migrations stuck in an incomplete states, that could not be fixed automatically:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

#{incomplete_versions.join('\n')}
This can happen when there's a critical error inside a migration.

Expand Down
Loading