Skip to content

Commit

Permalink
Switch from TravisCI to Taskcluster
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhitlock committed Feb 2, 2022
1 parent 4e19ee9 commit 38e2eaf
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 56 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*log
.env
.git
.taskcluster.yml
Dockerfile
node_modules
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ node_modules
*docker-exec-client.js
test/browserifytest.js
test/testserver.js
Dockerfile
docker-compose.yml
98 changes: 60 additions & 38 deletions .taskcluster.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,61 @@
version: 0
metadata:
name: docker-exec-websocket-server
description: 'Helpers for testing taskcluster'
owner: '{{ event.head.user.email }}'
source: '{{ event.head.repo.url }}'
version: 1
policy:
pullRequests: public
tasks:
- provisionerId: '{{ taskcluster.docker.provisionerId }}'
workerType: '{{ taskcluster.docker.workerType }}'
extra:
github:
events:
- push
branches:
- master
scopes:
- auth:aws-s3:read-write:taskcluster-raw-docs/docker-exec-websocket-server/
payload:
maxRunTime: 3600
image: taskcluster/upload-project-docs:latest
features:
taskclusterProxy:
true
command:
- /bin/bash
- '--login'
- '-cx'
- >-
git clone {{event.head.repo.url}} repo &&
cd repo &&
git config advice.detachedHead false &&
git checkout {{event.head.sha}} &&
export DOCS_PROJECT=docker-exec-websocket-server DOCS_TIER=libraries DOCS_FOLDER=docs DOCS_README=README.md &&
upload-project-docs
metadata:
name: "docker-exec-websocket-server docs upload"
description: "Upload documentation for this project"
owner: '{{ event.head.user.email }}'
source: '{{ event.head.repo.url }}'
$let:
proj_name: "docker-exec-websocket-client"
head_rev:
$if: tasks_for == "github-pull-request"
then: ${event.pull_request.head.sha}
else: ${event.after}
repository:
$if: tasks_for == "github-pull-request"
then: ${event.pull_request.head.repo.html_url}
else: ${event.repository.html_url}
environments:
- node_image_tag: 16-bullseye
description: Run tests with node v16
- node_image_tag: 14-bullseye
description: Run tests with node v14
- node_image_tag: 12-bullseye
description: Run tests with node v12
- node_image_tag: "10"
description: Run tests with node v10
- node_image_tag: "8"
description: Run tests with node v8
- node_image_tag: current-bullseye
description: Run tests with current node version
in:
$if: tasks_for == "github-pull-request" && event["action"] in ["opened","reopened","synchronize"]
then:
$map: {$eval: environments}
each(env):
taskId: {$eval: as_slugid(proj_name + ":node:" + env.node_image_tag + ":tests")}
deadline:
$fromNow: 1 day
taskQueueId: proj-taskcluster/gw-ci-ubuntu-18-04
metadata:
name: node:${env.node_image_tag} tests
description: ${env.description}
owner: ${event.sender.login}@users.noreply.github.com
source: ${event.repository.url}
payload:
maxRunTime: 3600
env:
BUILDKIT_PROGRESS: plain # auto / tty is over-verbose
REPO_DIR: {$eval: as_slugid(proj_name + ":node:" + env.node_image_tag + ":tests")}
command:
-
- /bin/bash
- -vxec
- >
git --version &&
git clone --no-progress "${repository}" "$REPO_DIR" &&
chmod a+wrx "$REPO_DIR" &&
cd "$REPO_DIR" &&
git config advice.detachedHead "false" &&
git checkout --no-progress "${head_rev}" &&
curl -sL "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose &&
chmod +x /usr/local/bin/docker-compose &&
/usr/local/bin/docker-compose build --build-arg "NODE_VERSION=${env.node_image_tag}" &&
/usr/local/bin/docker-compose run test
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ARG NODE_VERSION=14-bullseye
FROM node:${NODE_VERSION}

RUN node -v
RUN npm -v
USER root
RUN mkdir /var/run/app
COPY . /var/run/app/
WORKDIR /var/run/app
RUN yarn install
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,16 @@ There are also other client events:

## Testing

Docker 1.6.1 or above must be installed with a container named `servertest` running with `cat` and `/bin/bash` capabilities to inject the exec process into. From there, `npm test` will carry out the test.
Ensure Docker is installed.

To test locally:

* Run ``yarn install`` to install the dependencies, including developer dependencies
* Run ``yarn test``

To test with ``docker-compose``:

* Run ``docker-compose build --build-arg NODE_VERSION=16-bullseye``, or change to the desired
[Node.js image tag](https://hub.docker.com/_/node/)
* Run ``docker-compose run test``
* Repeat ``docker-compose build ...`` when the code changes or you want to try a different Node.js image.
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "2"

services:
testserver:
image: ubuntu
command: "sleep 60"
test:
build:
context: .
dockerfile: Dockerfile
image: local/docker-exec-websocket-server
depends_on:
- testserver
volumes:
- ./:/home/node/app
- /var/run/docker.sock:/var/run/docker.sock
command: /var/run/app/node_modules/.bin/mocha --exit /var/run/app/test/test.js

0 comments on commit 38e2eaf

Please sign in to comment.