Skip to content

Commit

Permalink
Testing Circle CI config (#18)
Browse files Browse the repository at this point in the history
* Testing Circle CI config

* Separate network tests

* Remove image definitions

* Remove unnecessary parallelization

* Remove old script

* Add local docker steps
  • Loading branch information
liberty-rowland authored Aug 9, 2021
1 parent f5e89f2 commit 81c586e
Show file tree
Hide file tree
Showing 16 changed files with 384 additions and 104 deletions.
147 changes: 137 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,113 @@
version: 2.1
parameters:
browser:
type: enum
enum: ["chrome", "firefox"]
default: "chrome"
bver:
type: enum
enum: ["stable", "beta", "unstable"]
default: "stable"
pr_workflow:
type: boolean
default: true # by default pr workflow will get executed.
tag:
type: string
default: "" # use something like: "2.0.0-beta15" when invoking with parameters.
executors:
machine-executor:
machine: true
generic-executor:
docker:
- image: alpine:3.7
docker-with-browser:
parameters:
browser:
type: enum
enum: ["chrome", "firefox"]
default: "chrome"
bver:
type: enum
enum: ["stable", "beta", "unstable"]
default: "stable"
docker:
- image: twilio/twilio-video-browsers:<<parameters.browser>>-<<parameters.bver>>
commands:
get-code:
steps:
- checkout
- when:
condition: << pipeline.parameters.tag >>
steps:
- run: git checkout << pipeline.parameters.tag >>
set-node-version:
steps:
- run:
name: Set node to version 12
command: |
sudo npm install -g n
sudo n 12
get-code-and-dependencies:
steps:
- get-code
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Installing dependencies
command: node -v && npm install --legacy-peer-deps
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
unit-tests:
steps:
- set-node-version
- get-code-and-dependencies
- run:
name: Running unit tests
command: node -v && npm run build && npm run test:unit
network-tests:
steps:
- get-code-and-dependencies
- run:
name: Running integration tests
command: npm run test:docker
integration-tests:
steps:
- get-code-and-dependencies
- run:
name: Running integration tests
command: npm run build && npm run test:integration

jobs:
UnitTests:
executor: docker-with-browser
steps:
- unit-tests
run-network-tests:
parameters:
bver:
type: string
browser:
type: string
executor:
name: machine-executor
environment:
BROWSER: << parameters.browser >>
BVER: << parameters.bver >>
steps: [network-tests]
run-integration-tests:
parameters:
bver:
type: string
browser:
type: string
executor:
name: docker-with-browser
environment:
BROWSER: << parameters.browser >>
BVER: << parameters.bver >>
steps: [integration-tests]
trigger-qe-tests:
docker:
- image: circleci/node:latest
Expand All @@ -13,15 +120,35 @@ jobs:
-d '{"branch":"'v${CIRCLE_TAG:0:1}'","parameters":{"sdk_version":"'$CIRCLE_TAG'","is_rc":true}}' \
$SDKS_QE_CIRCLECI_VOICE_JS_SLAVE_PIPELINE_ENDPOINT
workflows:
Pull_Request_Workflow:
when: << pipeline.parameters.pr_workflow >>
jobs:
- UnitTests:
context: dockerhub-pulls
name: Unit Tests
- run-integration-tests:
context: dockerhub-pulls
name: Integration Tests <<matrix.browser>> <<matrix.bver>>
matrix:
parameters:
browser: ["chrome", "firefox"]
bver: ["beta", "unstable", "stable"]
- run-network-tests:
context: dockerhub-pulls
name: Network Tests <<matrix.browser>> <<matrix.bver>>
matrix:
parameters:
browser: ["chrome", "firefox"]
bver: ["stable"]
release-candidate:
jobs:
- trigger-qe-tests:
context: sdks-qe
filters:
tags:
only:
- /^\d+\.\d+\.\d+-rc\d+$/
- /^\d+\.\d+\.\d+-preview\d+-rc\d+$/
- /^\d+\.\d+\.\d+-beta\d+-rc\d+$/
branches:
ignore: /.*/
- trigger-qe-tests:
context: sdks-qe
filters:
tags:
only:
- /^\d+\.\d+\.\d+-rc\d+$/
- /^\d+\.\d+\.\d+-preview\d+-rc\d+$/
- /^\d+\.\d+\.\d+-beta\d+-rc\d+$/
branches:
ignore: /.*/
39 changes: 39 additions & 0 deletions .circleci/images/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: '3'
# Note: This file is used to build run the integration tests.
# for running integration tests
# BROWSER=chrome BVER=stable docker-compose --file=./docker-compose.yml run integrationTests
# to build container with browsers that will be used by integrationTests:
# BROWSER=chrome BVER=stable docker-compose --file=./docker-compose.yml build browserContainer
# to run bash for debugging the container:
# BROWSER=chrome BVER=stable docker-compose --file=./docker-compose.yml run bash
services:
defaults: &defaults
user: root
image: twilio/twilio-video-browsers:${BROWSER}-${BVER}
working_dir: /opt/app
cap_add:
- NET_ADMIN
- NET_RAW
runtimeDefaults: &runtimeDefaults
<<: *defaults
environment:
- ENVIRONMENT
- ACCOUNT_SID
- API_KEY_SID
- API_KEY_SECRET
- APPLICATION_SID
- APPLICATION_SID_STIR
- CALLER_ID
volumes:
- "../../:/opt/app"
- /var/run/docker.sock:/var/run/docker.sock
- /opt/app/node_modules
integrationTests: # runs integration tets. Expects that sources are mounted.
<<: *runtimeDefaults
command: bash -c "npm install -g n && n 12 && npm install --no-optional --no-legacy-peer-deps && npm run build && ls -la /root && ls -la /root/.npm && npm run test:network"
bash: # runs bash shell inside container. helpful for debugging
<<: *runtimeDefaults
command: bash
getVersion: # print browser version installed in the container.
<<: *runtimeDefaults
command: /opt/app/.circleci/images/printbrowserversion.sh
7 changes: 7 additions & 0 deletions .circleci/images/printbrowserversion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
if [ "${BROWSER}" == "firefox" ];
then
echo $(firefox --version)
else
echo $(google-chrome --version)
fi
49 changes: 7 additions & 42 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,13 @@
FROM node:8.16.0
ARG IMAGE=twilio/twilio-video-browsers:chrome-stable
FROM $IMAGE

RUN apt-get update \
&& apt-get install -y \
libasound2 \
libpango1.0-0 \
libxt6 \
wget \
bzip2 \
sudo \
libdbus-glib-1-2 \
libgtk-3-0 \
iptables \
net-tools \
&& adduser user1 && adduser user1 sudo && su - user1
RUN sudo apt-get update
RUN sudo apt-get install -y libasound2 libpango1.0-0 libxt6 wget bzip2 sudo libdbus-glib-1-2 libgtk-3-0 iptables net-tools
RUN sudo groupadd docker
RUN sudo usermod -aG docker user1
RUN sudo su user1

WORKDIR /app

ARG BVER='stable'

RUN echo "Installing Chrome: $BVER" \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list \
&& apt-get update \
&& echo "Installing google-chrome-$BVER from apt-get" \
&& apt-get install -y google-chrome-$BVER \
&& rm -rf /var/lib/apt/lists/*

RUN echo "Installing Firefox: $BVER" \
&& if [ $BVER = "beta" ] \
;then \
FIREFOX_DOWNLOAD_URL="https://download.mozilla.org/?product=firefox-beta-latest-ssl&os=linux64&lang=en-US" \
;elif [ $BVER = "unstable" ] \
;then \
FIREFOX_DOWNLOAD_URL="https://download.mozilla.org/?product=firefox-nightly-latest-ssl&os=linux64&lang=en-US" \
;else \
FIREFOX_DOWNLOAD_URL="https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64&lang=en-US" \
;fi \
&& echo "Firefox Download URL: $FIREFOX_DOWNLOAD_URL" \
&& mkdir /application \
&& cd /application \
&& wget -O - $FIREFOX_DOWNLOAD_URL | tar jx

ENV FIREFOX_BIN=/application/firefox/firefox

COPY . /app

CMD ["bash"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ npm run test:integration

These tests will run via karma, one at a time, in your system's default Chrome and then Firefox.

Network tests have been split out into their own docker processes, and can be run via

```
npm run test:docker
```

Content Security Policy (CSP)
----------------------------

Expand Down
25 changes: 0 additions & 25 deletions docker-compose.yml

This file was deleted.

Loading

0 comments on commit 81c586e

Please sign in to comment.