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

Commit

Permalink
chore: configures CI to work with a monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-zakharchenko committed Oct 3, 2019
1 parent 94dae5a commit 9a04883
Show file tree
Hide file tree
Showing 40 changed files with 52 additions and 48 deletions.
56 changes: 24 additions & 32 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
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" }}
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" }}
key: py-deps-{{ checksum "./docs/requirements.txt" }}
paths:
- ./venv

aliases:
- &install
- run: sudo npm i -g yarn && yarn install --frozen-lockfile

- &node12
image: circleci/node:12

Expand All @@ -35,9 +27,9 @@ aliases:
- &test-steps
steps:
- checkout
- npm-install
- run: npm run build
- run: npm run ci:test
- <<: *install
- run: yarn build
- run: yarn ci:test

jobs:
test-node12:
Expand All @@ -56,60 +48,60 @@ jobs:
docker: [<<: *node12]
steps:
- checkout
- npm-install
- run: npm run build
- run: npm run e2e:apib
- <<: *install
- run: yarn build
- run: yarn e2e:apib

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

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

format-check:
docker: [<<: *node12]
steps:
- checkout
- npm-install
- run: npm run prettify:check
- <<: *install
- run: yarn prettify:check

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

smoke-tests:
docker:
- <<: *node12
- image: circleci/mongo:latest
steps:
- checkout
- npm-install
- run: npm run ci:smoke
- <<: *install
- run: yarn 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
- <<: *install
- run: yarn ci:release

workflows:
version: 2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cov.*
*.log
.env*
__pycache__
/docs/_build

# Regardless the rules above, never ignore following
!.vscode/launch.json
12 changes: 7 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ environment:
install:
- ps: Install-Product node 12
- 'npm -g install npm@6'
- 'npm install -g yarn'
- "set PATH=%APPDATA%\\npm;%PATH%"
- 'npm install'
- 'yarn install'
cache:
- 'node_modules -> package.json'
- "%APPDATA%\\npm-cache -> package.json"
- 'node_modules -> yarn.lock'
- "%APPDATA%\\npm-cache -> yarn.lock"
build: off
test_script:
- 'node --version'
- 'npm --version'
- 'npm run build'
- 'npm test'
- 'yarn --version'
- 'yarn build'
- 'yarn test'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions packages/dredd/docs/hooks/index.rst → docs/hooks/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ Let's have a description of a blog API, which allows to list all articles, and t

.. group-tab:: API Blueprint

.. literalinclude:: ../../test/fixtures/blog/apidesc.apib
.. literalinclude:: ../../packages/dredd/test/fixtures/blog/apidesc.apib
:language: apiblueprint

.. group-tab:: OpenAPI 2

.. literalinclude:: ../../test/fixtures/blog/apidesc.openapi2.yaml
.. literalinclude:: ../../packages/dredd/test/fixtures/blog/apidesc.openapi2.yaml
:language: openapi2

Now let's say the real instance of the API has the POST request protected so it is not possible for everyone to publish new articles. We do not want to hardcode secret tokens in our API description, but we want to get Dredd to pass the auth. This is where the hooks can help.
Expand All @@ -52,7 +52,7 @@ Dredd supports :ref:`writing hooks in multiple programming languages <supported-

Let's create a file called ``hooks.js`` with the following content:

.. literalinclude:: ../../test/fixtures/blog/hooks.apib.js
.. literalinclude:: ../../packages/dredd/fixtures/blog/hooks.apib.js
:language: javascript

As you can see, we're registering the hook function to be executed **before** the HTTP transaction ``Articles > Publish an article``. This path-like identifier is a :ref:`transaction name <transaction-names>`.
Expand All @@ -61,7 +61,7 @@ Dredd supports :ref:`writing hooks in multiple programming languages <supported-

Let's create a file called ``hooks.js`` with the following content:

.. literalinclude:: ../../test/fixtures/blog/hooks.openapi2.js
.. literalinclude:: ../../packages/dredd/test/fixtures/blog/hooks.openapi2.js
:language: javascript

As you can see, we're registering the hook function to be executed **before** the HTTP transaction ``Articles > Publish an article > 201 > application/json``. This path-like identifier is a :ref:`transaction name <transaction-names>`.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
{
"private": true,
"scripts": {
"build": "lerna exec --scope='dredd' yarn build",
"prettify:check": "lerna exec --scope='dredd' yarn prettify:check",
"docs:lint": "sphinx-build -nW -b linkcheck ./docs ./docs/_build",
"docs:test-extensions": "python -m unittest docs/_extensions/*.py --verbose",
"docs:build": "sphinx-build -nW -b html ./docs ./docs/_build",
"docs:serve": "sphinx-autobuild ./docs ./docs/_build",
"e2e:apib": "lerna exec --scope='dredd' yarn e2e:apib",
"e2e:openapi2": "lerna exec --scope='dredd' yarn e2e:openapi2",
"ci:release": "lerna exec --scope='dredd' yarn ci:release",
"ci:docs": "yarn docs:build",
"ci:lint": "lerna exec --scope='dredd' yarn ci:lint && yarn docs:lint && yarn docs:test-extensions",
"ci:smoke": "lerna exec --scope='dredd' yarn ci:smoke",
"ci:test": "lerna exec --scope='dredd' yarn ci:test"
},
"devDependencies": {
"lerna": "^3.16.4"
},
Expand Down
1 change: 0 additions & 1 deletion packages/dredd/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/build
/coverage
/docs/_build
7 changes: 1 addition & 6 deletions packages/dredd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
"scripts": {
"start": "npm run build -- --watch",
"build": "tsc --build tsconfig.json",
"docs:lint": "sphinx-build -nW -b linkcheck ./docs ./docs/_build",
"docs:test-extensions": "python -m unittest docs/_extensions/*.py --verbose",
"docs:build": "sphinx-build -nW -b html ./docs ./docs/_build",
"docs:serve": "sphinx-autobuild ./docs ./docs/_build",
"lint": "./scripts/commitlint.sh && eslint . bin/dredd",
"prettify": "prettier --write lib/**/*.js test/**/*.js",
"prettify:check": "prettier --check lib/**/*.js test/**/*.js",
Expand All @@ -24,8 +20,7 @@
"e2e": "npm run e2e:apib && npm run e2e:openapi2",
"e2e:apib": "cucumber-js",
"e2e:openapi2": "cucumber-js --world-parameters=\"{\\\"apiDescriptionFormat\\\": \\\"application/swagger+yaml\\\"}\"",
"ci:lint": "npm run lint && npm run docs:lint && npm run docs:test-extensions",
"ci:docs": "npm run docs:build",
"ci:lint": "npm run lint",
"ci:test": "npm test",
"ci:smoke": "bash ./scripts/smoke.sh",
"ci:release": "semantic-release && npm dist-tag add \"dredd@$(npm view dredd version)\" stable",
Expand Down

0 comments on commit 9a04883

Please sign in to comment.