-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Anyone manage to get Hasura to work in a CI/CD pipeline, e.g. with GitHub Actions? #3649
Comments
@joshuarobs What is the error/issue that you're hitting with this configuration? |
@shahidhk This is the error: If you see the link, you can see that calling pg_dump returns no SQL statements. I find it weird, because if I run the same On my second repo (full details here: https://github.com/joshuarobs/test-ci/commit/07c627eef3d2627ee3d610b4e6efeba3ca3f2fc2/checks?check_suite_id=387692198) I get this error: ```
|
Hi @joshuarobs Could you share which repository you managed to fix the issue? Since you shared 2 of them I'm not quite sure which one is the one working. Thanks. |
Thanks @joshuarobs, quick question, do you know what's the main difference between these 02 different Docker setup? I've posted a question here as well: #3954 Thanks. |
@samuelcastro one works and the other doesn't |
@joshuarobs Did you ever get this working? I am stuck on this. Some added complexity since I've got remote schema too. But running into the same versions issues.
|
@browniefed are you still stuck on this? I was working on this for a while as well and I've been using the github action that you wrote as part of my tests. It turns out that this was the issue. When I use your action I get the same message where it says that it cannot connect to 127.0.0.1. When I switch to just directly installing the hasura CLI in the action and calling it directly as @joshuarobs has done it worked immediately. |
Thanks for updating with your solution @joshuarobs! I just got Hasura working in a Gitlab CI/CD pipeline with the following configuration. Sharing for anyone who stumbles upon this issue after facing a test-hasura-migrations:
image: debian:12-slim
services:
- name: postgres
alias: postgres
- name: hasura/graphql-engine:v2.35.1
alias: graphql-engine # this is the hostname where the service can be accessed
variables:
FF_NETWORK_PER_BUILD: 1 # see https://docs.gitlab.com/ee/ci/services/#connecting-services
POSTGRES_PASSWORD: "postgrespassword"
POSTGRES_USER: postgres
POSTGRES_DB: postgres
HASURA_GRAPHQL_DATABASE_URL: postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres/$POSTGRES_DB
PG_DATABASE_URL: postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@postgres/$POSTGRES_DB
HASURA_GRAPHQL_ENDPOINT: http://graphql-engine:8080
script:
- apt update && apt upgrade --yes
- apt install curl --yes
- curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash
# Apply the migrations to the fresh DB
- cd hasura
- hasura metadata apply # at this point, the metadata will be inconsistent, since migrations have not been applied yet
- hasura migrate apply --database-name $HASURA_DATABASE_NAME
- hasura migrate status --database-name $HASURA_DATABASE_NAME
- hasura seeds apply --database-name $HASURA_DATABASE_NAME
- hasura metadata reload # hasura will check again and metadata should now be consistent with database information.
- |
output=$(hasura metadata inconsistency status 2>&1)
if [[ ! $output =~ "metadata is consistent" ]]; then
hasura metadata ic list
exit 1
fi
rules:
# Automatically run on any merge request that updates the hasura directory
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
changes:
- hasura/migrations/**/*
- hasura/metadata/**/*
- hasura/seeds/**/*
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: manual # If the hasura files haven't changed allow the user to choose to manually run it
allow_failure: true # the pipeline continues running even if the manual job is not run |
Edit:
I have solved this issue. This is the working GitHub Actions workflow file:
Working tests are in this repo: https://github.com/joshuarobs/making-hasura-work-with-github-actions
This is my original issue (#3638) that I have closed so that I can put it here, in this more centralised issue.
I've spent the last 2 days trying to get Hasura to work with GitHub Actions, so that I can run tests in the cloud after pushing commits. This is so that I can have a proper DevOps workflow, with proper CI/CD.
I've had no luck in being able to get this work. For now I'm giving up, and just going to have to skip cloud testing and pray that my local tests are adequate enough. If someone else wants to take over, good luck.
I have two repos I've tried to make Hasura work in a CI/CD environment:
Attempt 1
This one uses instructions for setup from here: https://docs.hasura.io/1.0/graphql/manual/getting-started/docker-simple.html
This is by running a
docker-compose
, instead of runningdocker-run.sh
.Attempt 2
This one uses instructions for setup from here: https://docs.hasura.io/1.0/graphql/manual/deployment/docker/index.html
This is by running a
docker-run.sh
file, instead of runningdocker-compose
.If someone has managed to make this work with GitHub Actions, please share how you managed to make it work. Or if you managed to make it work with another build server/service, what did you use and what script are you using?
Also with attempt 1 repo, I found a slight clue as to what might be going wrong here: #3648 But I don't know what to do with this clue
The text was updated successfully, but these errors were encountered: