-
Notifications
You must be signed in to change notification settings - Fork 120
Expand file tree
/
Copy path.travis.yml
More file actions
91 lines (70 loc) · 3.21 KB
/
.travis.yml
File metadata and controls
91 lines (70 loc) · 3.21 KB
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
dist: jammy
language: shell
os: linux
env:
global:
- CC_TEST_REPORTER_ID=46ef31dae5b656e0f4be410a86bd83bdcf73e7d27ab33a704c197e6fe4bf02a0
- DOCKER_PLATFORMS=linux/arm64/v8,linux/amd64
- IMAGE_NAME=wud
- NODE_VERSION=24
before_install:
- export IMAGE_VERSION=${TRAVIS_BRANCH//\//\_}
- export IMAGE_VERSION=${IMAGE_VERSION//\#/\_}
- export IMAGE_VERSION_MINOR=$(echo $IMAGE_VERSION | sed -rn 's/^(v?[[:digit:]]+.[[:digit:]]+).([[:digit:]]+)(.*)/\1/p')
- export IMAGE_VERSION_MAJOR=$(echo $IMAGE_VERSION | sed -rn 's/^(v?[[:digit:]]+).[[:digit:]]+.([[:digit:]]+)(.*)/\1/p')
# Install docker with buildx
- sudo install -m 0755 -d /etc/apt/keyrings
- sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
- sudo chmod a+r /etc/apt/keyrings/docker.asc
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- sudo apt-get update
- sudo apt-get install -y docker-buildx-plugin
- docker version
# Install Nodejs
- nvm install $NODE_VERSION
# Init Code Climate
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./app/cc-test-reporter
- (cd app && chmod +x ./cc-test-reporter)
# - (cd app && ./cc-test-reporter before-build)
install:
- (cd app && npm ci)
- (cd e2e && npm ci)
- (cd ui && npm ci)
script:
# Fail at first non zero exit code
- set -e
# Run Linter
- (cd app && npm run lint)
- (cd e2e && npm run lint)
- (cd ui && npm run lint)
# Run UT
- (cd app && npm test)
- (cd ui && npm run test:unit)
# Report to Code Climate
# - (cd app && ./cc-test-reporter after-build -t lcov --debug --exit-code $TRAVIS_TEST_RESULT)
# Package ui
- (cd ui && npm run build)
# Build wud docker image
- docker build -t wud --build-arg WUD_VERSION=$IMAGE_VERSION .
# Setup test containers
- (cd scripts && ./setup-test-containers.sh)
# Start wud
- (cd scripts && ./start-wud.sh)
- docker logs wud
# Run E2E Tests
- (cd e2e && npm run cucumber)
# Override image version with tag name if any
- export DOCKER_TAGS="-t ${DOCKER_USERNAME}/${IMAGE_NAME}:${IMAGE_VERSION} -t ghcr.io/${GITHUB_USERNAME}/${IMAGE_NAME}:${IMAGE_VERSION}"
- |
if [ ! -z "$TRAVIS_TAG" ]
then
export DOCKER_TAGS="${DOCKER_TAGS} -t ${DOCKER_USERNAME}/${IMAGE_NAME}:${IMAGE_VERSION_MAJOR} -t ghcr.io/${GITHUB_USERNAME}/${IMAGE_NAME}:${IMAGE_VERSION_MAJOR}"
export DOCKER_TAGS="${DOCKER_TAGS} -t ${DOCKER_USERNAME}/${IMAGE_NAME}:${IMAGE_VERSION_MINOR} -t ghcr.io/${GITHUB_USERNAME}/${IMAGE_NAME}:${IMAGE_VERSION_MINOR}"
export DOCKER_TAGS="${DOCKER_TAGS} -t ${DOCKER_USERNAME}/${IMAGE_NAME}:latest -t ghcr.io/${GITHUB_USERNAME}/${IMAGE_NAME}:latest"
fi
# Build & push image
- docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
- docker login ghcr.io -u "$GITHUB_USERNAME" -p "$GITHUB_TOKEN"
- docker buildx create --use
- echo "Building & pushing ${DOCKER_TAGS}"
- docker buildx build --push --platform ${DOCKER_PLATFORMS} --build-arg WUD_VERSION=${IMAGE_VERSION} ${DOCKER_TAGS} .