Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need Docker to run Redis on GitHub actions

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

like image 797
orimdominic Avatar asked May 24 '26 06:05

orimdominic


1 Answers

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.

like image 153
DannyB Avatar answered May 25 '26 23:05

DannyB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!