Skip to content

Commit de2cdce

Browse files
Add GUI tests
1 parent 5665b99 commit de2cdce

File tree

7 files changed

+395
-0
lines changed

7 files changed

+395
-0
lines changed

.github/workflows/ci.yml

+10
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ jobs:
7777
- name: Clean up the database
7878
run: docker-compose down --volumes
7979

80+
gui_tests:
81+
runs-on: ubuntu-latest
82+
needs: build
83+
84+
steps:
85+
- uses: actions/checkout@master
86+
87+
- name: Run GUI tests
88+
run: ./dockerfiles/run-gui-tests.sh
89+
8090
build_tests:
8191
runs-on: ubuntu-latest
8292
needs: build

docker-compose.yml

+8
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ services:
8989
timeout: 5s
9090
retries: 10
9191

92+
gui_tests:
93+
build:
94+
context: .
95+
dockerfile: ./dockerfiles/Dockerfile-gui-tests
96+
network_mode: "host"
97+
volumes:
98+
- "${PWD}:/build/out"
99+
92100
volumes:
93101
postgres-data: {}
94102
minio-data: {}

dockerfiles/Dockerfile-gui-tests

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
FROM ubuntu:16.04 as build
2+
SHELL ["/bin/bash", "-c"]
3+
4+
RUN apt-get update && apt-get install -y \
5+
ca-certificates \
6+
curl \
7+
docker.io \
8+
gcc \
9+
git \
10+
libssl-dev \
11+
pkg-config \
12+
xz-utils
13+
14+
# Install dependencies for chromium browser
15+
RUN apt-get install -y \
16+
gconf-service \
17+
libasound2 \
18+
libatk1.0-0 \
19+
libatk-bridge2.0-0 \
20+
libc6 \
21+
libcairo2 \
22+
libcups2 \
23+
libdbus-1-3 \
24+
libexpat1 \
25+
libfontconfig1 \
26+
libgbm-dev \
27+
libgcc1 \
28+
libgconf-2-4 \
29+
libgdk-pixbuf2.0-0 \
30+
libglib2.0-0 \
31+
libgtk-3-0 \
32+
libnspr4 \
33+
libpango-1.0-0 \
34+
libpangocairo-1.0-0 \
35+
libstdc++6 \
36+
libx11-6 \
37+
libx11-xcb1 \
38+
libxcb1 \
39+
libxcomposite1 \
40+
libxcursor1 \
41+
libxdamage1 \
42+
libxext6 \
43+
libxfixes3 \
44+
libxi6 \
45+
libxrandr2 \
46+
libxrender1 \
47+
libxss1 \
48+
libxtst6 \
49+
fonts-liberation \
50+
libappindicator1 \
51+
libnss3 \
52+
lsb-release \
53+
xdg-utils \
54+
wget
55+
56+
# Install rust
57+
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain nightly --no-modify-path --profile minimal
58+
ENV PATH="/root/.cargo/bin:${PATH}"
59+
60+
RUN curl -sL https://nodejs.org/dist/v14.4.0/node-v14.4.0-linux-x64.tar.xz | tar -xJ
61+
ENV PATH="/node-v14.4.0-linux-x64/bin:${PATH}"
62+
ENV NODE_PATH="/node-v14.4.0-linux-x64/lib/node_modules/"
63+
64+
WORKDIR /build
65+
66+
RUN mkdir out
67+
68+
# For now, we need to use `--unsafe-perm=true` to go around an issue when npm tries
69+
# to create a new folder. For reference:
70+
# https://github.com/puppeteer/puppeteer/issues/375
71+
#
72+
# We also specify the version in case we need to update it to go around cache limitations.
73+
RUN npm install -g [email protected] --unsafe-perm=true
74+
75+
EXPOSE 3000
76+
77+
CMD ["node", "/build/out/gui-tests/tester.js"]

dockerfiles/run-gui-tests.sh

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
# Just in case it's running, we stop the web server.
4+
docker-compose stop web
5+
6+
docker-compose up -d db s3
7+
8+
# We add the information we need.
9+
cargo run -- database migrate
10+
cargo run -- build crate sysinfo 0.23.4
11+
cargo run -- build crate sysinfo 0.23.5
12+
cargo run -- build add-essential-files
13+
14+
# In case we don't have a `.env`, we create one.
15+
if [ ! -f .env ]
16+
then
17+
cp .env.sample .env
18+
source .env
19+
fi
20+
21+
cargo run -- start-web-server &
22+
SERVER_PID=$!
23+
24+
docker build . -f dockerfiles/Dockerfile-gui-tests -t gui_tests
25+
26+
echo "Sleeping a bit to be sure the web server will be started..."
27+
sleep 5
28+
29+
# status="docker run . -v `pwd`:/build/out:ro gui_tests"
30+
docker-compose run gui_tests
31+
status=$?
32+
kill -9 $SERVER_PID
33+
exit $status

gui-tests/404.goml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Checks the content of the 404 page.
2+
goto: |DOC_PATH|/non-existing-crate
3+
assert-text: ("#crate-title", "The requested crate does not exist")

gui-tests/basic.goml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Checks that the "latest" URL leads us to the last version of the `sysinfo` crate.
2+
goto: |DOC_PATH|/sysinfo
3+
// We first check if the redirection worked as expected:
4+
assert-document-property: ({"URL": "/sysinfo/latest/sysinfo/"}, ENDS_WITH)
5+
assert: "//*[@class='title' and text()='sysinfo-0.23.5']"
6+
// And we also confirm we're on a rustdoc page.
7+
assert: "#rustdoc_body_wrapper"
8+
9+
// Let's go to the docs.rs page of the crate.
10+
goto: |DOC_PATH|/crate/sysinfo/latest
11+
assert-false: "#rustdoc_body_wrapper"
12+
assert-text: ("#crate-title", "sysinfo 0.23.5", CONTAINS)

0 commit comments

Comments
 (0)