Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 164 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
language: node_js
node_js:
- 24.15 # 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.

# add group: previous to see if this fixes the stalled npm build - 2025-04-14
# remove again 2025-05-08 as builds started breaking again.
# group: previous

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:
# Cache node_modules to avoid re-downloading on every build
# See https://docs.travis-ci.com/user/caching/
directories:
- node_modules

before_install:
###############
# Hugo, Docsy and dependencies are installed via npm
- travis_retry 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
# Output header in bold white on green
- printf '\033[37;42;1m' > $TRAVIS_BUILD_DIR/hugo.log
- echo "HUGO was run for environment $TRAVIS_BRANCH" >> $TRAVIS_BUILD_DIR/hugo.log
- printf '\033[0;22m' >> $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)

# bash -o pipefail ensures Hugo's non-zero exit code is not masked by tee inside the subprocess
- travis_wait 15 bash -o pipefail -c './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
# Additional info in bold white on green
- printf '\033[37;42;1m' >> $TRAVIS_BUILD_DIR/hugo.log
- echo "Any errors from HTMLTEST will be treated as warnings - the build will continue." >> $TRAVIS_BUILD_DIR/hugo.log
- printf '\033[0;22m' >> $TRAVIS_BUILD_DIR/hugo.log
- chmod +x ./htmltest/htmltest
# Run htmltest - convert red (91) and green (92) aixterm colors with 8-bit versions (31 and 32).

- ./htmltest/htmltest 2>&1 | sed "s/\o033\[91/\o033\[31/g; s/\o033\[92/\o033\[32/g" |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.
- printf '\n\n%s\n\n' "$(<$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 :-(.