39
.github/workflows/postgres-service.yml
vendored
39
.github/workflows/postgres-service.yml
vendored
@@ -1,7 +1,15 @@
|
||||
on: [push]
|
||||
name: Postgres Service Example
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
container-job:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
container:
|
||||
@@ -30,3 +38,30 @@ jobs:
|
||||
# If we were running the job on the VM this would be localhost
|
||||
POSTGRES_HOST: postgres
|
||||
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
|
||||
|
||||
vm-job:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
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 contaienr for the job.
|
||||
# If we were running the job on the VM this would be localhost
|
||||
POSTGRES_HOST: localhost
|
||||
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
|
||||
55
.github/workflows/redis-service.yml
vendored
Normal file
55
.github/workflows/redis-service.yml
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
name: Redis Service Example
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
container-job:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
container:
|
||||
image: node:10.16-jessie
|
||||
|
||||
services:
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- 6379:6379
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- run: npm ci
|
||||
working-directory: ./redis
|
||||
|
||||
- run: node client.js
|
||||
working-directory: ./redis
|
||||
env:
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
|
||||
|
||||
vm-job:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- 6379/tcp
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- run: npm ci
|
||||
working-directory: ./redis
|
||||
|
||||
- run: node client.js
|
||||
working-directory: ./redis
|
||||
env:
|
||||
REDIS_HOST: localhost
|
||||
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
|
||||
19
redis/client.js
Normal file
19
redis/client.js
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
const redis = require("redis");
|
||||
|
||||
redisClient = redis.createClient(process.env.REDIS_PORT, process.env.REDIS_HOST);
|
||||
|
||||
redisClient.on("error", function(err) {
|
||||
console.log("Error " + err);
|
||||
});
|
||||
|
||||
redisClient.set("string key", "string val", redis.print);
|
||||
redisClient.hset("hash key", "hashtest 1", "some value", redis.print);
|
||||
redisClient.hset(["hash key", "hashtest 2", "some other value"], redis.print);
|
||||
redisClient.hkeys("hash key", function (err, replies) {
|
||||
console.log(replies.length + " replies:");
|
||||
replies.forEach(function (reply, i) {
|
||||
console.log(" " + i + ": " + reply);
|
||||
});
|
||||
redisClient.quit();
|
||||
});
|
||||
31
redis/package-lock.json
generated
Normal file
31
redis/package-lock.json
generated
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"requires": true,
|
||||
"lockfileVersion": 1,
|
||||
"dependencies": {
|
||||
"double-ended-queue": {
|
||||
"version": "2.1.0-0",
|
||||
"resolved": "https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz",
|
||||
"integrity": "sha1-ED01J/0xUo9AGIEwyEHv3XgmTlw="
|
||||
},
|
||||
"redis": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/redis/-/redis-2.8.0.tgz",
|
||||
"integrity": "sha512-M1OkonEQwtRmZv4tEWF2VgpG0JWJ8Fv1PhlgT5+B+uNq2cA3Rt1Yt/ryoR+vQNOQcIEgdCdfH0jr3bDpihAw1A==",
|
||||
"requires": {
|
||||
"double-ended-queue": "^2.1.0-0",
|
||||
"redis-commands": "^1.2.0",
|
||||
"redis-parser": "^2.6.0"
|
||||
}
|
||||
},
|
||||
"redis-commands": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.5.0.tgz",
|
||||
"integrity": "sha512-6KxamqpZ468MeQC3bkWmCB1fp56XL64D4Kf0zJSwDZbVLLm7KFkoIcHrgRvQ+sk8dnhySs7+yBg94yIkAK7aJg=="
|
||||
},
|
||||
"redis-parser": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz",
|
||||
"integrity": "sha1-Uu0J2srBCPGmMcB+m2mUHnoZUEs="
|
||||
}
|
||||
}
|
||||
}
|
||||
5
redis/package.json
Normal file
5
redis/package.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"redis": "^2.8.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user