summarylogtreecommitdiffstats
path: root/.travis.yml
blob: 8ac4a3e8bb0e4a95401ad92157c8803f416cbefe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
sudo: required

branches:
  only:
  - master

cache:
  directories:
  - .ccache
  - .arch-cache
  - AUR-repo
  - LuxCore.git

services:
- docker

arch:
  repos:
  - bartus=https://github.com/bartoszek/AUR-repo/raw/master
  packages:
# disable to prevent `package-cleanup.hook`
# - ccache
# - moreutils
  script:
  - "echo 'options+=(ccache)' >> PKGBUILD"
  - "export CCACHE_DIR='/build/.ccache'"
# COMPRESSXZ=(), can't be passed to makepkg as bash dosn't support array in `export` statement.
  - "echo 'COMPRESSXZ=(xz -T 0 -7 -c -z -)' >> PKGBUILD"
# override `package-cleanup.hook` to preserve cache for travis.
  - "sudo mkdir /etc/pacman.d/hooks/ && sudo ln -s /dev/null /etc/pacman.d/hooks/package-cleanup.hook"
  - "sudo pacman -S --noconfirm ccache moreutils bc"
# check for new version
# @update_interval in days
  - "update_interval=5"
  - 'update_offset=$(. PKGBUILD; sha1sum <<<"$pkgname"|sed -e "s/[a-z -]//g" -e "s/^0*//"|echo `cat`%$update_interval|bc)'
  - "next_update=$(((365-`date +%j`+update_offset)%update_interval))"
# force update on commit message containing [force|rebuild]
  - "force_update=$(git log --pretty=%B -1|egrep -q '\[(force|rebuild)\]'; echo $?"
  - "makepkg -od --skipinteg"
  - "new_pkgver=$(. PKGBUILD; [[ -v epoch ]] && echo -n $epoch:; echo $pkgver-$pkgrel)"
  - "old_pkgver=$(. PKGBUILD; pacman -S --print-format %v $pkgname|tail -n1)"
  - '[[ "$new_pkgver" == "$old_pkgver" && $next_update != 0 && $force_update != 0 ]] && { echo -e "Current version is up to date!\nNext force update in $next_update days!"; exit 0; }'
# exit with makepkg return code
  - "set -o pipefail"
  - "makepkg -s --noconfirm TRAVIS=1 MAKEFLAGS='-j2' 2>&1 |ts -s '[%.T]'; makepkg_ret=$?"
  - "ccache -s"
  - "exit $makepkg_ret"

script:
- "curl -s https://raw.githubusercontent.com/bartoszek/arch-travis/pacman-pkg-cache/arch-travis.sh | bash"
- "echo 'pacman pkg cache size: ' $(du -h .arch-cache|cut -f1) in $(ls .arch-cache|wc -l) files"

deploy:
  on:
    branch: master
  skip_cleanup: true
  provider: script
  script: bash .travis_deploy.sh