Skip to content

Commit 1ba7ddf

Browse files
authored
Add end-to-end tests for Ubuntu 12.04, 14.04 and 16.04 using Docker (yarnpkg#1391)
1 parent d225ba4 commit 1ba7ddf

7 files changed

+73
-0
lines changed

end_to_end_tests/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This directory contains end-to-end tests for Yarn. The tests perform the following steps:
2+
3+
1. Spin up a fresh Docker container
4+
2. Install Yarn through the package repository
5+
3. Run `yarn add react` in a test directory

end_to_end_tests/data/run-ubuntu.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
# Executed within a fresh Docker container to test installation and execution of Yarn.
3+
set -ex
4+
5+
. /etc/lsb-release
6+
7+
# Set proxy if one was passed in (eg. if caching on the host machine using apt-cacher-ng)
8+
if [ -n "$APT_PROXY" ]; then
9+
echo 'Acquire::http::proxy "http://'$APT_PROXY'";' > /etc/apt/apt.conf.d/02proxy
10+
fi;
11+
12+
# Add Yarn repo
13+
apt-key adv --keyserver pgp.mit.edu --recv D101F7899D41F3C3
14+
# TODO: Use nightly repo once it's configured
15+
echo "deb http://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list
16+
apt-get update -y
17+
18+
if [ "$DISTRIB_RELEASE" == '12.04' -o "$DISTRIB_RELEASE" == '14.04' ]; then
19+
# This is an old Ubuntu version; we need to add the NodeSource repo too
20+
apt-get install curl -y
21+
curl -sL https://deb.nodesource.com/setup_6.x | bash -
22+
fi;
23+
24+
# TODO: Remove ca-certificates from this list once https://github.com/yarnpkg/yarn/issues/1390 is fixed
25+
apt-get install yarn ca-certificates -y
26+
27+
./run-yarn-test.sh
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
# Executed within a fresh Docker container to test execution of Yarn.
3+
# Should be executed after Yarn has been installed.
4+
set -ex
5+
6+
fail_with_log() {
7+
# Include the yarn-error.log file in the output, if available
8+
exitcode=$?
9+
if [ -s yarn-error.log ]; then
10+
cat yarn-error.log
11+
fi;
12+
exit $exitcode
13+
}
14+
15+
cd /tmp
16+
mkdir yarntest
17+
cd yarntest
18+
yarn add react || fail_with_log

end_to_end_tests/data/start-ubuntu.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
# Starts an Ubuntu Docker container and runs the Yarn end-to-end test on it
3+
set -ex
4+
5+
if [ -z "$1" ]; then
6+
echo 'Ubuntu distribution was not specified'
7+
exit 1
8+
fi;
9+
10+
data_path=$(dirname $(readlink -f "$0"))
11+
docker run -v $data_path:/data -w=/data -e APT_PROXY=$APT_PROXY $1 /data/run-ubuntu.sh

end_to_end_tests/test-ubuntu-12.04.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
# Starts an Ubuntu 12.04 Docker container and runs the Yarn end-to-end test on it
3+
set -ex
4+
./data/start-ubuntu.sh ubuntu:12.04

end_to_end_tests/test-ubuntu-14.04.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
# Starts an Ubuntu 14.04 Docker container and runs the Yarn end-to-end test on it
3+
set -ex
4+
./data/start-ubuntu.sh ubuntu:14.04

end_to_end_tests/test-ubuntu-16.04.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
# Starts an Ubuntu 16.04 Docker container and runs the Yarn end-to-end test on it
3+
set -ex
4+
./data/start-ubuntu.sh ubuntu:16.04

0 commit comments

Comments
 (0)