Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1494 from apiaryio/honzajavorek/circleci
Browse files Browse the repository at this point in the history
Switch Dredd to CircleCI
  • Loading branch information
honzajavorek authored Sep 16, 2019
2 parents d5eee29 + 9f6a074 commit 0524546
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 88 deletions.
133 changes: 133 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
version: 2.1


commands:
npm-install:
steps:
- run: echo $(node --version) > .node-version
- restore_cache:
key: js-deps-{{ checksum ".node-version" }}-{{ checksum "package.json" }}
- run: npm install --no-save
- save_cache:
key: js-deps-{{ checksum "package.json" }}
paths:
- ./node_modules

pip-install-docs:
steps:
- run: echo $(python --version) > .python-version
- restore_cache:
key: py-deps-{{ checksum ".python-version" }}-{{ checksum "docs/requirements.txt" }}
- run: "if [ ! -d ./venv ]; then python -m venv ./venv; fi"
- run: echo "source $(pwd)/venv/bin/activate" >> $BASH_ENV
- run: pip install -r ./docs/requirements.txt
- save_cache:
key: py-deps-{{ checksum "docs/requirements.txt" }}
paths:
- ./venv


aliases:
- &node12
image: circleci/node:12

- &python-docs
# using Python 3.6 as that's the version ReadTheDocs is running
image: circleci/python:3.6-node

- &test-steps
steps:
- checkout
- npm-install
- run: npm run ci:test


jobs:
test-node12:
docker: [<<: *node12]
<<: *test-steps

test-node10:
docker: [image: circleci/node:10]
<<: *test-steps

test-node8:
docker: [image: circleci/node:8]
<<: *test-steps

test-e2e-apib:
docker: [<<: *node12]
steps:
- checkout
- npm-install
- run: npm run e2e:apib

test-e2e-openapi2:
docker: [<<: *node12]
steps:
- checkout
- npm-install
- run: npm run e2e:openapi2

quality-checks:
docker: [<<: *python-docs]
steps:
- checkout
- npm-install
- pip-install-docs
- run: npm run ci:lint

docs-dry-run:
# 'dry run', because production build happens directly on the ReadTheDocs
# infrastructure
docker: [<<: *python-docs]
steps:
- checkout
- npm-install
- pip-install-docs
- run: npm run ci:docs

smoke-tests:
docker:
- <<: *node12
- image: circleci/mongo:latest
steps:
- checkout
- npm-install
- run: npm run ci:smoke

release:
# the GH_TOKEN and NPM_TOKEN environment variables are expected to be set
# in https://circleci.com/gh/apiaryio/dredd/edit#env-vars
docker: [<<: *node12]
steps:
- checkout
- npm-install
- run: npm run ci:release


workflows:
version: 2
test-and-release:
jobs:
- quality-checks
- test-node12
- test-node10
- test-node8
- test-e2e-apib
- test-e2e-openapi2
- smoke-tests
- docs-dry-run
- release:
requires:
- quality-checks
- test-node12
- test-node10
- test-node8
- test-e2e-apib
- test-e2e-openapi2
- smoke-tests
- docs-dry-run
filters:
branches:
only: master
68 changes: 0 additions & 68 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Dredd — HTTP API Testing Framework

[![npm version](https://badge.fury.io/js/dredd.svg)](https://www.npmjs.com/package/dredd)
[![Build Status](https://travis-ci.org/apiaryio/dredd.svg?branch=master)](https://travis-ci.org/apiaryio/dredd)
[![Build Status](https://circleci.com/gh/apiaryio/dredd/tree/master.svg?style=svg)](https://circleci.com/gh/apiaryio/dredd/tree/master)
[![Build Status](https://ci.appveyor.com/api/projects/status/n3ixfxh72qushyr4/branch/master?svg=true)](https://ci.appveyor.com/project/Apiary/dredd/branch/master)
[![Documentation Status](https://readthedocs.org/projects/dredd/badge/?version=latest)](https://readthedocs.org/projects/dredd/builds/)
[![Known Vulnerabilities](https://snyk.io/test/npm/dredd/badge.svg)](https://snyk.io/test/npm/dredd)
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ Example Applications

.. |npm version| image:: https://badge.fury.io/js/dredd.svg
:target: https://www.npmjs.com/package/dredd
.. |Build Status| image:: https://travis-ci.org/apiaryio/dredd.svg?branch=master
:target: https://travis-ci.org/apiaryio/dredd
.. |Build Status| image:: https://circleci.com/gh/apiaryio/dredd/tree/master.svg?style=svg
:target: https://circleci.com/gh/apiaryio/dredd/tree/master
.. |Windows Build Status| image:: https://ci.appveyor.com/api/projects/status/n3ixfxh72qushyr4/branch/master?svg=true
:target: https://ci.appveyor.com/project/Apiary/dredd/branch/master
.. |Documentation Status| image:: https://readthedocs.org/projects/dredd/badge/?version=latest
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
"devDependencies": {
"@commitlint/cli": "8.1.0",
"@commitlint/config-conventional": "8.1.0",
"@commitlint/travis-cli": "8.1.0",
"body-parser": "1.19.0",
"coffeescript": "2.4.1",
"commitlint-circle": "1.0.0",
"cucumber": "5.1.0",
"eslint": "5.16.0",
"eslint-config-airbnb-base": "13.2.0",
Expand Down
13 changes: 4 additions & 9 deletions scripts/commitlint.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
#!/bin/bash
# Validates format of the commit messages on Travis CI
# Validates format of the commit messages on CI


set -e # aborts as soon as anything returns non-zero exit status


if [ ! -z "$TRAVIS" ]; then
git remote set-branches origin master
git fetch --unshallow --quiet
git checkout master --quiet
git checkout - --quiet
./node_modules/.bin/commitlint-travis
if [ ! -z "$CIRCLECI" ]; then
npx commitlint-circle
else
./node_modules/.bin/commitlint --from=master
npx commitlint --from=master
fi
2 changes: 1 addition & 1 deletion scripts/smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
set -e


if [ ! -z "$TRAVIS" ]; then
if [ ! -z "$CIRCLECI" ]; then
# Move everything in the current directory to a subdirectory called 'dredd'
#
# First we set glob to make the line with 'mv' to take dotfiles as well.
Expand Down
20 changes: 14 additions & 6 deletions test/integration/proxy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ const SERVER_HOST = `127.0.0.1:${DEFAULT_SERVER_PORT}`;
const DUMMY_URL = 'http://example.com';
const REGULAR_HTTP_METHODS = ['GET', 'POST', 'PUT', 'DELETE'];


function unsetAllProxyEnvVars(env) {
Object.keys(env)
.filter(envName => envName.toLowerCase().includes('proxy'))
.forEach(envName => delete env[envName]);
}

// Normally, tests create Dredd instance and pass it to the 'runDredd'
// helper, which captures Dredd's logging while it runs. However, in
// this case we need to capture logging also during the instantiation.
Expand Down Expand Up @@ -165,8 +172,11 @@ proxy specified by environment variables: \
${protocol}_proxy=${PROXY_URL}\
`;

before(() => { process.env[`${protocol}_proxy`] = PROXY_URL; });
after(() => delete process.env[`${protocol}_proxy`]);
before(() => {
unsetAllProxyEnvVars(process.env);
process.env[`${protocol}_proxy`] = PROXY_URL;
});
after(() => unsetAllProxyEnvVars(process.env));

describe('Requesting Server Under Test', () => test({
protocol,
Expand Down Expand Up @@ -219,13 +229,11 @@ http_proxy=${PROXY_URL}, no_proxy=${SERVER_HOST}\
`;

before(() => {
unsetAllProxyEnvVars(process.env);
process.env.http_proxy = PROXY_URL;
process.env.no_proxy = SERVER_HOST;
});
after(() => {
delete process.env.http_proxy;
delete process.env.no_proxy;
});
after(() => unsetAllProxyEnvVars(process.env));

describe('Requesting Server Under Test', () => test({
protocol: 'http',
Expand Down

0 comments on commit 0524546

Please sign in to comment.