skip to Main Content

I’m fairly new to GitHub actions and Redis.
I’m running a this CI on GitHub actions (code below)

name: sanity check
on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
jobs:
  tests:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        redis-version: [6]
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: "14"
      - uses: supercharge/[email protected] # sets up Redis
        with:
          redis-version: ${{ matrix.redis-version }}
      - run: node -v
      - run: yarn -v
      # - run: redis-cli ping
      - run: yarn install
      - run: yarn test --detectOpenHandles

so that I can perform integration tests with Redis, but this CI doesn’t exit (I’m running tests with Jest)

Is it because I’m not using Docker? What do I need to do to make sure this test exits? Locally, it runs fine (I start a Redis server manually though). Do I need Docker to make this work well? Any links for how to run Docker with Redis on GitHub actions if that’s the problem?

PS: If you need extra information about this, please let me know

2

Answers


  1. Chosen as BEST ANSWER

    The problem of Jest not exiting was probably because I was using the real redis nodejs client in my tests. I switced it to this

    
    import { createNodeRedisClient } from "handy-redis";
    import { createClient } from "redis-mock";
    
    const cache =
      process.env.NODE_ENV === "production"
        ? createNodeRedisClient({
            url: process.env.REDIS_URL,
          })
        : createClient();
    
    export { cache };
    

    and I wasn't getting the error anymore


  2. You probably don’t need this redis action, and you do not need anything docker related (although if you want, you can run redis using docker).

    Just install redis-server and if you want the redis CLI, also redis-tools.

    Here is a sample GitHub Action that installs and pings the redis server:

    name: Redis test
    on: [push]
    
    jobs:
      test:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v2
          - name: Install redis
            run: sudo apt-get install -y redis-tools redis-server
          - name: Verify that redis is up
            run: redis-cli ping
    

    If you prefer using the action, here is a working workflow:

    name: Redis test
    on: [push]
    
    jobs:
      test:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v2
    
          - name: Setup redis
            uses: supercharge/[email protected]
            with: 
              redis-version: 6
    
          - name: Install redis cli # so we can test the server
            run: sudo apt-get install -y redis-tools
    
          - name: Verify that redis is up
            run: redis-cli ping
    
    

    Finally, if your GitHub Action did not exit, it could have been a problem related to one of the recent GitHub Actions outages on May 20, May 18 or May 16.

    If it’s none of the above, the problem is probably not redis related and you might want to reduce the number of "moving parts" until you see the faulty one.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search