.cirrus.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. test_task:
  2. env:
  3. ELVISH_TEST_TIME_SCALE: 20
  4. TEST_FLAG: -race
  5. go_modules_cache:
  6. fingerprint_script: cat go.sum
  7. folder: ~/go/pkg/mod
  8. go_build_cache:
  9. folder: ~/.cache/go-build
  10. matrix:
  11. # Re-enable gccgo when it supports Go 1.18.
  12. #- name: Test on gccgo
  13. # container:
  14. # image: debian:unstable-slim
  15. # setup_script:
  16. # - apt-get -y update
  17. # - apt-get -y install ca-certificates gccgo-12 git
  18. # - ln -sf /usr/bin/go-12 /usr/local/bin/go
  19. # env:
  20. # # gccgo doesn't support race test
  21. # TEST_FLAG: ""
  22. - name: Test on Linux ARM64
  23. arm_container:
  24. # The Alpine image has segmentation faults when running test -race, so
  25. # use Debian instead.
  26. image: golang:1.19.3-bullseye
  27. - name: Test on FreeBSD
  28. freebsd_instance:
  29. image_family: freebsd-13-1
  30. env:
  31. PATH: /usr/local/go/bin:$PATH
  32. GO_VERSION: 1.19.3
  33. go_toolchain_cache:
  34. fingerprint_key: $GO_VERSION
  35. folder: /usr/local/go
  36. populate_script: |
  37. pkg install -y curl
  38. curl -L -o go.tar.gz https://go.dev/dl/go$GO_VERSION.freebsd-amd64.tar.gz
  39. tar -C /usr/local -xf go.tar.gz
  40. setup_script: pkg install -y git
  41. go_version_script: go version
  42. test_script: go test $TEST_FLAG ./...
  43. build_binaries_task:
  44. name: Build binaries
  45. only_if: $CIRRUS_BRANCH == 'master'
  46. alias: binaries
  47. env:
  48. CGO_ENABLED: 0
  49. container:
  50. image: golang:1.19.3-alpine
  51. go_modules_cache:
  52. fingerprint_script: cat go.sum
  53. folder: ~/go/pkg/mod
  54. go_build_cache:
  55. folder: ~/.cache/go-build
  56. setup_script: apk add zip
  57. build_binaries_script: |
  58. ELVISH_BUILD_VARIANT=official ./tools/buildall.sh . $CIRRUS_WORKING_DIR/elvish-bin HEAD
  59. binaries_artifacts:
  60. path: elvish-bin/**
  61. check_binary_checksums_task:
  62. name: Check binary checksums ($HOST)
  63. only_if: $CIRRUS_BRANCH == 'master'
  64. container:
  65. image: golang:1.19.3-alpine
  66. depends_on: binaries
  67. env:
  68. GITHUB_TOKEN: ENCRYPTED[42d653b965486640762776cc9c7a98262c2d68d7797c6de801a7764b26a6fd5dbe4952115217f4cc1bed564c336bdf61]
  69. matrix:
  70. - env:
  71. HOST: cdg
  72. - env:
  73. HOST: hkg
  74. setup_script: apk add git curl
  75. wait_website_update_script: |
  76. ts=$(git show -s --format=%ct HEAD)
  77. wait=10
  78. while true; do
  79. website_ts=$(curl -sS https://$HOST.elv.sh/commit-ts.txt)
  80. if test -z "$website_ts"; then
  81. echo "website has no commit-ts.txt yet"
  82. elif test "$website_ts" -ge "$ts"; then
  83. echo "website ($website_ts) >= CI ($ts)"
  84. exit 0
  85. else
  86. echo "website ($website_ts) < CI ($ts)"
  87. fi
  88. sleep $wait
  89. test $wait -lt 96 && wait=`echo "$wait * 2" | bc`
  90. done
  91. check_binary_checksums_script: |
  92. curl -o binaries.zip https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/binaries/binaries.zip
  93. unzip binaries.zip
  94. cd elvish-bin
  95. ret=0
  96. for f in */elvish-HEAD.sha256sum; do
  97. website_sum=$(curl -sS https://$HOST.dl.elv.sh/$f | awk '{print $1}')
  98. ci_sum=$(cat $f | awk '{print $1}')
  99. if test "$website_sum" = "$ci_sum"; then
  100. echo "$f: website == CI ($ci_sum)"
  101. else
  102. echo "$f: website ($website_sum) != CI ($ci_sum)"
  103. ret=1
  104. fi
  105. done
  106. if test $ret != 0; then
  107. latest_sha=$(curl -sS -H "Authorization: token $GITHUB_TOKEN" -H 'Accept: application/vnd.github.VERSION.sha' https://api.github.com/repos/elves/elvish/commits/master)
  108. if test "$CIRRUS_CHANGE_IN_REPO" != "$latest_sha"; then
  109. echo "$CIRRUS_CHANGE_IN_REPO != $latest_sha"
  110. echo "Ignoring the mismatch since there is a newer commit now"
  111. ret=0
  112. fi
  113. fi
  114. exit $ret