forked from rancher-sandbox/rancher-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.cirrus.yml
80 lines (75 loc) · 4.04 KB
/
.cirrus.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
task:
name: E2E/Integration Tests
timeout_in: 45
container:
image: ubuntu:20.04
kvm: true # required for E2E/Integrations tests
cpu: 8
memory: 16G
env:
DEBIAN_FRONTEND: noninteractive
CI: true
CIRRUS_CLONE_DEPTH: 0 # Required to get app version
FORCE_COLOR: 1 # force terminal color
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 # disable auto-browser download
KEYRING: /usr/share/keyrings/nodesource.gpg
NODE_VERSION: node_16.x # set node version e.g: "node_17.x" for Node 17 LTS
SUDO_NON_ROOT_CMD: >-
sudo --login --user=ranchertest /usr/bin/env --chdir=/home/ranchertest/src
CI=${CI} CIRRUS_CI=${CIRRUS_CI} CONTINUOUS_INTEGRATION=${CONTINUOUS_INTEGRATION}
CIRRUS_BASE_BRANCH=${CIRRUS_BASE_BRANCH} CIRRUS_BASE_SHA=${CIRRUS_BASE_SHA}
CIRRUS_BRANCH=${CIRRUS_BRANCH} CIRRUS_PR=${CIRRUS_PR} CIRRUS_TAG=${CIRRUS_TAG}
CIRRUS_REPO_NAME=${CIRRUS_REPO_NAME} CIRRUS_REPO_OWNER=${CIRRUS_REPO_OWNER}
CIRRUS_REPO_FULL_NAME=${CIRRUS_REPO_FULL_NAME}
# Setting up a non-root user
prepare_user_script:
- groupadd --gid $(stat -c '%g' /dev/kvm) kvm
- useradd --create-home --groups kvm ranchertest
- mkdir /home/ranchertest/src
- tar c --owner=ranchertest . | tar x --directory=/home/ranchertest/src
- chown -R ranchertest:ranchertest /home/ranchertest
install_deps_script: |
apt-get update
apt-get install --yes --no-install-recommends ca-certificates gcc g++ curl git openssh-client make netcat sudo vim gpg lsb-core \
libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
install_golang_script: |
curl -L https://go.dev/dl/go1.18rc1.linux-amd64.tar.gz | tar xz -C /usr/local --strip-components=1
# The process to install Node w/o sudo|bash requires a validation:
# Step.1 - Check if node package is available on nodesource, if not it will fail
# Step.2 - Add node key and update source list
# Step.3 - Update source and install node+npm
install_node_script: |
export DISTRO="$(lsb_release --short --codename)"
curl --silent --location --fail --output /dev/null "https://deb.nodesource.com/${NODE_VERSION}/dists/${DISTRO}/Release"
curl --silent https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor > "$KEYRING"
echo "deb [signed-by=${KEYRING}] https://deb.nodesource.com/${NODE_VERSION} ${DISTRO} main" > /etc/apt/sources.list.d/nodesource.list
echo "deb-src [signed-by=${KEYRING}] https://deb.nodesource.com/${NODE_VERSION} ${DISTRO} main" >> /etc/apt/sources.list.d/nodesource.list
apt-get update
apt-get install --yes nodejs
node --version && npm --version
# Info about Cirrus CI caching see: https://cirrus-ci.org/guide/writing-tasks/#cache-instruction
node_modules_cache:
folder: /home/ranchertest/src/node_modules
fingerprint_script: cat package-lock.json
populate_script:
# Passing DEBUG=pw:install in order to verify if all Playwright deps were installed properly
- ${SUDO_NON_ROOT_CMD} DEBUG=pw:install npm ci
# `playwright install-deps` needs to be run as root, as it does apt-get things.
- /usr/bin/env --chdir=/home/ranchertest/src ./node_modules/.bin/playwright install-deps
# Ensure the tools were installed properly
post_install_script:
# CirrusCI caching doesn't seem to maintain the UID; we'll need to reset the ownership to ensure
# we can build files in it.
- chown -R ranchertest:ranchertest /home/ranchertest/src/node_modules
- ${SUDO_NON_ROOT_CMD} npm run postinstall
test_script:
- export KUBECONFIG=/home/ranchertest/.kube/config
- ${SUDO_NON_ROOT_CMD} xvfb-run --auto-servernum -- npm run test:e2e
on_failure:
# custom_script workaround for cirrus bug: https://github.com/cirruslabs/cirrus-ci-agent/issues/197
# Still broken after cirrus fix, addressing a new issue to them. (Jan.06 2022)
custom_script: |
mkdir e2e/reports/
cp -R /home/ranchertest/src/e2e/reports/* /tmp/cirrus-ci-build/e2e/reports/
playwright_artifacts:
path: "/tmp/cirrus-ci-build/e2e/reports/*"