Comments (9)
from example-services.
Basically I just need a PostgreSQL up and running on 127.0.0.1 postgres/postgres on port 5432 to connect from Go code.
from example-services.
@arthurkushman do you have set working-directory: ./postgres
on your action?
from example-services.
I'm totally unfamiliar with GitHub Actions, so I don't know where to apply working-directory: ./postgres
does this should be set in the same file - postgres-service.yml
? Do you have an example?
from example-services.
Yes it is set like this:
jobs:
container-job:
runs-on: ubuntu-latest
# runs all of the steps inside the specified continer rather than on the VM host.
# Because of this the network configuration changes from host based network to a container network.
container:
image: node:10.16-jessie
services:
postgres:
image: postgres:10.8
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 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
steps:
- uses: actions/checkout@v1
- run: npm ci
working-directory: ./postgres
- run: node client.js
working-directory: ./postgres
env:
# use postgres for the host here because we have specified a container for the job.
# If we were running the job on the VM this would be localhost
POSTGRES_HOST: postgres
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
from example-services.
No problem @arthurkushman, the working-directory
is necessary when you want to run your job on a specific folder of your project. For the postgres example, on the repo they use the folder postgres of the repo to run the job that's why, but if it's not needed for you, just remove the line.
jobs:
vm-job:
runs-on: ubuntu-latest
# here is your service
services:
postgres:
image: postgres:10.8
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 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
# here is your action linked to your code
# here it init go and run hello go
steps:
- uses: actions/checkout@master
- uses: actions/setup-go@v1
with:
go-version: '1.9.3' # The Go version to download (if necessary) and use.
- run: go run hello.go
env:
# you can use the both key for your connection or set directly localhost for host and 5432 for the port on your code
POSTGRES_HOST: localhost
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} # it's dynamic here but it will be 5432
Hope it will help !
from example-services.
After removing working-directory from anywhere got the error:
Yaml config:
name: Postgres Service Example
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
container-job:
runs-on: ubuntu-latest
# runs all of the steps inside the specified continer rather than on the VM host.
# Because of this the network configuration changes from host based network to a container network.
container:
image: node:10.16-jessie
services:
postgres:
image: postgres:10.8
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 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
steps:
- uses: actions/checkout@v1
- run: npm ci
- run: node client.js
env:
# use postgres for the host here because we have specified a container for the job.
# If we were running the job on the VM this would be localhost
POSTGRES_HOST: postgres
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
# Runs all steps on the VM
# The service containers will use host port binding instead of container networking so you access them via localhost rather than the service name
vm-job:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:10.8
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
# will assign a random free host port
- 5432/tcp
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v1
- run: npm ci
- run: node client.js
env:
# use localhost for the host here because we have specified a container for the job.
# If we were running the job on the VM this would be postgres
POSTGRES_HOST: localhost
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} # get randomly assigned published port
What I need is just run PostgreSQL on 127.0.0.1:5432 to be able to connect from Go program, if there is no need for npm I can remove those blocks for ex.
from example-services.
What I need is just run PostgreSQL on 127.0.0.1:5432 to be able to connect from Go program
@arthurkushman I give you the full example for you in my previous post, you can copy paste all.
It's was an example for use npm ci but i don't think it's needed for you, so you can remove yes.
from example-services.
Oh, good - finally PostgreSQL up and running.
What I did is just remove npm checker and then got issues related to non created shcemes:
--- FAIL: TestSelectAndLimit (0.01s)
15
builder_test.go:28:
16
Error Trace: builder_test.go:28
17
Error: Received unexpected error:
18
pq: relation "test" does not exist
19
Test: TestSelectAndLimit
20
--- FAIL: TestInsert (0.01s)
21
builder_test.go:45:
22
Error Trace: builder_test.go:45
23
Error: Received unexpected error:
24
pq: relation "test" does not exist
25
Test: TestInsert
And that's great - nothing to worry about, thx a lot for your help, good luck with your projects.
from example-services.
Related Issues (17)
- Postgres service unhealthy HOT 1
- Kindly add an example for using Microsoft SQL Server on Windows VM HOT 2
- Feature Request: Add example for OracleDB-XE HOT 1
- Contributing Example for WebDriver Selenium
- dial tcp 127.0.0.1:5432: connect: connection refused HOT 4
- Provide native seeding capability for actions
- The postgres example does not work out of the box. HOT 4
- Rename default branch
- Please delete this
- Actions and services feedback (health check questions) HOT 12
- Error: Process completed with exit code 6. HOT 2
- Incorrect comment for POSTGRES_HOST line HOT 3
- github actions fail when redis tries to save an RDB snapshot HOT 5
- Confused about the goal of these examples
- Example for mongodb? HOT 18
- Running services from the Github Package Registry
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from example-services.