Scott Hiett commited on
Commit
739b573
·
unverified ·
2 Parent(s): e8a4156 a77abdf

Merge pull request #17 from hiett/16-improve-test-ci-to-actually-build-srh-and-run-that-image

Browse files
Files changed (1) hide show
  1. .github/workflows/test.yml +45 -8
.github/workflows/test.yml CHANGED
@@ -4,6 +4,9 @@ on:
4
  push:
5
  paths:
6
  - 'lib/**'
 
 
 
7
  schedule:
8
  - cron: '0 12 * * *'
9
 
@@ -11,18 +14,30 @@ env:
11
  SRH_TOKEN: example_token
12
 
13
  jobs:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  container-job:
15
  runs-on: ubuntu-latest
16
- container: denoland/deno
17
  services:
18
  redis:
19
  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
26
 
27
  steps:
28
  - name: Checkout code
@@ -30,6 +45,28 @@ jobs:
30
  with:
31
  repository: upstash/upstash-redis
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  # The following tests fail because of bugs with Upstash's implementation of Redis, NOT because of our library
34
  # So we remove them from the test suite
35
  - name: Remove JSON tests
@@ -41,5 +78,5 @@ jobs:
41
  - name: Run @upstash/redis Test Suite
42
  run: deno test -A ./pkg
43
  env:
44
- UPSTASH_REDIS_REST_URL: http://srh:80
45
  UPSTASH_REDIS_REST_TOKEN: ${{ env.SRH_TOKEN }}
 
4
  push:
5
  paths:
6
  - 'lib/**'
7
+ - 'Dockerfile'
8
+ - 'mix.exs'
9
+ - 'mix.lock'
10
  schedule:
11
  - cron: '0 12 * * *'
12
 
 
14
  SRH_TOKEN: example_token
15
 
16
  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
+
35
  container-job:
36
  runs-on: ubuntu-latest
37
+ needs: build
38
  services:
39
  redis:
40
  image: redis/redis-stack-server:6.2.6-v6 # 6.2 is the Upstash compatible Redis version
 
 
 
 
 
 
41
 
42
  steps:
43
  - name: Checkout code
 
45
  with:
46
  repository: upstash/upstash-redis
47
 
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
+
70
  # The following tests fail because of bugs with Upstash's implementation of Redis, NOT because of our library
71
  # So we remove them from the test suite
72
  - name: Remove JSON tests
 
78
  - name: Run @upstash/redis Test Suite
79
  run: deno test -A ./pkg
80
  env:
81
+ UPSTASH_REDIS_REST_URL: http://localhost:8080
82
  UPSTASH_REDIS_REST_TOKEN: ${{ env.SRH_TOKEN }}