-
Notifications
You must be signed in to change notification settings - Fork 34
187 lines (154 loc) · 5.71 KB
/
build-push.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: Build/Test and Upload to PyPi
on:
pull_request:
branches:
- master
push:
tags:
- '*'
branches:
- master
env:
CIBW_SKIP: cp36*
jobs:
build_wheels:
name: Build wheels (${{ matrix.os }})
if: contains(github.event.pull_request.labels.*.name, 'test-build') || github.event_name == 'push' && endsWith(github.event.ref, 'scylla')
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-11]
steps:
- uses: actions/checkout@v3
- name: Build wheels
uses: pypa/[email protected]
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
if: contains(github.event.pull_request.labels.*.name, 'test-build') || github.event_name == 'push' && endsWith(github.event.ref, 'scylla')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build sdist
run: |
pipx run build --sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
integration_test_scylla:
name: Integration Tests (Scylla)
if: "!contains(github.event.pull_request.labels.*.name, 'disable-integration-test')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Start Scylla
run: |
export DOCKER_ID=$(docker run -d scylladb/scylla:latest --cluster-name test )
export CQL_TEST_HOST=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' ${DOCKER_ID})
while ! nc -z ${CQL_TEST_HOST} 9042; do
sleep 0.1 # wait for 1/10 of the second before check again
done
echo "CQL_TEST_HOST=${CQL_TEST_HOST}" >> $GITHUB_ENV
- name: pytest
run: |
pip install -r ./pylib/requirements.txt
pytest ./cqlshlib/test
integration_test_scylla_cloud_bundle:
name: Integration Tests (Scylla Cloud Bundle)
if: "!contains(github.event.pull_request.labels.*.name, 'disable-integration-test')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Start Scylla cloud bundle setup with CCM
run: |
# install python2 is needed for scylla < 5.3, cause it bundle with old cqlsh
sudo apt update -y
sudo apt install -y python2
python3 -m pip install https://github.com/scylladb/scylla-ccm/archive/master.zip
ccm create test_sni -i 127.0.1. -n 1 --scylla --version release:5.2
ccm start --sni-proxy --sni-port=8443
export CQL_TEST_BUNDLE_PATH=$(realpath ~/.ccm/test_sni/config_data.yaml)
echo "CQL_TEST_BUNDLE_PATH=${CQL_TEST_BUNDLE_PATH}" >> $GITHUB_ENV
- name: pytest
run: |
pip install -r ./pylib/requirements.txt
pytest ./cqlshlib/test
integration_test_cassandra:
name: Integration Tests (Cassandra)
if: "!contains(github.event.pull_request.labels.*.name, 'disable-integration-test')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Start Scylla
run: |
export DOCKER_ID=$(docker run -d -e CASSANDRA_CLUSTER_NAME=test cassandra:4.1 )
export CQL_TEST_HOST=$(docker inspect --format='{{ .NetworkSettings.IPAddress }}' ${DOCKER_ID})
while ! nc -z ${CQL_TEST_HOST} 9042; do
sleep 0.1 # wait for 1/10 of the second before check again
done
echo "CQL_TEST_HOST=${CQL_TEST_HOST}" >> $GITHUB_ENV
- name: pytest
run: |
pip install -r ./pylib/requirements.txt
pytest ./cqlshlib/test
docker:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: determine docker tag base on tag
if: endsWith(github.event.ref, '-scylla')
shell: bash
run: |
split=(${GITHUB_REF_NAME//-/ })
DOCKER_TAG=${split[0]}
echo DOCKER_TAG=$DOCKER_TAG >> $GITHUB_ENV
- name: Build and push release
if: endsWith(github.event.ref, '-scylla')
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
scylladb/scylla-cqlsh:${{ env.DOCKER_TAG }}
scylladb/scylla-cqlsh:latest
- name: Build and push master
uses: docker/build-push-action@v4
if: endsWith(github.event.ref, 'master')
with:
context: .
platforms: linux/amd64,linux/arm64
file: ./Dockerfile
push: true
tags: |
scylladb/scylla-cqlsh:master
upload_pypi:
needs: [build_wheels, build_sdist, integration_test_scylla, integration_test_cassandra]
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
if: github.event_name == 'push' && endsWith(github.event.ref, 'scylla')
# alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}