Skip to content

Commit ba3b63e

Browse files
committed
Move all cicd steps into Makefile
1. Implement all steps in Makefile 2. Make CICD use Makefile 3. Drop setup-environment step, it is done automatically now 4. Add linting step
1 parent 05e6036 commit ba3b63e

File tree

3 files changed

+213
-176
lines changed

3 files changed

+213
-176
lines changed

.github/actions/setup-environment/action.yml

Lines changed: 0 additions & 50 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 62 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ on:
77
pull_request:
88
types: [ opened, synchronize, reopened ]
99

10-
env:
11-
CCM_VERSION: "4621dfee5ad73956b831091a8b863d100d25c610"
12-
1310
jobs:
1411
build:
1512
name: Unit tests
@@ -22,9 +19,11 @@ jobs:
2219
- uses: actions/setup-go@v4
2320
with:
2421
go-version: ${{ matrix.go }}
25-
- run: go vet ./...
22+
- name: Run linting
23+
run: make check
2624
- name: Run unit tests
27-
run: go test -v -tags unit -race ./...
25+
run: make test-unit
26+
2827
integration-cassandra:
2928
timeout-minutes: 15
3029
needs:
@@ -45,82 +44,51 @@ jobs:
4544
compressor: "snappy"
4645
steps:
4746
- uses: actions/checkout@v2
48-
- uses: actions/setup-go@v2
47+
48+
- uses: actions/setup-go@v5
4949
with:
5050
go-version: ${{ matrix.go }}
51-
- uses: actions/cache@v4
52-
id: gomod-cache
53-
with:
54-
path: ~/go/pkg/mod
55-
key: ${{ runner.os }}-go-${{ hashFiles('go.mod') }}
56-
restore-keys: |
57-
${{ runner.os }}-go-
58-
- name: Setup environment
59-
uses: ./.github/actions/setup-environment
60-
- name: Start cassandra nodes
61-
run: |
62-
source ~/venv/bin/activate
63-
VERSION=${{ matrix.cassandra_version }}
64-
keypath="$(pwd)/testdata/pki"
65-
conf=(
66-
"client_encryption_options.enabled: true"
67-
"client_encryption_options.keystore: $keypath/.keystore"
68-
"client_encryption_options.keystore_password: cassandra"
69-
"client_encryption_options.require_client_auth: true"
70-
"client_encryption_options.truststore: $keypath/.truststore"
71-
"client_encryption_options.truststore_password: cassandra"
72-
"concurrent_reads: 2"
73-
"concurrent_writes: 2"
74-
"write_request_timeout_in_ms: 5000"
75-
"read_request_timeout_in_ms: 5000"
76-
)
77-
78-
if [[ $VERSION == 3.*.* ]]; then
79-
conf+=(
80-
"rpc_server_type: sync"
81-
"rpc_min_threads: 2"
82-
"rpc_max_threads: 2"
83-
"enable_user_defined_functions: true"
84-
"enable_materialized_views: true"
85-
)
86-
elif [[ $VERSION == 4.0.* ]]; then
87-
conf+=(
88-
"enable_user_defined_functions: true"
89-
"enable_materialized_views: true"
90-
)
91-
else
92-
conf+=(
93-
"user_defined_functions_enabled: true"
94-
"materialized_views_enabled: true"
95-
)
96-
fi
9751

98-
ccm remove test || true
99-
100-
ccm create test -v $VERSION -n 3 -d --vnodes --jvm_arg="-Xmx256m -XX:NewSize=100m"
101-
ccm updateconf "${conf[@]}"
52+
- uses: actions/setup-python@v5
53+
with:
54+
python-version: '3.10'
55+
cache: 'pip'
56+
cache-dependency-path: Makefile
10257

103-
export JVM_EXTRA_OPTS=" -Dcassandra.test.fail_writes_ks=test -Dcassandra.custom_query_handler_class=org.apache.cassandra.cql3.CustomPayloadMirroringQueryHandler"
58+
- name: Set up cache for SDKMAN
59+
uses: actions/cache@v3
60+
with:
61+
path: ~/.sdkman
62+
key: ${{ runner.os }}-sdkman
10463

105-
ccm start --wait-for-binary-proto --verbose
106-
ccm status
107-
ccm node1 nodetool status
64+
- name: Set up cache for CCM
65+
uses: actions/cache@v4
66+
with:
67+
path: ~/.ccm/repository
68+
key: ${{ runner.os }}-ccm-${{ matrix.cassandra_version }}
10869

109-
args="-gocql.timeout=60s -runssl -proto=${{ matrix.proto_version }} -rf=3 -clusterSize=3 -autowait=2000ms -compressor=${{ matrix.compressor }} -gocql.cversion=$VERSION -cluster=$(ccm liveset) ./..."
70+
- name: Start cassandra nodes
71+
env:
72+
CASSANDRA_VERSION: ${{ matrix.cassandra_version }}
73+
run: |
74+
make cassandra-start
75+
sleep 30s
11076
111-
echo "args=$args" >> $GITHUB_ENV
112-
echo "JVM_EXTRA_OPTS=$JVM_EXTRA_OPTS" >> $GITHUB_ENV
11377
- name: Integration tests
78+
env:
79+
CASSANDRA_VERSION: ${{ matrix.cassandra_version }}
80+
TEST_CQL_PROTOCOL: ${{ matrix.proto_version }}
81+
TEST_COMPRESSOR: ${{ matrix.compressor }}
82+
TEST_INTEGRATION_TAGS: ${{ matrix.tags }}
11483
run: |
115-
source ~/venv/bin/activate
116-
export JVM_EXTRA_OPTS="${{env.JVM_EXTRA_OPTS}}"
117-
go test -v -tags "${{ matrix.tags }} gocql_debug" -timeout=5m -race ${{ env.args }}
84+
make test-integration
85+
11886
- name: 'Save ccm logs'
11987
if: 'failure()'
12088
uses: actions/upload-artifact@v4
12189
with:
12290
name: ccm-cluster-cassandra-${{ matrix.cassandra_version }}-go-${{ matrix.go }}-tag-${{ matrix.tags }}-proto-version-${{ matrix.proto_version }}-compressor-${{ matrix.compressor }}
123-
path: /home/runner/.ccm/test
91+
path: /home/runner/.ccm/gocql_integration_test
12492
retention-days: 5
12593
integration-auth-cassandra:
12694
timeout-minutes: 15
@@ -144,69 +112,37 @@ jobs:
144112
- uses: actions/setup-go@v4
145113
with:
146114
go-version: ${{ matrix.go }}
147-
- name: Setup environment
148-
uses: ./.github/actions/setup-environment
149-
- name: Start cassandra nodes
150-
run: |
151-
source ~/venv/bin/activate
152-
VERSION=${{ matrix.cassandra_version }}
153-
keypath="$(pwd)/testdata/pki"
154-
conf=(
155-
"client_encryption_options.enabled: true"
156-
"client_encryption_options.keystore: $keypath/.keystore"
157-
"client_encryption_options.keystore_password: cassandra"
158-
"client_encryption_options.require_client_auth: true"
159-
"client_encryption_options.truststore: $keypath/.truststore"
160-
"client_encryption_options.truststore_password: cassandra"
161-
"concurrent_reads: 2"
162-
"concurrent_writes: 2"
163-
"write_request_timeout_in_ms: 5000"
164-
"read_request_timeout_in_ms: 5000"
165-
"authenticator: PasswordAuthenticator"
166-
"authorizer: CassandraAuthorizer"
167-
"enable_user_defined_functions: true"
168-
)
169-
170-
if [[ $VERSION == 3.*.* ]]; then
171-
conf+=(
172-
"rpc_server_type: sync"
173-
"rpc_min_threads: 2"
174-
"rpc_max_threads: 2"
175-
"enable_user_defined_functions: true"
176-
"enable_materialized_views: true"
177-
)
178-
elif [[ $VERSION == 4.0.* ]]; then
179-
conf+=(
180-
"enable_user_defined_functions: true"
181-
"enable_materialized_views: true"
182-
)
183-
else
184-
conf+=(
185-
"user_defined_functions_enabled: true"
186-
"materialized_views_enabled: true"
187-
)
188-
fi
189-
190-
ccm remove test || true
191-
192-
ccm create test -v $VERSION -n 1 -d --vnodes --jvm_arg="-Xmx256m -XX:NewSize=100m"
193-
ccm updateconf "${conf[@]}"
194-
195-
rm -rf $HOME/.ccm/test/node1/data/system_auth
196115

197-
export JVM_EXTRA_OPTS=" -Dcassandra.test.fail_writes_ks=test -Dcassandra.custom_query_handler_class=org.apache.cassandra.cql3.CustomPayloadMirroringQueryHandler"
116+
- uses: actions/setup-python@v5
117+
with:
118+
python-version: '3.10'
119+
cache: 'pip'
120+
cache-dependency-path: Makefile
198121

199-
ccm start --wait-for-binary-proto --verbose
200-
ccm status
201-
ccm node1 nodetool status
122+
- name: Set up cache for SDKMAN
123+
uses: actions/cache@v3
124+
with:
125+
path: ~/.sdkman
126+
key: ${{ runner.os }}-sdkman
202127

203-
args="-gocql.timeout=60s -runssl -proto=${{ matrix.proto_version }} -rf=3 -clusterSize=1 -autowait=2000ms -compressor=${{ matrix.compressor }} -gocql.cversion=$VERSION -cluster=$(ccm liveset) ./..."
128+
- name: Set up cache for CCM
129+
uses: actions/cache@v4
130+
with:
131+
path: ~/.ccm/repository
132+
key: ${{ runner.os }}-ccm-${{ matrix.cassandra_version }}
204133

205-
echo "args=$args" >> $GITHUB_ENV
206-
echo "JVM_EXTRA_OPTS=$JVM_EXTRA_OPTS" >> $GITHUB_ENV
134+
- name: Start cassandra nodes
135+
env:
136+
CASSANDRA_VERSION: ${{ matrix.cassandra_version }}
137+
run: |
138+
make cassandra-start
207139
sleep 30s
140+
208141
- name: Integration tests
142+
env:
143+
CASSANDRA_VERSION: ${{ matrix.cassandra_version }}
144+
TEST_CQL_PROTOCOL: ${{ matrix.proto_version }}
145+
TEST_COMPRESSOR: ${{ matrix.compressor }}
146+
TEST_INTEGRATION_TAGS: ${{ matrix.tags }}
209147
run: |
210-
source ~/venv/bin/activate
211-
export JVM_EXTRA_OPTS="${{env.JVM_EXTRA_OPTS}}"
212-
go test -v -run=TestAuthentication -tags "${{ matrix.tags }} gocql_debug" -timeout=15s -runauth ${{ env.args }}
148+
make test-integration-auth

0 commit comments

Comments
 (0)