这是indexloc提供的服务,不要输入任何密码
Skip to content

Anyone manage to get Hasura to work in a CI/CD pipeline, e.g. with GitHub Actions? #3649

@joshuarobs

Description

@joshuarobs

Edit:

I have solved this issue. This is the working GitHub Actions workflow file:

name: Node CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    services:
      postgres:
        image: postgres:12.1
        env:
          POSTGRES_USER: postgres
          POSTGRES_DB: postgres
        ports:
        # will assign a random free host port
        - 5432:5432
        # needed because the postgres container does not provide a healthcheck
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
      hasura:
        image: hasura/graphql-engine:latest
        env:
          HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:@postgres:5432/postgres
        ports:
          - 8080:8080

    strategy:
      matrix:
        node-version: [12.x]

    steps:
    - uses: actions/checkout@v1
    - name: Install Hasura cli
      run: curl -L https://github.com/hasura/graphql-engine/raw/master/cli/get.sh | bash
    - name: Start up the Docker containers and migrate to the latest version of the database
      run: |
        docker ps
        cd docker
        hasura migrate status --skip-update-check --endpoint http://localhost:8080
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - name: npm install, build, and test
      run: |
        node index.js
      env:
        CI: true

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:

  1. Attempt 1 - https://github.com/joshuarobs/making-hasura-work-with-github-actions
  2. Attempt 2 - https://github.com/joshuarobs/test-ci

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 running docker-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 running docker-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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions