Skip to content

Commit 17afc91

Browse files
Publish archived local sccache to S3
1 parent 23501a5 commit 17afc91

File tree

1 file changed

+59
-17
lines changed

1 file changed

+59
-17
lines changed

.drone.jsonnet

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ local Pipeline(branch, platform, event, arch='amd64', server='10.6-enterprise')
685685
platform: { arch: arch },
686686
// [if arch == 'arm64' then 'node']: { arch: 'arm64' },
687687
clone: { depth: 10 },
688-
steps: [
688+
steps: std.filter(function(step) step != null, [
689689
{
690690
name: 'submodules',
691691
image: 'alpine/git',
@@ -718,8 +718,36 @@ local Pipeline(branch, platform, event, arch='amd64', server='10.6-enterprise')
718718
],
719719
},
720720
{
721-
name: 'build',
721+
name: 'get-local-sccache',
722722
depends_on: ['clone-mdb'],
723+
image: 'amazon/aws-cli',
724+
volumes: [pipeline._volumes.mdb],
725+
environment: {
726+
AWS_ACCESS_KEY_ID: {
727+
from_secret: 'aws_access_key_id',
728+
},
729+
AWS_SECRET_ACCESS_KEY: {
730+
from_secret: 'aws_secret_access_key',
731+
},
732+
},
733+
commands: [
734+
'yum install -y tar zstd',
735+
'mkdir -p /mdb/sccache',
736+
'echo "Attempting to download SCCache archive from S3..."',
737+
'if aws s3 cp s3://cspkg/nightly-sccache/stable-23.10-' + server + '-' + arch + '-' + std.strReplace(platform, ":", "-") + '/sccache.tar.zst /tmp/sccache.tar.zst; then',
738+
' echo "SCCache archive found. Extracting..."',
739+
' tar -I zstd -xf /tmp/sccache.tar.zst -C /mdb/sccache',
740+
' ls /mdb/sccache/ && mv /mdb/sccache/mdb/sccache /mdb/sccache_inner && rm -rf /mdb/sccache/ && mv /mdb/sccache_inner /mdb/sccache', # TODO remove
741+
' echo "SCCache successfully downloaded and extracted."',
742+
' ls /mdb/sccache',
743+
'else',
744+
' echo "SCCache archive not found on S3. Proceeding without it."',
745+
'fi',
746+
],
747+
},
748+
{
749+
name: 'build',
750+
depends_on: ['get-local-sccache'],
723751
image: img,
724752
volumes: [pipeline._volumes.mdb],
725753
environment: {
@@ -733,19 +761,15 @@ local Pipeline(branch, platform, event, arch='amd64', server='10.6-enterprise')
733761
AWS_SECRET_ACCESS_KEY: {
734762
from_secret: 'aws_secret_access_key',
735763
},
736-
SCCACHE_DIR: '/tmp/sccache', // local cache for sccache
764+
SCCACHE_DIR: '/mdb/sccache', // local cache for sccache
737765
SCCACHE_CACHE_SIZE: '20G',
738-
// SCCACHE_BUCKET: 'cs-sccache', // remote S3 cache in case we have a local miss
739-
// SCCACHE_REGION: 'us-east-1',
740-
// SCCACHE_S3_USE_SSL: 'true',
741-
// SCCACHE_S3_KEY_PREFIX: result + branch + server + arch + '${DRONE_PULL_REQUEST}',
742-
SCCACHE_ERROR_LOG: '/tmp/sccache_log.txt',
743-
SCCACHE_LOG: 'sccache_debug.txt',
766+
// SCCACHE_ERROR_LOG: '/tmp/sccache_log.txt',
767+
// SCCACHE_LOG: 'sccache_debug.txt',
744768
},
745769
commands: [
746770
'export CLICOLOR_FORCE=1',
747771
get_sccache,
748-
'mkdir -p /tmp/sccache',
772+
'mkdir -p /mdb/sccache',
749773
'mkdir /mdb/' + builddir + '/' + result,
750774

751775
'bash -c "set -o pipefail && bash /mdb/' + builddir + '/storage/columnstore/columnstore/build/bootstrap_mcs.sh ' +
@@ -757,12 +781,6 @@ local Pipeline(branch, platform, event, arch='amd64', server='10.6-enterprise')
757781
'/mdb/' + builddir + '/' + result + '/build.log"' ,
758782
'sccache --show-adv-stats',
759783

760-
// if this is a nightly build, archive local sccache dir and upload it to S3
761-
'du -hs /tmp/sccache',
762-
'time tar -I pzstd -cf sccache.tar.zst /tmp/sccache',
763-
'time aws s3 cp sccache.tar.zst s3://cspkg/nightly-sccache/stable-23.10-' + server + '-' + arch + '-' + std.strReplace(platform, ':', '-') + '/sccache.tar.zst',
764-
'echo "Nightly build cache uploaded to: s3://cspkg/nightly-sccache/stable-23.10-' + server + '-' + arch + '-' + std.strReplace(platform, ':', '-') + '/sccache.tar.zst"',
765-
766784
// move engine and cmapi packages to one dir and make a repo
767785
if (pkg_format == 'rpm') then "mv -v -t ./" + result + "/ /mdb/" + builddir + "/*.rpm /drone/src/cmapi/" + result + "/*.rpm && createrepo ./" + result
768786
else "mv -v -t ./" + result + "/ /mdb/*.deb /drone/src/cmapi/" + result + "/*.deb && dpkg-scanpackages " + result + " | gzip > ./" + result + "/Packages.gz",
@@ -771,6 +789,30 @@ local Pipeline(branch, platform, event, arch='amd64', server='10.6-enterprise')
771789
'ls -la /mdb/' + builddir + '/storage/columnstore/columnstore/storage-manager',
772790
],
773791
},
792+
// (if (event == 'cron') then { // Publish cache only in the nightly builds)
793+
(if (1 == 1) then {
794+
name: 'publish-sccache',
795+
depends_on: ['build'],
796+
image: 'amazon/aws-cli',
797+
volumes: [pipeline._volumes.mdb],
798+
environment: {
799+
AWS_ACCESS_KEY_ID: {
800+
from_secret: 'aws_access_key_id',
801+
},
802+
AWS_SECRET_ACCESS_KEY: {
803+
from_secret: 'aws_secret_access_key',
804+
},
805+
},
806+
commands: [
807+
'yum install -y tar zstd',
808+
'du -hs /mdb/sccache',
809+
'cd /mdb/sccache',
810+
'time tar -I pzstd -cf ../sccache.tar.zst .',
811+
'cd ..',
812+
'time aws s3 cp sccache.tar.zst s3://cspkg/nightly-sccache/stable-23.10-' + server + '-' + arch + '-' + std.strReplace(platform, ':', '-') + '/sccache.tar.zst',
813+
'echo "Nightly build cache uploaded to: s3://cspkg/nightly-sccache/stable-23.10-' + server + '-' + arch + '-' + std.strReplace(platform, ':', '-') + '/sccache.tar.zst"',
814+
],
815+
} else null),
774816
{
775817
name: 'unittests',
776818
depends_on: ['build'],
@@ -813,7 +855,7 @@ local Pipeline(branch, platform, event, arch='amd64', server='10.6-enterprise')
813855
'ls -l /drone/src/%s | grep columnstore' % result,
814856
],
815857
},
816-
] +
858+
]) +
817859
[pipeline.cmapipython] + [pipeline.cmapibuild] +
818860
[pipeline.publish('cmapi build')] +
819861
[pipeline.publish()] +

0 commit comments

Comments
 (0)