Skip to content

Commit

Permalink
Break out CI into script
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterAdams-A committed Nov 1, 2024
1 parent d2187ba commit c9b1143
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
with:
name: "Unit tests"
matrix_linux_command: "printf '#!/bin/sh\nexit 0' > /usr/sbin/policy-rc.d && echo \"deb [signed-by=/etc/apt/keyrings/apache-cassandra.asc] https://debian.cassandra.apache.org 41x main\" | tee -a /etc/apt/sources.list.d/cassandra.sources.list && curl -o /etc/apt/keyrings/apache-cassandra.asc https://downloads.apache.org/cassandra/KEYS && apt-get update && apt install -y default-jre && apt-get install -y cassandra && swift build --explicit-target-dependency-import-check error && while ! nodetool status 2>/dev/null; do echo Waiting for Cassandra.. && sleep 3; done && export CASSANDRA_USER=cassandra && export CASSANDRA_PASSWORD=cassandra && export CASSANDRA_KEYSPACE=cassandra && swift test --explicit-target-dependency-import-check error"
matrix_linux_command: "I_AM_RUNNING_IN_CI=true ./scripts/gha_run_unit_tests.sh"

cxx-interop:
name: Cxx interop
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
with:
name: "Unit tests"
matrix_linux_command: "printf '#!/bin/sh\nexit 0' > /usr/sbin/policy-rc.d && echo \"deb [signed-by=/etc/apt/keyrings/apache-cassandra.asc] https://debian.cassandra.apache.org 41x main\" | tee -a /etc/apt/sources.list.d/cassandra.sources.list && curl -o /etc/apt/keyrings/apache-cassandra.asc https://downloads.apache.org/cassandra/KEYS && apt-get update && apt install -y default-jre && apt-get install -y cassandra && swift build --explicit-target-dependency-import-check error && while ! nodetool status 2>/dev/null; do echo Waiting for Cassandra.. && sleep 3; done && export CASSANDRA_USER=cassandra && export CASSANDRA_PASSWORD=cassandra && export CASSANDRA_KEYSPACE=cassandra && swift test --explicit-target-dependency-import-check error"
matrix_linux_command: "I_AM_RUNNING_IN_CI=true ./scripts/gha_run_unit_tests.sh"

cxx-interop:
name: Cxx interop
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
uses: apple/swift-nio/.github/workflows/swift_matrix.yml@main
with:
name: "Unit tests"
matrix_linux_command: "printf '#!/bin/sh\nexit 0' > /usr/sbin/policy-rc.d && echo \"deb [signed-by=/etc/apt/keyrings/apache-cassandra.asc] https://debian.cassandra.apache.org 41x main\" | tee -a /etc/apt/sources.list.d/cassandra.sources.list && curl -o /etc/apt/keyrings/apache-cassandra.asc https://downloads.apache.org/cassandra/KEYS && apt-get update && apt install -y default-jre && apt-get install -y cassandra && swift build --explicit-target-dependency-import-check error && while ! nodetool status 2>/dev/null; do echo Waiting for Cassandra.. && sleep 3; done && export CASSANDRA_USER=cassandra && export CASSANDRA_PASSWORD=cassandra && export CASSANDRA_KEYSPACE=cassandra && swift test --explicit-target-dependency-import-check error"
matrix_linux_command: "I_AM_RUNNING_IN_CI=true ./scripts/gha_run_unit_tests.sh"
40 changes: 40 additions & 0 deletions scripts/gha_run_unit_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
##===----------------------------------------------------------------------===##
##
## This source file is part of the Swift Cassandra Client open source project
##
## Copyright (c) 2017-2018 Apple Inc. and the SwiftNIO project authors
## Licensed under Apache License v2.0
##
## See LICENSE.txt for license information
## See CONTRIBUTORS.txt for the list of SwiftNIO project authors
##
## SPDX-License-Identifier: Apache-2.0
##
##===----------------------------------------------------------------------===##

set -e

if [ -z ${I_AM_RUNNING_IN_CI} ]
then
echo "Not running in CI"
exit 1
fi

printf '#!/bin/sh\nexit 0' > /usr/sbin/policy-rc.d
echo \"deb [signed-by=/etc/apt/keyrings/apache-cassandra.asc] https://debian.cassandra.apache.org 41x main\" | tee -a /etc/apt/sources.list.d/cassandra.sources.list
curl -o /etc/apt/keyrings/apache-cassandra.asc https://downloads.apache.org/cassandra/KEYS
apt-get update
apt install -y -q default-jre
apt-get install -y -q cassandra
swift build --explicit-target-dependency-import-check error
while ! nodetool status 2>/dev/null
do
echo Waiting for Cassandra..
sleep 3
done

export CASSANDRA_USER=cassandra
export CASSANDRA_PASSWORD=cassandra
export CASSANDRA_KEYSPACE=cassandra
swift test --explicit-target-dependency-import-check error

0 comments on commit c9b1143

Please sign in to comment.