-
Notifications
You must be signed in to change notification settings - Fork 28
137 lines (135 loc) · 4.89 KB
/
test.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: test
on:
pull_request_target:
push:
branches:
- main
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
deploy:
needs: [ruff]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || 'main' }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_RPC_REPO }}
tags: |
type=ref,event=tag
type=ref,event=pr
type=raw,value=latest,enable={{is_default_branch}}
labels: |
maintainer=bitcoindevproject
org.opencontainers.image.title=warnet-rpc
org.opencontainers.image.description=Warnet RPC server
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push production RPC image
uses: docker/build-push-action@v5
with:
file: src/templates/rpc/Dockerfile_rpc
platforms: linux/amd64,linux/arm64
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_RPC_REPO }}:latest
cache-to: type=inline
- name: Build and push dev RPC image
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v5
with:
file: src/templates/rpc/Dockerfile_rpc_dev
platforms: linux/amd64,linux/arm64
context: .
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_RPC_REPO }}:dev
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_RPC_REPO }}:dev
cache-to: type=inline
- name: Create tag name file
run: echo "${{ steps.meta.outputs.tags }}" > tagname.txt
- name: Upload tag name as artifact
uses: actions/upload-artifact@v4
with:
name: image-tags-${{ github.sha }}
path: tagname.txt
test:
needs: [deploy]
runs-on: ubuntu-latest
strategy:
matrix:
backend: [compose, k8s]
test: [scenarios_test.py, rpc_test.py, graph_test.py, ln_test.py]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || 'main' }}
- if: matrix.backend == 'compose'
uses: ./.github/actions
- if: matrix.backend == 'k8s'
uses: extractions/setup-just@v1
- if: matrix.backend == 'k8s'
uses: actions/download-artifact@v4
with:
name: image-tags-${{ github.sha }}
- if: matrix.backend == 'k8s'
uses: medyagh/setup-minikube@master
- if: matrix.backend == 'k8s'
run: |
tagname=$(cat tagname.txt)
echo "Using tagname: $tagname"
pip install --upgrade pip
pip install -e .
sed -i "s|bitcoindevproject/warnet-rpc:dev|$tagname|g" src/templates/rpc/warnet-rpc-statefulset-dev.yaml
just start
kubectl wait --for=condition=Ready --timeout=2m pod rpc-0
kubectl port-forward svc/rpc 9276:9276 &
- run: ./test/${{matrix.test}} ${{matrix.backend}}
build:
needs: [deploy, test]
runs-on: ubuntu-latest
strategy:
matrix:
backend: [compose]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || 'main' }}
- uses: ./.github/actions
- if: matrix.backend == 'k8s'
uses: extractions/setup-just@v1
- if: matrix.backend == 'k8s'
uses: actions/download-artifact@v4
with:
name: image-tags-${{ github.sha }}
- if: matrix.backend == 'k8s'
uses: medyagh/setup-minikube@master
- if: matrix.backend == 'k8s'
run: |
tagname=$(cat tagname.txt)
echo "Using tagname: $tagname"
eval $(minikube docker-env)
pip install --upgrade pip
pip install -e .
sed -i "s|bitcoindevproject/warnet-rpc:dev|$tagname|g" src/templates/rpc/warnet-rpc-statefulset-dev.yaml
just start
kubectl wait --for=condition=Ready --timeout=2m pod rpc-0
kubectl port-forward svc/rpc 9276:9276 &
- run: ./test/build_branch_test.py ${{matrix.backend}}