123 lines (110 loc) · 3.24 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: ci
on:
push:
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and export
uses: docker/build-push-action@v5
with:
context: .
tags: ${{github.repository}}:latest
outputs: type=docker,dest=/tmp/image.tar
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: image
path: /tmp/image.tar
run_tests:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
token: ["", "token"]
reductstore_version: [ "main", "latest" ]
license: ["", "/workdir/lic.key"]
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: image
path: /tmp/
- name: check
run: ls -la /tmp
- name: Generate license
run: echo '${{secrets.LICENSE_KEY}}' > lic.key
- name: Run ReductStore
run: docker run -p 8383:8383 -v ${PWD}:/workdir
--env RS_API_TOKEN=${{matrix.token}}
--env RS_LOG_LEVEL=DEBUG
--env RS_LICENSE_PATH=${{matrix.license}}
-d reduct/store:${{ matrix.reductstore_version }}
- name: Load image with tests
run: |
docker load --input /tmp/image.tar
docker image ls -a
- name: Run tests
run: docker run --network=host
--env RS_API_TOKEN=${{ matrix.token }}
--env RS_LICENSE_PATH=${{matrix.license}}
${{github.repository}} npm test
run_examples:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
example: ["HelloWorld.js", "QuickStart.js", "Subscription.js"]
reductstore_version: ["main", "latest"]
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: image
path: /tmp/
- name: Run ReductStore
run: docker run -p 8383:8383 -v ${PWD}/data:/data -d reduct/store:${{ matrix.reductstore_version }}
- name: Wait for ReductStore
run: sleep 3
- name: Load image with tests
run: |
docker load --input /tmp/image.tar
docker image ls -a
- name: Run example
run: docker run --network=host ${{github.repository}} node examples/${{matrix.example}}
lint:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: image
path: /tmp/
- name: Load image with tests
run: |
docker load --input /tmp/image.tar
docker image ls -a
- name: Run tests
run: docker run --network=host ${{github.repository}} npm run lint
publish:
needs: [run_tests, run_examples, lint]
runs-on: ubuntu-latest
if: ${{ startsWith(github.event.ref, 'refs/tags/v') }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 17
- run: npm i
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}