Skip to content

Commit

Permalink
ci: Move linter task to cirrus
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv committed Dec 16, 2020
1 parent 94a9cd2 commit c00ca01
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 96 deletions.
54 changes: 38 additions & 16 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
### Global defaults

timeout_in: 120m # https://cirrus-ci.org/faq/#instance-timed-out
container:
# https://cirrus-ci.org/faq/#are-there-any-limits
# Each project has 16 CPU in total, assign 2 to each container, so that 8 tasks run in parallel
cpu: 2
memory: 8G # Set to 8GB to avoid OOM. https://cirrus-ci.org/guide/linux/#linux-containers
kvm: true # Use kvm to avoid spurious CI failures in the default virtualization cluster, see https://github.com/bitcoin/bitcoin/issues/20093
env:
PACKAGE_MANAGER_INSTALL: "apt-get update && apt-get install -y"
MAKEJOBS: "-j4"
Expand All @@ -15,11 +9,27 @@ env:
CCACHE_SIZE: "200M"
CCACHE_DIR: "/tmp/ccache_dir"

### Global task template

### Base template
# https://cirrus-ci.org/guide/tips-and-tricks/#sharing-configuration-between-tasks
base_template: &BASE_TEMPLATE
skip: $CIRRUS_REPO_FULL_NAME == "bitcoin-core/gui" && $CIRRUS_PR == "" # No need to run on the read-only mirror, unless it is a PR. https://cirrus-ci.org/guide/writing-tasks/#conditional-task-execution
container:
# https://cirrus-ci.org/faq/#are-there-any-limits
# Each project has 16 CPU in total, assign 2 to each container, so that 8 tasks run in parallel
cpu: 2
memory: 8G # Set to 8GB to avoid OOM. https://cirrus-ci.org/guide/linux/#linux-containers
kvm: true # Use kvm to avoid spurious CI failures in the default virtualization cluster, see https://github.com/bitcoin/bitcoin/issues/20093
merge_base_script:
- if [ "$CIRRUS_PR" = "" ]; then exit 0; fi
- bash -c "$PACKAGE_MANAGER_INSTALL git"
- git fetch $CIRRUS_REPO_CLONE_URL $CIRRUS_BASE_BRANCH
- git config --global user.email "ci@ci.ci"
- git config --global user.name "ci"
- git merge FETCH_HEAD # Merge base to detect silent merge conflicts

### Global task template
global_task_template: &GLOBAL_TASK_TEMPLATE
skip: $CIRRUS_REPO_FULL_NAME == "bitcoin-core/gui" && $CIRRUS_PR == "" # No need to run on the read-only mirror, unless it is a PR. https://cirrus-ci.org/guide/writing-tasks/#conditional-task-execution
<< : *BASE_TEMPLATE
ccache_cache:
folder: "/tmp/ccache_dir"
depends_built_cache:
Expand All @@ -28,13 +38,6 @@ global_task_template: &GLOBAL_TASK_TEMPLATE
folder: "/tmp/cirrus-ci-build/depends/sdk-sources"
depends_releases_cache:
folder: "/tmp/cirrus-ci-build/releases"
merge_base_script:
- if [ "$CIRRUS_PR" = "" ]; then exit 0; fi
- bash -c "$PACKAGE_MANAGER_INSTALL git"
- git fetch $CIRRUS_REPO_CLONE_URL $CIRRUS_BASE_BRANCH
- git config --global user.email "ci@ci.ci"
- git config --global user.name "ci"
- git merge FETCH_HEAD # Merge base to detect silent merge conflicts
ci_script:
- ./ci/test_run_all.sh

Expand All @@ -54,6 +57,25 @@ global_task_template: &GLOBAL_TASK_TEMPLATE
# install_script:
# - choco install python --version=3.7.7 -y

task:
name: 'lint'
<< : *BASE_TEMPLATE
container:
image: ubuntu:bionic # For python 3.6, oldest supported version according to doc/dependencies.md
cpu: 1 # Cut credits bill in half
# For faster CI feedback, immediately schedule the linters. https://cirrus-ci.org/pricing/#compute-credits
use_compute_credits: $CIRRUS_REPO_FULL_NAME == 'bitcoin/bitcoin'
setup_script:
- set -o errexit; source ./ci/test/00_setup_env.sh
before_install_script:
- set -o errexit; source ./ci/test/03_before_install.sh
install_script:
- set -o errexit; source ./ci/lint/04_install.sh
before_script:
- set -o errexit; source ./ci/lint/05_before_script.sh
lint_script:
- set -o errexit; source ./ci/lint/06_script.sh

task:
name: 'ARM [unit tests, no functional tests] [buster]'
<< : *GLOBAL_TASK_TEMPLATE
Expand Down
66 changes: 0 additions & 66 deletions .travis.yml

This file was deleted.

14 changes: 7 additions & 7 deletions ci/lint/04_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

export LC_ALL=C

travis_retry sudo apt update && sudo apt install -y clang-format-9
sudo update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-9 ) 100
sudo update-alternatives --install /usr/bin/clang-format-diff clang-format-diff $(which clang-format-diff-9) 100
${CI_RETRY_EXE} apt update && apt install -y clang-format-9 python3-pip curl git
update-alternatives --install /usr/bin/clang-format clang-format $(which clang-format-9 ) 100
update-alternatives --install /usr/bin/clang-format-diff clang-format-diff $(which clang-format-diff-9) 100

travis_retry pip3 install codespell==1.17.1
travis_retry pip3 install flake8==3.8.3
travis_retry pip3 install yq
travis_retry pip3 install mypy==0.781
${CI_RETRY_EXE} pip3 install codespell==1.17.1
${CI_RETRY_EXE} pip3 install flake8==3.8.3
${CI_RETRY_EXE} pip3 install yq
${CI_RETRY_EXE} pip3 install mypy==0.781

SHELLCHECK_VERSION=v0.7.1
curl -sL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | tar --xz -xf - --directory /tmp/
Expand Down
2 changes: 1 addition & 1 deletion ci/lint/05_before_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

export LC_ALL=C

git fetch --unshallow
git fetch
12 changes: 6 additions & 6 deletions ci/lint/06_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

export LC_ALL=C

if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then
# TRAVIS_BRANCH will be present in a Travis environment. For builds triggered
if [ -n "$CIRRUS_PR" ]; then
# CIRRUS_PR will be present in a Cirrus environment. For builds triggered
# by a pull request this is the name of the branch targeted by the pull request.
# https://docs.travis-ci.com/user/environment-variables/
COMMIT_RANGE="$TRAVIS_BRANCH..HEAD"
# https://cirrus-ci.org/guide/writing-tasks/#environment-variables
COMMIT_RANGE="$CIRRUS_BRANCH..HEAD"
test/lint/commit-script-check.sh $COMMIT_RANGE
fi

Expand All @@ -25,8 +25,8 @@ test/lint/check-doc.py
test/lint/check-rpc-mappings.py .
test/lint/lint-all.sh

if [ "$TRAVIS_REPO_SLUG" = "bitcoin/bitcoin" ] && [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then
if [ "$CIRRUS_REPO_FULL_NAME" = "bitcoin/bitcoin" ] && [ -n "$CIRRUS_CRON" ]; then
git log --merges --before="2 days ago" -1 --format='%H' > ./contrib/verify-commits/trusted-sha512-root-commit
travis_retry gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys $(<contrib/verify-commits/trusted-keys) &&
${CI_RETRY_EXE} gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys $(<contrib/verify-commits/trusted-keys) &&
./contrib/verify-commits/verify-commits.py --clean-merge=2;
fi

0 comments on commit c00ca01

Please sign in to comment.