-
Notifications
You must be signed in to change notification settings - Fork 725
/
.travis.yml
155 lines (137 loc) · 6.33 KB
/
.travis.yml
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
language: node_js
node_js:
- 20.9 # latest LTS version ('node' will give latest version, 'lts/*' will give LTS version )
arch: amd64 # optional, this is default, routes to a full VM
# arch: arm64 # this is the recommended LXD container - faster spin up but some limitations Not used as it seems very unstable.
os: linux # optional, this is default
dist: jammy # or bionic | xenial | trusty | precise with xenial as default - Recommended here: https://docs.travis-ci.com/user/reference/overview/#deprecated-virtualization-environments
git:
depth: 20000 # We're cloning this many commits as it is roughly covering the last 4 years of commits, thus letting us show the last changed date on the documentation pages.
quiet: true # prevent commit numbers appearing in the log and being flagged as potential security leaks.
submodules: false # turn off submodules
env:
global:
# Global variables can go here, for example HUGO_VERSION if we were using Netlify to publish.
branches:
# build only development and production
only:
- production
- development
# Start of Travis Job Lifecycle: https://docs.travis-ci.com/user/job-lifecycle/
# addons:
######### Skipped
#
# snaps: # Installs hugo if dist: xenial or bionic see https://gohugo.io/getting-started/installing/#snap-package and https://docs.travis-ci.com/user/installing-dependencies/#installing-snap-packages-with-the-snaps-addon
# ===================================================================================================
# TOO RISKY TO USE SNAP - IF WRONG VERSION IS UPLOADED THEN DIFFICULT TO GO BACK TO DIFFERENT VERSION
# ===================================================================================================
# - name: hugo
# channel: extended/stable # needs extended to compile SCSS etc. Issue if snap is not updated correctly
# cache:
######## Skipped
#
# Is there anything worth cacheing that isn't currently cached?
# see https://docs.travis-ci.com/user/caching/#how-does-caching-work
# Probably NOT /static
# Docsy theme?
# Custom layouts?
# SASS/CSS
#
before_install:
###############
# Hugo, Docsy and dependencies are installed via npm
- npm install # use npm rather than yarn - HUGO doesn't have that many dependencies
#
# Currently will use custom version of htmltest stored in /htmltest/htmltest
# This version makes the html.Parse much smaller
# For htmltest installation instructions, see https://github.com/wjdp/htmltest/blob/master/README.md
# - travis_retry curl https://htmltest.wjdp.uk | bash # install htmltest into $TRAVIS_BUILD_DIR/bin/htmltest
install:
########
# ------------------------
- mkdir public # This because <Maybe> the process of syncing to public is probably deadlocked behind waiting for the public folder to be made, and is never signalled that the folder is created, which ends up stalling the build on Travis CI.
# ------------------------
- ./node_modules/.bin/hugo config --environment $TRAVIS_BRANCH # report the config we are using
- echo "HUGO was run for environment $TRAVIS_BRANCH" > $TRAVIS_BUILD_DIR/hugo.log
# Set pipefail so that if Hugo fails the whole job fails
- set -o pipefail
# put the flags in different config files controlled by environment matching $TRAVIS_BRANCH
# Append output to hugo.log file to print at the end of the travis job
# (see https://stackoverflow.com/questions/418896/how-to-redirect-output-to-a-file-and-stdout)
- ./node_modules/.bin/hugo --environment $TRAVIS_BRANCH 2>&1 | tee -a $TRAVIS_BUILD_DIR/hugo.log
#
# normal htmltest takes too much memory - using a modified version which strips <aside> tag content
# NB - Set pipefail so that Travis CI sees the return code from `tee` and not from `htmltest` so it will always build.
- set +o pipefail
- echo "Any errors from HTMLTEST will be treated as warnings - the build will continue." >> $TRAVIS_BUILD_DIR/hugo.log
- chmod +x ./htmltest/htmltest
- ./htmltest/htmltest 2>&1 | tee -a $TRAVIS_BUILD_DIR/hugo.log
before_script:
##############
- pyenv versions # list python versions supported by pyenv in case version in next command is removed
- pyenv global 3.8 # this version needs to be already installed in the travis build
- python -V
script:
#######
# Uncomment these variables if you want to see what values are there
# - echo $HOME
# - echo $TRAVIS_BRANCH
# - echo $TRAVIS_BUILD_DIR
# - echo $TRAVIS_BUILD_ID
# - echo $TRAVIS_BUILD_NUMBER
# - echo $TRAVIS_BUILD_WEB_URL
# - echo $TRAVIS_COMMIT
# - echo $TRAVIS_COMMIT_MESSAGE
# - echo $TRAVIS_COMMIT_RANGE
# - echo $TRAVIS_COMPILER
# - echo $TRAVIS_CPU_ARCH
# - echo $TRAVIS_DEBUG_MODE
# - echo $TRAVIS_DIST
# - echo $TRAVIS_EVENT_TYPE
# - echo $TRAVIS_JOB_ID
# - echo $TRAVIS_JOB_NAME
# - echo $TRAVIS_JOB_NUMBER
# - echo $TRAVIS_JOB_WEB_URL
# - echo $TRAVIS_NODE_VERSION
# - echo $TRAVIS_OS_NAME
# - echo $TRAVIS_PULL_REQUEST
# - echo $TRAVIS_PULL_REQUEST_BRANCH
# - pwd
# NB: Have to have something here, otherwise Travis tries to run "npm test"
# Display the output from hugo and htmltest so it is not folded and hidden, and is at the end of the log.
- echo "$(<$TRAVIS_BUILD_DIR/hugo.log)"
# before_cache
############## Skipped
# after_success
############### Skipped
# after_failure
############### Skipped
before_deploy:
##############
# - curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip" # arm version
- curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" # amd version
- unzip -q awscliv2.zip
- sudo ./aws/install # install AWS command line
- aws --version
- chmod +x $TRAVIS_BUILD_DIR/_scripts/deploy.sh
- python --version
- pip install --upgrade 'algoliasearch>=2.0,<3.0' # install Algolia Python API Client version 2
deploy:
#######
#
# Need to decide where to deploy to, so need to do the actual deployment in a script https://docs.travis-ci.com/user/job-lifecycle#complex-build-commands
# - aws s3 sync . s3://$TARGETAWSBUCKET --delete --only-show-errors
provider: script
# ⋮
edge: true
script: $TRAVIS_BUILD_DIR/_scripts/deploy.sh
on:
branch:
- production
- development
after_deploy:
############# Skipped
# Cannot get python push to Travis to work here. Added it to deploy.sh.
after_script:
############# Skipped
# Anything placed here gets folded by Travis, so can't output useful information :-(.