[GH-ISSUE #173] Services not working #117

Closed
opened 2026-03-01 21:40:18 +03:00 by kerem · 25 comments
Owner

Originally created by @fgimenez on GitHub (Mar 28, 2020).
Original GitHub issue: https://github.com/nektos/act/issues/173

Originally assigned to: @catthehacker on GitHub.

Hello! I have this workflow:

on: [push]

jobs:
  tests:
    runs-on: ubuntu-latest
    container: node:12.16.1-stretch
    services:
      mongodb:
        image: "mongo:4.0.17"
    steps:
      - uses: actions/checkout@v2
      - run: yarn
      - run: yarn test

The yarn test command expects to find a mongodb service listening on 27017, but running act the command fails with MongooseServerSelectionError: getaddrinfo ENOTFOUND mongodb. The same workflow succeeds on GitHub.

I've also tried -P ubuntu-latest=nektos/act-environments-ubuntu:18.04, any help is very appreciated :)

Originally created by @fgimenez on GitHub (Mar 28, 2020). Original GitHub issue: https://github.com/nektos/act/issues/173 Originally assigned to: @catthehacker on GitHub. Hello! I have this workflow: ```name: test-and-build on: [push] jobs: tests: runs-on: ubuntu-latest container: node:12.16.1-stretch services: mongodb: image: "mongo:4.0.17" steps: - uses: actions/checkout@v2 - run: yarn - run: yarn test ``` The `yarn test` command expects to find a mongodb service listening on 27017, but running act the command fails with `MongooseServerSelectionError: getaddrinfo ENOTFOUND mongodb`. The same workflow succeeds on GitHub. I've also tried `-P ubuntu-latest=nektos/act-environments-ubuntu:18.04`, any help is very appreciated :)
Author
Owner

@thatdoogieguy commented on GitHub (May 1, 2020):

I was having a similar problem, especially when i was trying to combine rails caching with postgresql and redis. In the end i created a seperate workflow file called ci-local.yml based off of the production Github Actions file i had created and manually defined the services by calling apt-get then service %service_name% start.

Massive PITA but for localised testing this was the only way i could thoroughly test the functional parts of GitHub Actions where multiple parts are as yet unsupported.

Not a fix, just a hacky workaround to get myself out of trouble!

<!-- gh-comment-id:622234799 --> @thatdoogieguy commented on GitHub (May 1, 2020): I was having a similar problem, especially when i was trying to combine rails caching with postgresql and redis. In the end i created a seperate workflow file called ci-local.yml based off of the production Github Actions file i had created and manually defined the services by calling apt-get then service %service_name% start. Massive PITA but for localised testing this was the only way i could thoroughly test the functional parts of GitHub Actions where multiple parts are as yet unsupported. Not a fix, just a hacky workaround to get myself out of trouble!
Author
Owner

@github-actions[bot] commented on GitHub (Jul 1, 2020):

Issue is stale and will be closed in 7 days unless there is new activity

<!-- gh-comment-id:652113476 --> @github-actions[bot] commented on GitHub (Jul 1, 2020): Issue is stale and will be closed in 7 days unless there is new activity
Author
Owner

@mossad-zika commented on GitHub (Aug 31, 2020):

shiiiiiiiiiiiiit

<!-- gh-comment-id:683816911 --> @mossad-zika commented on GitHub (Aug 31, 2020): shiiiiiiiiiiiiit
Author
Owner

@jadhavmanoj commented on GitHub (Oct 15, 2020):

Same here. Services not working. Any workaround for the same?

<!-- gh-comment-id:708965355 --> @jadhavmanoj commented on GitHub (Oct 15, 2020): Same here. Services not working. Any workaround for the same?
Author
Owner

@mossad-zika commented on GitHub (Oct 15, 2020):

@jadhavmanoj workaround is to use docker-compose

<!-- gh-comment-id:709112448 --> @mossad-zika commented on GitHub (Oct 15, 2020): @jadhavmanoj workaround is to use docker-compose
Author
Owner

@chenxilinsidney commented on GitHub (Nov 21, 2020):

I have the same problem while using services of mysql and redis in action

<!-- gh-comment-id:731523206 --> @chenxilinsidney commented on GitHub (Nov 21, 2020): I have the same problem while using services of mysql and redis in action
Author
Owner

@theoparis commented on GitHub (Dec 28, 2020):

Any updates? It's been another month

<!-- gh-comment-id:751675177 --> @theoparis commented on GitHub (Dec 28, 2020): Any updates? It's been another month
Author
Owner

@Lzok commented on GitHub (Jan 25, 2021):

Hello, any update on this?

My code:

jobs:
  test:
    runs-on: ubuntu-latest

    services:
      mongodb:
        image: mongo:4.0
        ports:
          - 27017/tcp
# ...etc

In the env section of my job I have: MONGO_URI_TESTS: localhost:${{ job.services.mongodb.ports[27017] }}/dbtest

The error: ERRO[0082] Unable to interpolate string 'localhost:${{ job.services.mongodb.ports[27017] }}/dbtest' - [TypeError: Cannot access member 'ports' of undefined]

Thank you!

<!-- gh-comment-id:766510838 --> @Lzok commented on GitHub (Jan 25, 2021): Hello, any update on this? My code: ```yaml jobs: test: runs-on: ubuntu-latest services: mongodb: image: mongo:4.0 ports: - 27017/tcp # ...etc ``` In the env section of my job I have: `MONGO_URI_TESTS: localhost:${{ job.services.mongodb.ports[27017] }}/dbtest` The error: `ERRO[0082] Unable to interpolate string 'localhost:${{ job.services.mongodb.ports[27017] }}/dbtest' - [TypeError: Cannot access member 'ports' of undefined]` Thank you!
Author
Owner

@Systho commented on GitHub (Feb 4, 2021):

@thatdoogieguy Could you provide a snippet of the step you wrote tha install & start postgresql ?
I have a feeling that is a simple one but since you have experience about it let's ensure there is no nasty corner case :)

<!-- gh-comment-id:773128170 --> @Systho commented on GitHub (Feb 4, 2021): @thatdoogieguy Could you provide a snippet of the step you wrote tha install & start postgresql ? I have a feeling that is a simple one but since you have experience about it let's ensure there is no nasty corner case :)
Author
Owner

@loklaan commented on GitHub (Feb 17, 2021):

Edit: I thought this was a bug, but in fact support for services aren't implemented yet in act, so for those shouting BUMP please consider contributing instead if you can! 🙌

@Systho A small reproduction is:

  1. Create .github/workflows/repro.yml
name: "Reproduction"

on:
  push:

jobs:
  repro:
    name: Reproduction of failing Services interpolation
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:12
        env:
          POSTGRES_USER: runner
          POSTGRES_PASSWORD: mysecretdbpass
          POSTGRES_DB: mydb
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 5432:5432
    steps:
      - name: Echo the Postgres service ID / Network / Ports
        run: |
          echo "id: ${{ job.services.postgres.id }}"
          echo "network: ${{ job.services.postgres.network }}"
          echo "ports: ${{ job.services.postgres.ports }}"
  1. Run act "push" --job "repro"
<!-- gh-comment-id:780900845 --> @loklaan commented on GitHub (Feb 17, 2021): _Edit: I thought this was a bug, but in fact support for `services` aren't implemented yet in act, so for those shouting BUMP please consider contributing instead if you can!_ 🙌 @Systho A small reproduction is: 1. Create `.github/workflows/repro.yml` ```yml name: "Reproduction" on: push: jobs: repro: name: Reproduction of failing Services interpolation runs-on: ubuntu-latest services: postgres: image: postgres:12 env: POSTGRES_USER: runner POSTGRES_PASSWORD: mysecretdbpass POSTGRES_DB: mydb options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 5432:5432 steps: - name: Echo the Postgres service ID / Network / Ports run: | echo "id: ${{ job.services.postgres.id }}" echo "network: ${{ job.services.postgres.network }}" echo "ports: ${{ job.services.postgres.ports }}" ``` 2. Run `act "push" --job "repro"`
Author
Owner

@amacgregorhumi commented on GitHub (Feb 24, 2021):

BUMP

<!-- gh-comment-id:785333812 --> @amacgregorhumi commented on GitHub (Feb 24, 2021): BUMP
Author
Owner

@moki9 commented on GitHub (Mar 1, 2021):

BUMP

<!-- gh-comment-id:787686130 --> @moki9 commented on GitHub (Mar 1, 2021): BUMP
Author
Owner

@github-actions[bot] commented on GitHub (Apr 1, 2021):

Issue is stale and will be closed in 14 days unless there is new activity

<!-- gh-comment-id:811545528 --> @github-actions[bot] commented on GitHub (Apr 1, 2021): Issue is stale and will be closed in 14 days unless there is new activity
Author
Owner

@elitan commented on GitHub (Jul 14, 2021):

The bot closing issues after 14 days is pretty aggressive. :/

(I too have this issue locally. Works on GitHub)

<!-- gh-comment-id:879853877 --> @elitan commented on GitHub (Jul 14, 2021): The bot closing issues after 14 days is pretty aggressive. :/ (I too have this issue locally. Works on GitHub)
Author
Owner

@catthehacker commented on GitHub (Jul 14, 2021):

Services were drafted in https://github.com/nektos/act/pull/638 but author stopped responding, it works but it also breaks easily thus it wasn't merged

<!-- gh-comment-id:879910381 --> @catthehacker commented on GitHub (Jul 14, 2021): Services were drafted in https://github.com/nektos/act/pull/638 but author stopped responding, it works but it also breaks easily thus it wasn't merged
Author
Owner

@catthehacker commented on GitHub (Aug 11, 2021):

Notification for people subscribed to this thread, please see latest PR mentioned.
artefacts: https://github.com/nektos/act/actions/runs/1118549374

<!-- gh-comment-id:896462155 --> @catthehacker commented on GitHub (Aug 11, 2021): Notification for people subscribed to this thread, please see latest PR mentioned. artefacts: https://github.com/nektos/act/actions/runs/1118549374
Author
Owner

@techpeace commented on GitHub (Aug 24, 2021):

I added the following steps to my workflow in order to get the actions for my Rails app running locally:

# Install local deps if this action is being run locally
- name: Install local dependencies
  if: ${{ env.ACT }}
  run: |
    npm i -g yarn
    sudo apt-get update
    sudo apt-get -yqq install libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libnss3-dev libxss-dev libasound2 libxshmfence-dev postgresql postgresql-contrib redis-server

- name: Boot local dependencies
  if: ${{ env.ACT }}
  run: |
    sudo service postgresql start
    sudo service redis-server start

- name: Configure local dependencies
  if: ${{ env.ACT }}
  run: |
    sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password 'password';"
<!-- gh-comment-id:904752209 --> @techpeace commented on GitHub (Aug 24, 2021): I added the following steps to my workflow in order to get the actions for my Rails app running locally: ```yaml # Install local deps if this action is being run locally - name: Install local dependencies if: ${{ env.ACT }} run: | npm i -g yarn sudo apt-get update sudo apt-get -yqq install libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libnss3-dev libxss-dev libasound2 libxshmfence-dev postgresql postgresql-contrib redis-server - name: Boot local dependencies if: ${{ env.ACT }} run: | sudo service postgresql start sudo service redis-server start - name: Configure local dependencies if: ${{ env.ACT }} run: | sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password 'password';" ```
Author
Owner

@neongreen commented on GitHub (Mar 15, 2022):

It would be great if the readme mentioned that services isn't supported.

<!-- gh-comment-id:1068004312 --> @neongreen commented on GitHub (Mar 15, 2022): It would be great if the readme mentioned that `services` isn't supported.
Author
Owner

@kent-avl commented on GitHub (Nov 8, 2022):

I added the following steps to my workflow in order to get the actions for my Rails app running locally:

# Install local deps if this action is being run locally
- name: Install local dependencies
  if: ${{ env.ACT }}
  run: |
    npm i -g yarn
    sudo apt-get update
    sudo apt-get -yqq install libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libnss3-dev libxss-dev libasound2 libxshmfence-dev postgresql postgresql-contrib redis-server

- name: Boot local dependencies
  if: ${{ env.ACT }}
  run: |
    sudo service postgresql start
    sudo service redis-server start

- name: Configure local dependencies
  if: ${{ env.ACT }}
  run: |
    sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password 'password';"

thanks for providing this workaround. but installing everything every time is quite annoying, is any way to make act connect host service? e.g make act connect PostgreSQL that runs in the host.

<!-- gh-comment-id:1307519386 --> @kent-avl commented on GitHub (Nov 8, 2022): > I added the following steps to my workflow in order to get the actions for my Rails app running locally: > > ```yaml > # Install local deps if this action is being run locally > - name: Install local dependencies > if: ${{ env.ACT }} > run: | > npm i -g yarn > sudo apt-get update > sudo apt-get -yqq install libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libnss3-dev libxss-dev libasound2 libxshmfence-dev postgresql postgresql-contrib redis-server > > - name: Boot local dependencies > if: ${{ env.ACT }} > run: | > sudo service postgresql start > sudo service redis-server start > > - name: Configure local dependencies > if: ${{ env.ACT }} > run: | > sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password 'password';" > ``` thanks for providing this workaround. but installing everything every time is quite annoying, is any way to make act connect host service? e.g make act connect PostgreSQL that runs in the host.
Author
Owner

@till commented on GitHub (Nov 8, 2022):

You can probably use host.docker.internal on osx.

<!-- gh-comment-id:1307591404 --> @till commented on GitHub (Nov 8, 2022): You can probably use `host.docker.internal` on osx.
Author
Owner

@edmundsj commented on GitHub (Jan 15, 2023):

Getting this working would be AMAZING - our company heavily uses GitHub actions and act (mostly for debugging - makes it a breeze), but getting services running locally would dramatically cut our build times (as they could be done locally) and make debugging complex actions possible.

<!-- gh-comment-id:1383004700 --> @edmundsj commented on GitHub (Jan 15, 2023): Getting this working would be AMAZING - our company heavily uses GitHub actions and act (mostly for debugging - makes it a breeze), but getting services running locally would dramatically cut our build times (as they could be done locally) and make debugging complex actions possible.
Author
Owner

@bilogic commented on GitHub (Mar 31, 2023):

thanks for providing this workaround. but installing everything every time is quite annoying, is any way to make act connect host service? e.g make act connect PostgreSQL that runs in the host.

Yea it is annoying, but connecting to host will likely restrict you to only 1 runner. Probably makes more sense to have database as part of the image, but I'm still researching how that can be done, i.e. where are they pulling unbuntu-latest from

<!-- gh-comment-id:1491215836 --> @bilogic commented on GitHub (Mar 31, 2023): > thanks for providing this workaround. but installing everything every time is quite annoying, is any way to make act connect host service? e.g make act connect PostgreSQL that runs in the host. Yea it is annoying, but connecting to host will likely restrict you to only 1 runner. Probably makes more sense to have database as part of the image, but I'm still researching how that can be done, i.e. where are they pulling `unbuntu-latest` from
Author
Owner

@tarikhagustia commented on GitHub (Apr 17, 2023):

+1

<!-- gh-comment-id:1510682661 --> @tarikhagustia commented on GitHub (Apr 17, 2023): +1
Author
Owner

@GuessWhoSamFoo commented on GitHub (Jul 10, 2023):

@catthehacker Are you aware of any active development efforts? Last I've seen is #775 and would love to help get it over the finish line

<!-- gh-comment-id:1628220125 --> @GuessWhoSamFoo commented on GitHub (Jul 10, 2023): @catthehacker Are you aware of any active development efforts? Last I've seen is #775 and would love to help get it over the finish line
Author
Owner

@ChristopherHX commented on GitHub (Jul 10, 2023):

This is finished in a fork https://gitea.com/gitea/act.
Maybe this can be backported by someone.

There aren't any active development efforts for this in nektos/act.

<!-- gh-comment-id:1628390610 --> @ChristopherHX commented on GitHub (Jul 10, 2023): This is finished in a fork https://gitea.com/gitea/act. Maybe this can be backported by someone. There aren't any active development efforts for this in nektos/act.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#117
No description provided.