Use default clone, moving codecov to no PR builds

pull/959/head
Morgan Pretty 1 year ago
parent 7b6a209ff3
commit f0e9f4c9ee

@ -13,27 +13,9 @@ local version_info = {
}; };
// Intentionally doing a depth of 2 as libSession-util has it's own submodules (and libLokinet likely will as well) // Intentionally doing a depth of 2 as libSession-util has it's own submodules (and libLokinet likely will as well)
local custom_clone = { local clone_submodules = {
name: 'Clone Repo', name: 'Clone Submodules',
environment: { CLONE_KEY: { from_secret: 'CLONE_KEY' } }, commands: [ 'git submodule update --init --recursive --depth=2 --jobs=4' ]
commands: [
|||
if [ -z "$CLONE_KEY" ]; then
echo -e "\n\n\n\e[31;1mUnable to checkout repo: CLONE_KEY not set\e[0m"
exit 1
fi
|||,
'mkdir -p $HOME/.ssh && touch $HOME/.ssh/config && touch $HOME/.ssh/known_hosts',
'echo "$CLONE_KEY" > $HOME/.ssh/id_ed25519_drone_ci_deploy',
'chmod 600 $HOME/.ssh/config $HOME/.ssh/known_hosts $HOME/.ssh/id_ed25519_drone_ci_deploy',
'ssh-keyscan -t ed25519 github.com >> $HOME/.ssh/known_hosts',
'export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/id_ed25519_drone_ci_deploy -F $HOME/.ssh/config -o UserKnownHostsFile=$HOME/.ssh/known_hosts"',
'git -c init.defaultBranch=master init',
'git remote add origin $DRONE_GIT_SSH_URL',
'git fetch --depth=1 origin +$DRONE_COMMIT_REF',
'git checkout $DRONE_COMMIT -b $DRONE_BRANCH',
'git submodule update --init --recursive --depth=2 --jobs=4'
]
}; };
// cmake options for static deps mirror // cmake options for static deps mirror
@ -77,7 +59,7 @@ local load_cocoapods_cache = {
'rm -f /Users/drone/.cocoapods_cache.lock' 'rm -f /Users/drone/.cocoapods_cache.lock'
], ],
depends_on: [ depends_on: [
'Clone Repo' 'Clone Submodules'
] ]
}; };
@ -108,21 +90,10 @@ local update_cocoapods_cache(depends_on) = {
depends_on: depends_on, depends_on: depends_on,
}; };
[ // Unit tests
// Unit tests (PRs only) //
{ // The following 4 steps need to be run in order to run the unit tests
kind: 'pipeline', local pre_boot_test_sim = {
type: 'exec',
name: 'Unit Tests',
platform: { os: 'darwin', arch: 'arm64' },
trigger: { event: { exclude: [ 'push' ] } },
clone: { disable: true },
steps: [
version_info,
custom_clone,
load_cocoapods_cache,
install_cocoapods,
{
name: 'Pre-Boot Test Simulator', name: 'Pre-Boot Test Simulator',
commands: [ commands: [
'mkdir -p build/artifacts', 'mkdir -p build/artifacts',
@ -132,8 +103,9 @@ local update_cocoapods_cache(depends_on) = {
'xcrun simctl boot $(cat ./build/artifacts/sim_uuid)', 'xcrun simctl boot $(cat ./build/artifacts/sim_uuid)',
'echo "Pre-booting simulator complete: $(xcrun simctl list | sed "s/^[[:space:]]*//" | grep -o ".*$(cat ./build/artifacts/sim_uuid).*")"', 'echo "Pre-booting simulator complete: $(xcrun simctl list | sed "s/^[[:space:]]*//" | grep -o ".*$(cat ./build/artifacts/sim_uuid).*")"',
] ]
}, };
{
local build_and_run_tests = {
name: 'Build and Run Tests', name: 'Build and Run Tests',
commands: [ commands: [
'NSUnbufferedIO=YES set -o pipefail && xcodebuild test -workspace Session.xcworkspace -scheme Session -derivedDataPath ./build/derivedData -resultBundlePath ./build/artifacts/testResults.xcresult -parallelizeTargets -destination "platform=iOS Simulator,id=$(cat ./build/artifacts/sim_uuid)" -parallel-testing-enabled NO -test-timeouts-enabled YES -maximum-test-execution-time-allowance 10 -collect-test-diagnostics never 2>&1 | xcbeautify --is-ci', 'NSUnbufferedIO=YES set -o pipefail && xcodebuild test -workspace Session.xcworkspace -scheme Session -derivedDataPath ./build/derivedData -resultBundlePath ./build/artifacts/testResults.xcresult -parallelizeTargets -destination "platform=iOS Simulator,id=$(cat ./build/artifacts/sim_uuid)" -parallel-testing-enabled NO -test-timeouts-enabled YES -maximum-test-execution-time-allowance 10 -collect-test-diagnostics never 2>&1 | xcbeautify --is-ci',
@ -142,8 +114,9 @@ local update_cocoapods_cache(depends_on) = {
'Pre-Boot Test Simulator', 'Pre-Boot Test Simulator',
'Install CocoaPods' 'Install CocoaPods'
], ],
}, };
{
local unit_test_summary = {
name: 'Unit Test Summary', name: 'Unit Test Summary',
commands: [ commands: [
||| |||
@ -158,15 +131,24 @@ local update_cocoapods_cache(depends_on) = {
when: { when: {
status: ['failure', 'success'] status: ['failure', 'success']
} }
}, };
{
local delete_test_simulator = {
name: 'Delete Test Simulator', name: 'Delete Test Simulator',
commands: [ commands: [
'xcrun simctl delete unavailable',
||| |||
if [[ -f ./build/artifacts/sim_uuid ]]; then if [[ -f ./build/artifacts/sim_uuid ]]; then
xcrun simctl delete $(cat ./build/artifacts/sim_uuid) xcrun simctl delete $(cat ./build/artifacts/sim_uuid)
fi fi
|||, |||,
|||
if [[ -z $(xcrun simctl list | sed "s/^[[:space:]]*//" | grep -o ".*2879BA18-1253-4EDC-B4AF-A21DAC3025DD.*") ]]; then
echo "Successfully deleted simulator."
else
echo "Failed to delete simulator!"
fi
|||
], ],
depends_on: [ depends_on: [
'Build and Run Tests', 'Build and Run Tests',
@ -174,37 +156,26 @@ local update_cocoapods_cache(depends_on) = {
when: { when: {
status: ['failure', 'success'] status: ['failure', 'success']
} }
}, };
update_cocoapods_cache(['Build and Run Tests']),
{ [
name: 'Install Codecov CLI', // Unit tests (PRs only)
commands: [
'pip3 install codecov-cli 2>&1 | grep "The script codecovcli is installed in" | sed -n -e "s/^.*The script codecovcli is installed in \\(.*\\) which is not on PATH.*$/\\1/p" > ./build/artifacts/codecov_install_path',
|||
if [[ ! -s ./build/artifacts/codecov_install_path ]]; then
which codecovcli > ./build/artifacts/codecov_install_path
fi
|||,
'$(cat ./build/artifacts/codecov_install_path)/codecovcli --version'
],
},
{
name: 'Convert xcresult to xml',
commands: [
'xcresultparser --output-format cobertura ./build/artifacts/testResults.xcresult > ./build/artifacts/coverage.xml',
],
depends_on: ['Build and Run Tests']
},
{ {
name: 'Upload coverage to Codecov', kind: 'pipeline',
commands: [ type: 'exec',
'$(cat ./build/artifacts/codecov_install_path)/codecovcli upload-process --fail-on-error -f ./build/artifacts/coverage.xml', name: 'Unit Tests',
], platform: { os: 'darwin', arch: 'arm64' },
depends_on: [ trigger: { event: { exclude: [ 'push' ] } },
'Convert xcresult to xml', steps: [
'Install Codecov CLI' version_info,
] clone_submodules,
}, load_cocoapods_cache,
install_cocoapods,
pre_boot_test_sim,
build_and_run_tests,
unit_test_summary,
delete_test_simulator,
update_cocoapods_cache(['Build and Run Tests'])
], ],
}, },
// Validate build artifact was created by the direct branch push (PRs only) // Validate build artifact was created by the direct branch push (PRs only)
@ -214,16 +185,12 @@ local update_cocoapods_cache(depends_on) = {
name: 'Check Build Artifact Existence', name: 'Check Build Artifact Existence',
platform: { os: 'darwin', arch: 'arm64' }, platform: { os: 'darwin', arch: 'arm64' },
trigger: { event: { exclude: [ 'push' ] } }, trigger: { event: { exclude: [ 'push' ] } },
clone: { disable: true },
steps: [ steps: [
custom_clone, custom_clone,
{ {
name: 'Poll for build artifact existence', name: 'Poll for build artifact existence',
commands: [ commands: [
'./Scripts/drone-upload-exists.sh' './Scripts/drone-upload-exists.sh'
],
depends_on: [
'Clone Repo'
] ]
} }
] ]
@ -235,10 +202,9 @@ local update_cocoapods_cache(depends_on) = {
name: 'Simulator Build', name: 'Simulator Build',
platform: { os: 'darwin', arch: 'arm64' }, platform: { os: 'darwin', arch: 'arm64' },
trigger: { event: { exclude: [ 'pull_request' ] } }, trigger: { event: { exclude: [ 'pull_request' ] } },
clone: { disable: true },
steps: [ steps: [
version_info, version_info,
custom_clone, clone_submodules,
load_cocoapods_cache, load_cocoapods_cache,
install_cocoapods, install_cocoapods,
{ {
@ -264,4 +230,53 @@ local update_cocoapods_cache(depends_on) = {
}, },
], ],
}, },
// Unit tests and code coverage (non-PRs only)
{
kind: 'pipeline',
type: 'exec',
name: 'Simulator Build',
platform: { os: 'darwin', arch: 'arm64' },
trigger: { event: { exclude: [ 'pull_request' ] } },
steps: [
version_info,
clone_submodules,
load_cocoapods_cache,
install_cocoapods,
pre_boot_test_sim,
build_and_run_tests,
unit_test_summary,
delete_test_simulator,
update_cocoapods_cache(['Build and Run Tests']),
{
name: 'Install Codecov CLI',
commands: [
'pip3 install codecov-cli 2>&1 | grep "The script codecovcli is installed in" | sed -n -e "s/^.*The script codecovcli is installed in (.*) which is not on PATH.*$/\1/p" > ./build/artifacts/codecov_install_path',
|||
if [[ ! -s ./build/artifacts/codecov_install_path ]]; then
which codecovcli > ./build/artifacts/codecov_install_path
fi
|||,
'$(cat ./build/artifacts/codecov_install_path)/codecovcli --version'
],
},
{
name: 'Convert xcresult to xml',
commands: [
'xcresultparser --output-format cobertura ./build/artifacts/testResults.xcresult > ./build/artifacts/coverage.xml',
],
depends_on: ['Build and Run Tests']
},
{
name: 'Upload coverage to Codecov',
environment: { CODECOV_TOKEN: { from_secret: 'CODECOV_TOKEN' } },
commands: [
'$(cat ./build/artifacts/codecov_install_path)/codecovcli upload-process --fail-on-error -f ./build/artifacts/coverage.xml',
],
depends_on: [
'Convert xcresult to xml',
'Install Codecov CLI'
]
},
],
},
] ]

Loading…
Cancel
Save