Skip to content

Commit 739b573

Browse files
authored
Merge pull request #17 from hiett/16-improve-test-ci-to-actually-build-srh-and-run-that-image
16 improve test ci to actually build srh and run that image
2 parents e8a4156 + a77abdf commit 739b573

File tree

1 file changed

+45
-8
lines changed

1 file changed

+45
-8
lines changed

.github/workflows/test.yml

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,69 @@ on:
44
push:
55
paths:
66
- 'lib/**'
7+
- 'Dockerfile'
8+
- 'mix.exs'
9+
- 'mix.lock'
710
schedule:
811
- cron: '0 12 * * *'
912

1013
env:
1114
SRH_TOKEN: example_token
1215

1316
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout SRH code
21+
uses: actions/checkout@v3
22+
23+
- name: Build Dockerfile
24+
run: docker build -t hiett/serverless-redis-http:latest .
25+
26+
- name: Export to TAR
27+
run: docker save hiett/serverless-redis-http:latest -o /tmp/serverless-redis-http.tar
28+
29+
- name: Upload artifact
30+
uses: actions/upload-artifact@v3
31+
with:
32+
name: serverless-redis-http
33+
path: /tmp/serverless-redis-http.tar
34+
1435
container-job:
1536
runs-on: ubuntu-latest
16-
container: denoland/deno
37+
needs: build
1738
services:
1839
redis:
1940
image: redis/redis-stack-server:6.2.6-v6 # 6.2 is the Upstash compatible Redis version
20-
srh:
21-
image: hiett/serverless-redis-http:latest
22-
env:
23-
SRH_MODE: env
24-
SRH_TOKEN: ${{ env.SRH_TOKEN }}
25-
SRH_CONNECTION_STRING: redis://redis:6379
2641

2742
steps:
2843
- name: Checkout code
2944
uses: actions/checkout@v3
3045
with:
3146
repository: upstash/upstash-redis
3247

48+
- uses: denoland/setup-deno@v1
49+
with:
50+
deno-version: v1.x
51+
52+
- name: Download SRH artifact
53+
uses: actions/download-artifact@v3
54+
with:
55+
name: serverless-redis-http
56+
path: /tmp
57+
58+
- name: Load SRH image
59+
run: |
60+
docker load --input /tmp/serverless-redis-http.tar
61+
docker image ls -a | grep serverless-redis-http
62+
63+
# Placed inside the same docker network as the service container with job.container.network, at which point
64+
# it can directly address Redis. We still need to expose SRH's port to the host machine, however, so that
65+
# we can run tests against it.
66+
- name: Run SRH container
67+
run: |
68+
docker run -it -d -p 8080:80 --network ${{ job.container.network }} -e SRH_MODE=env -e SRH_TOKEN=${{ env.SRH_TOKEN }} -e SRH_CONNECTION_STRING="redis://redis:6379" hiett/serverless-redis-http:latest
69+
3370
# The following tests fail because of bugs with Upstash's implementation of Redis, NOT because of our library
3471
# So we remove them from the test suite
3572
- name: Remove JSON tests
@@ -41,5 +78,5 @@ jobs:
4178
- name: Run @upstash/redis Test Suite
4279
run: deno test -A ./pkg
4380
env:
44-
UPSTASH_REDIS_REST_URL: http://srh:80
81+
UPSTASH_REDIS_REST_URL: http://localhost:8080
4582
UPSTASH_REDIS_REST_TOKEN: ${{ env.SRH_TOKEN }}

0 commit comments

Comments
 (0)