Skip to content

Commit

Permalink
Improved e2e tests (#1724)
Browse files Browse the repository at this point in the history
* improved e2e tests

* using github.sha

* Update e2e_test.yml

* final cleanup
  • Loading branch information
mrhardikjoshi authored Sep 24, 2024
1 parent 523a07e commit 681afe8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
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
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:
#{incomplete_versions.join('\n')}
This can happen when there's a critical error inside a migration.
Expand Down

0 comments on commit 681afe8

Please sign in to comment.