From a24bf5e6f534553d546f18b52d54f18bd0834c57 Mon Sep 17 00:00:00 2001 From: "javier.brea" Date: Mon, 21 Dec 2020 10:19:39 +0100 Subject: [PATCH 1/7] chore(ci): Migrate to Github actions. Support all nodejs releases that have not passed their end date --- .github/workflows/build.yml | 72 +++++++++++++++++ .github/workflows/check-package-version.yml | 44 +++++++++++ .github/workflows/publish-to-github.yml | 18 +++++ .github/workflows/publish-to-npm.yml | 16 ++++ .travis.yml | 2 - CHANGELOG.md | 2 + README.md | 6 +- ...acceptance.config.js => jest.e2e.config.js | 2 +- package-lock.json | 33 -------- package.json | 9 +-- test/{acceptance => e2e}/CliRunner.js | 0 test/{acceptance => e2e}/about-api.spec.js | 0 .../{acceptance => e2e}/behaviors-api.spec.js | 0 .../change-behavior.spec.js | 0 .../deprecated-change-behavior.spec.js | 0 .../deprecated-core-events.spec.js | 0 test/{acceptance => e2e}/fixtures-api.spec.js | 0 .../files-modification/fixtures/users.js | 0 .../files-modification/new-fixtures/users.js | 0 .../fixtures/files-modification/standard.js | 0 .../fixtures/files-watch/fixtures/users.js | 78 +++++++++++++++++++ .../files-watch/new-fixtures/users.js | 43 ++++++++++ test/e2e/fixtures/files-watch/standard.js | 34 ++++++++ .../fixtures/start-files-watch.js | 0 test/{acceptance => e2e}/fixtures/start.js | 0 .../fixtures/web-tutorial-json/behaviors.json | 0 .../web-tutorial-json/fixtures/dynamic.js | 0 .../web-tutorial-json/fixtures/fixtures.json | 0 .../fixtures/web-tutorial/fixtures/users.js | 0 .../fixtures/web-tutorial/standard.js | 0 .../plugin-options.spec.js | 0 test/{acceptance => e2e}/settings-api.spec.js | 0 .../settings-logs-api.spec.js | 0 .../settings-watch-api.spec.js | 0 test/{acceptance => e2e}/utils.js | 0 35 files changed, 314 insertions(+), 45 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/check-package-version.yml create mode 100644 .github/workflows/publish-to-github.yml create mode 100644 .github/workflows/publish-to-npm.yml delete mode 100644 .travis.yml rename jest.acceptance.config.js => jest.e2e.config.js (87%) rename test/{acceptance => e2e}/CliRunner.js (100%) rename test/{acceptance => e2e}/about-api.spec.js (100%) rename test/{acceptance => e2e}/behaviors-api.spec.js (100%) rename test/{acceptance => e2e}/change-behavior.spec.js (100%) rename test/{acceptance => e2e}/deprecated-change-behavior.spec.js (100%) rename test/{acceptance => e2e}/deprecated-core-events.spec.js (100%) rename test/{acceptance => e2e}/fixtures-api.spec.js (100%) rename test/{acceptance => e2e}/fixtures/files-modification/fixtures/users.js (100%) rename test/{acceptance => e2e}/fixtures/files-modification/new-fixtures/users.js (100%) rename test/{acceptance => e2e}/fixtures/files-modification/standard.js (100%) create mode 100644 test/e2e/fixtures/files-watch/fixtures/users.js create mode 100644 test/e2e/fixtures/files-watch/new-fixtures/users.js create mode 100644 test/e2e/fixtures/files-watch/standard.js rename test/{acceptance => e2e}/fixtures/start-files-watch.js (100%) rename test/{acceptance => e2e}/fixtures/start.js (100%) rename test/{acceptance => e2e}/fixtures/web-tutorial-json/behaviors.json (100%) rename test/{acceptance => e2e}/fixtures/web-tutorial-json/fixtures/dynamic.js (100%) rename test/{acceptance => e2e}/fixtures/web-tutorial-json/fixtures/fixtures.json (100%) rename test/{acceptance => e2e}/fixtures/web-tutorial/fixtures/users.js (100%) rename test/{acceptance => e2e}/fixtures/web-tutorial/standard.js (100%) rename test/{acceptance => e2e}/plugin-options.spec.js (100%) rename test/{acceptance => e2e}/settings-api.spec.js (100%) rename test/{acceptance => e2e}/settings-logs-api.spec.js (100%) rename test/{acceptance => e2e}/settings-watch-api.spec.js (100%) rename test/{acceptance => e2e}/utils.js (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..78f0b70 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,72 @@ +name: build +on: + push: + branches: + - master + - release + pull_request: +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + node: ["10.23.0", "12.19.0", "14.15.0", "15.2.0"] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Extract branch name + shell: bash + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF##*/})" + id: extract-branch + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + - name: Cache node modules + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Install dependencies + run: npm ci + - name: Lint + run: npm run lint + - name: Test unit + run: npm run test:unit + - name: Test E2E + run: npm run test:e2e + id: test-e2e + - name: Upload test results + uses: actions/upload-artifact@v2 + with: + name: coverage-${{ matrix.node }} + path: coverage + retention-days: 1 + quality: + runs-on: ubuntu-latest + needs: test + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Download test results + uses: actions/download-artifact@v2 + with: + name: coverage-15.2.0 + path: coverage + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: SonarCloud Scan + if: env.SONAR_TOKEN != '' + uses: sonarsource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/check-package-version.yml b/.github/workflows/check-package-version.yml new file mode 100644 index 0000000..44b17aa --- /dev/null +++ b/.github/workflows/check-package-version.yml @@ -0,0 +1,44 @@ +name: check-package-version +on: + pull_request: + branches: + - master +jobs: + check-package-version: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Get NPM version is new + id: check + uses: EndBug/version-check@v1.6.0 + with: + diff-search: true + file-name: ./package.json + file-url: https://unpkg.com/@mocks-server/plugin-admin-api@latest/package.json + static-checking: localIsNew + - name: Check version is new + if: steps.check.outputs.changed != 'true' + run: | + echo "Version not changed" + exit 1 + - name: Get NPM version + id: package-version + uses: martinbeentjes/npm-get-version-action@v1.1.0 + - name: Check Changelog version + id: changelog_reader + uses: mindsers/changelog-reader-action@v2.0.0 + with: + version: ${{ steps.package-version.outputs.current-version }} + path: ./CHANGELOG.md + - name: Read version from Sonar config + id: sonar-version + uses: christian-draeger/read-properties@1.0.1 + with: + path: './sonar-project.properties' + property: 'sonar.projectVersion' + - name: Check Sonar version + if: steps.sonar-version.outputs.value != steps.package-version.outputs.current-version + run: | + echo "Version not changed" + exit 1 diff --git a/.github/workflows/publish-to-github.yml b/.github/workflows/publish-to-github.yml new file mode 100644 index 0000000..ba50e4f --- /dev/null +++ b/.github/workflows/publish-to-github.yml @@ -0,0 +1,18 @@ +name: publish-to-github +on: + release: + types: [created] +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '12.x' + registry-url: 'https://npm.pkg.github.com' + # Defaults to the user or organization that owns the workflow file + scope: '@mocks-server' + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish-to-npm.yml b/.github/workflows/publish-to-npm.yml new file mode 100644 index 0000000..2444d4b --- /dev/null +++ b/.github/workflows/publish-to-npm.yml @@ -0,0 +1,16 @@ +name: publish-to-npm +on: + release: + types: [created] +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: '12.x' + registry-url: 'https://registry.npmjs.org/' + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2916bb4..0000000 --- a/.travis.yml +++ /dev/null @@ -1,2 +0,0 @@ -version: ~> 1.0 -import: mocks-server/ci-cd:.travis-deploy.yml@master diff --git a/CHANGELOG.md b/CHANGELOG.md index c0b10c5..7cd55ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [unreleased] ### Added ### Changed +- chore(ci): Migrate from Travis CI to github actions +- chore(deps): Support all Node.js releases that have not passed their end date ### Fixed ### Removed diff --git a/README.md b/README.md index 98ce7f2..bdd88fc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build status][travisci-image]][travisci-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Quality Gate][quality-gate-image]][quality-gate-url] +[![Build status][build-image]][build-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Quality Gate][quality-gate-image]][quality-gate-url] [![NPM dependencies][npm-dependencies-image]][npm-dependencies-url] [![Renovate](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com) [![Last commit][last-commit-image]][last-commit-url] [![Last release][release-image]][release-url] @@ -51,8 +51,8 @@ Please read the [contributing guidelines](.github/CONTRIBUTING.md) and [code of [coveralls-image]: https://coveralls.io/repos/github/mocks-server/plugin-admin-api/badge.svg [coveralls-url]: https://coveralls.io/github/mocks-server/plugin-admin-api -[travisci-image]: https://travis-ci.com/mocks-server/plugin-admin-api.svg?branch=master -[travisci-url]: https://travis-ci.com/mocks-server/plugin-admin-api +[build-image]: https://github.com/mocks-server/plugin-admin-api/workflows/build/badge.svg?branch=master +[build-url]: https://github.com/mocks-server/plugin-admin-api/actions?query=workflow%3Abuild+branch%3Amaster [last-commit-image]: https://img.shields.io/github/last-commit/mocks-server/plugin-admin-api.svg [last-commit-url]: https://github.com/mocks-server/plugin-admin-api/commits [license-image]: https://img.shields.io/npm/l/@mocks-server/plugin-admin-api.svg diff --git a/jest.acceptance.config.js b/jest.e2e.config.js similarity index 87% rename from jest.acceptance.config.js rename to jest.e2e.config.js index 4694d8d..52a2db0 100644 --- a/jest.acceptance.config.js +++ b/jest.e2e.config.js @@ -5,7 +5,7 @@ module.exports = { // Automatically clear mock calls and instances between every test clearMocks: true, - testMatch: ["**/test/acceptance/**/?(*.)+(spec|test).js?(x)"], + testMatch: ["**/test/e2e/**/?(*.)+(spec|test).js?(x)"], // Indicates whether the coverage information should be collected while executing the test collectCoverage: false, diff --git a/package-lock.json b/package-lock.json index 58ef8c4..4b8bbcc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1797,27 +1797,6 @@ "yaml": "^1.10.0" } }, - "coveralls": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/coveralls/-/coveralls-3.0.9.tgz", - "integrity": "sha512-nNBg3B1+4iDox5A5zqHKzUTiwl2ey4k2o0NEcVZYvl+GOSJdKBj4AJGKLv6h3SvWch7tABHePAQOSZWM9E2hMg==", - "dev": true, - "requires": { - "js-yaml": "^3.13.1", - "lcov-parse": "^1.0.0", - "log-driver": "^1.2.7", - "minimist": "^1.2.0", - "request": "^2.88.0" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true - } - } - }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -4164,12 +4143,6 @@ "integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==", "dev": true }, - "lcov-parse": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-1.0.0.tgz", - "integrity": "sha1-6w1GtUER68VhrLTECO+TY73I9+A=", - "dev": true - }, "leven": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", @@ -4301,12 +4274,6 @@ "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", "dev": true }, - "log-driver": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/log-driver/-/log-driver-1.2.7.tgz", - "integrity": "sha512-U7KCmLdqsGHBLeWqYlFA0V0Sl6P08EE1ZrmA9cxjUE0WVqT9qnyVDPz1kzpFEP0jdJuFnasWIfSd7fsaNXkpbg==", - "dev": true - }, "log-symbols": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.0.0.tgz", diff --git a/package.json b/package.json index 3f5d42b..49e1bd1 100644 --- a/package.json +++ b/package.json @@ -27,10 +27,8 @@ "lint": "eslint *.js src test", "lint-staged": "lint-staged", "test": "jest", - "test:acceptance": "jest --config=jest.acceptance.config.js --runInBand", - "test:coverage": "npm run test", - "test:ci": "npm run test && npm run test:acceptance", - "coveralls": "cat ./coverage/lcov.info | coveralls" + "test:e2e": "jest --config=jest.e2e.config.js --runInBand", + "test:unit": "npm run test" }, "peerDependencies": { "@mocks-server/core": ">=1.3.0" @@ -42,7 +40,6 @@ }, "devDependencies": { "@mocks-server/core": "1.5.1", - "coveralls": "3.0.9", "eslint": "7.12.1", "eslint-config-prettier": "6.15.0", "eslint-plugin-prettier": "3.1.4", @@ -69,6 +66,6 @@ } }, "engines": { - "node": "12.x || 14.x" + "node": "10.x || 12.x || 14.x || 15.x" } } diff --git a/test/acceptance/CliRunner.js b/test/e2e/CliRunner.js similarity index 100% rename from test/acceptance/CliRunner.js rename to test/e2e/CliRunner.js diff --git a/test/acceptance/about-api.spec.js b/test/e2e/about-api.spec.js similarity index 100% rename from test/acceptance/about-api.spec.js rename to test/e2e/about-api.spec.js diff --git a/test/acceptance/behaviors-api.spec.js b/test/e2e/behaviors-api.spec.js similarity index 100% rename from test/acceptance/behaviors-api.spec.js rename to test/e2e/behaviors-api.spec.js diff --git a/test/acceptance/change-behavior.spec.js b/test/e2e/change-behavior.spec.js similarity index 100% rename from test/acceptance/change-behavior.spec.js rename to test/e2e/change-behavior.spec.js diff --git a/test/acceptance/deprecated-change-behavior.spec.js b/test/e2e/deprecated-change-behavior.spec.js similarity index 100% rename from test/acceptance/deprecated-change-behavior.spec.js rename to test/e2e/deprecated-change-behavior.spec.js diff --git a/test/acceptance/deprecated-core-events.spec.js b/test/e2e/deprecated-core-events.spec.js similarity index 100% rename from test/acceptance/deprecated-core-events.spec.js rename to test/e2e/deprecated-core-events.spec.js diff --git a/test/acceptance/fixtures-api.spec.js b/test/e2e/fixtures-api.spec.js similarity index 100% rename from test/acceptance/fixtures-api.spec.js rename to test/e2e/fixtures-api.spec.js diff --git a/test/acceptance/fixtures/files-modification/fixtures/users.js b/test/e2e/fixtures/files-modification/fixtures/users.js similarity index 100% rename from test/acceptance/fixtures/files-modification/fixtures/users.js rename to test/e2e/fixtures/files-modification/fixtures/users.js diff --git a/test/acceptance/fixtures/files-modification/new-fixtures/users.js b/test/e2e/fixtures/files-modification/new-fixtures/users.js similarity index 100% rename from test/acceptance/fixtures/files-modification/new-fixtures/users.js rename to test/e2e/fixtures/files-modification/new-fixtures/users.js diff --git a/test/acceptance/fixtures/files-modification/standard.js b/test/e2e/fixtures/files-modification/standard.js similarity index 100% rename from test/acceptance/fixtures/files-modification/standard.js rename to test/e2e/fixtures/files-modification/standard.js diff --git a/test/e2e/fixtures/files-watch/fixtures/users.js b/test/e2e/fixtures/files-watch/fixtures/users.js new file mode 100644 index 0000000..50d25b2 --- /dev/null +++ b/test/e2e/fixtures/files-watch/fixtures/users.js @@ -0,0 +1,78 @@ +/* +Copyright 2019 Javier Brea + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. +*/ + +const INITIAL_USERS = [ + { + id: 1, + name: "John Doe modified", + }, + { + id: 2, + name: "Jane Doe modified", + }, +]; + +const getUsers = { + url: "/api/users", + method: "GET", + response: { + status: 200, + body: INITIAL_USERS, + }, +}; + +const getUser = { + url: "/api/users/:id", + method: "GET", + response: { + status: 200, + body: { + id: 1, + name: "John Doe modified", + }, + }, +}; + +const getUser2 = { + url: "/api/users/:id", + method: "GET", + response: { + status: 200, + body: { + id: 2, + name: "Jane Doe modified", + }, + }, +}; + +const getRealUser = { + url: "/api/users/:id", + method: "GET", + response: (req, res) => { + const userId = req.params.id; + const user = INITIAL_USERS.find((userData) => userData.id === Number(userId)); + if (user) { + res.status(200); + res.send(user); + } else { + res.status(404); + res.send({ + message: "User not found", + }); + } + }, +}; + +module.exports = { + getUsers, + getUser, + getUser2, + getRealUser, +}; diff --git a/test/e2e/fixtures/files-watch/new-fixtures/users.js b/test/e2e/fixtures/files-watch/new-fixtures/users.js new file mode 100644 index 0000000..e764ff9 --- /dev/null +++ b/test/e2e/fixtures/files-watch/new-fixtures/users.js @@ -0,0 +1,43 @@ +/* +Copyright 2019 Javier Brea + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. +*/ + +const INITIAL_USERS = [ + { + id: 1, + name: "John Doe new", + }, + { + id: 2, + name: "Jane Doe new", + }, +]; + +const getNewUsers = { + url: "/api/new-users", + method: "GET", + response: { + status: 200, + body: INITIAL_USERS, + }, +}; + +const getNewUser = { + url: "/api/new-users/:id", + method: "GET", + response: { + status: 200, + body: INITIAL_USERS[0], + }, +}; + +module.exports = { + getNewUsers, + getNewUser, +}; diff --git a/test/e2e/fixtures/files-watch/standard.js b/test/e2e/fixtures/files-watch/standard.js new file mode 100644 index 0000000..382416d --- /dev/null +++ b/test/e2e/fixtures/files-watch/standard.js @@ -0,0 +1,34 @@ +/* +Copyright 2019 Javier Brea + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. +*/ + +// /mocks/behaviors.js + +const { Behavior } = require("@mocks-server/core"); + +const { getUsers, getUser, getUser2, getRealUser } = require("./fixtures/users"); +const { getNewUsers, getNewUser } = require("./new-fixtures/users"); + +const standard = new Behavior([getUsers, getUser]); + +// Extends the standard behavior adding "getUser2" fixture. +const user2 = standard.extend([getUser2]); + +// Extends the standard behavior adding "getRealUser" dynamic fixture. +const dynamic = standard.extend([getRealUser]); + +// New one created while server is running +const newOne = standard.extend([getNewUsers, getNewUser]); + +module.exports = { + standard, + user2, + dynamic, + newOne, +}; diff --git a/test/acceptance/fixtures/start-files-watch.js b/test/e2e/fixtures/start-files-watch.js similarity index 100% rename from test/acceptance/fixtures/start-files-watch.js rename to test/e2e/fixtures/start-files-watch.js diff --git a/test/acceptance/fixtures/start.js b/test/e2e/fixtures/start.js similarity index 100% rename from test/acceptance/fixtures/start.js rename to test/e2e/fixtures/start.js diff --git a/test/acceptance/fixtures/web-tutorial-json/behaviors.json b/test/e2e/fixtures/web-tutorial-json/behaviors.json similarity index 100% rename from test/acceptance/fixtures/web-tutorial-json/behaviors.json rename to test/e2e/fixtures/web-tutorial-json/behaviors.json diff --git a/test/acceptance/fixtures/web-tutorial-json/fixtures/dynamic.js b/test/e2e/fixtures/web-tutorial-json/fixtures/dynamic.js similarity index 100% rename from test/acceptance/fixtures/web-tutorial-json/fixtures/dynamic.js rename to test/e2e/fixtures/web-tutorial-json/fixtures/dynamic.js diff --git a/test/acceptance/fixtures/web-tutorial-json/fixtures/fixtures.json b/test/e2e/fixtures/web-tutorial-json/fixtures/fixtures.json similarity index 100% rename from test/acceptance/fixtures/web-tutorial-json/fixtures/fixtures.json rename to test/e2e/fixtures/web-tutorial-json/fixtures/fixtures.json diff --git a/test/acceptance/fixtures/web-tutorial/fixtures/users.js b/test/e2e/fixtures/web-tutorial/fixtures/users.js similarity index 100% rename from test/acceptance/fixtures/web-tutorial/fixtures/users.js rename to test/e2e/fixtures/web-tutorial/fixtures/users.js diff --git a/test/acceptance/fixtures/web-tutorial/standard.js b/test/e2e/fixtures/web-tutorial/standard.js similarity index 100% rename from test/acceptance/fixtures/web-tutorial/standard.js rename to test/e2e/fixtures/web-tutorial/standard.js diff --git a/test/acceptance/plugin-options.spec.js b/test/e2e/plugin-options.spec.js similarity index 100% rename from test/acceptance/plugin-options.spec.js rename to test/e2e/plugin-options.spec.js diff --git a/test/acceptance/settings-api.spec.js b/test/e2e/settings-api.spec.js similarity index 100% rename from test/acceptance/settings-api.spec.js rename to test/e2e/settings-api.spec.js diff --git a/test/acceptance/settings-logs-api.spec.js b/test/e2e/settings-logs-api.spec.js similarity index 100% rename from test/acceptance/settings-logs-api.spec.js rename to test/e2e/settings-logs-api.spec.js diff --git a/test/acceptance/settings-watch-api.spec.js b/test/e2e/settings-watch-api.spec.js similarity index 100% rename from test/acceptance/settings-watch-api.spec.js rename to test/e2e/settings-watch-api.spec.js diff --git a/test/acceptance/utils.js b/test/e2e/utils.js similarity index 100% rename from test/acceptance/utils.js rename to test/e2e/utils.js From a9a0d9cce65e378642fad240fc62781fb0605317 Mon Sep 17 00:00:00 2001 From: "javier.brea" Date: Mon, 21 Dec 2020 10:26:55 +0100 Subject: [PATCH 2/7] test(e2e): Avoid committing files generated in tests --- .../fixtures/files-watch/fixtures/users.js | 78 ------------------- .../files-watch/new-fixtures/users.js | 43 ---------- test/e2e/fixtures/files-watch/standard.js | 34 -------- 3 files changed, 155 deletions(-) delete mode 100644 test/e2e/fixtures/files-watch/fixtures/users.js delete mode 100644 test/e2e/fixtures/files-watch/new-fixtures/users.js delete mode 100644 test/e2e/fixtures/files-watch/standard.js diff --git a/test/e2e/fixtures/files-watch/fixtures/users.js b/test/e2e/fixtures/files-watch/fixtures/users.js deleted file mode 100644 index 50d25b2..0000000 --- a/test/e2e/fixtures/files-watch/fixtures/users.js +++ /dev/null @@ -1,78 +0,0 @@ -/* -Copyright 2019 Javier Brea - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ - -const INITIAL_USERS = [ - { - id: 1, - name: "John Doe modified", - }, - { - id: 2, - name: "Jane Doe modified", - }, -]; - -const getUsers = { - url: "/api/users", - method: "GET", - response: { - status: 200, - body: INITIAL_USERS, - }, -}; - -const getUser = { - url: "/api/users/:id", - method: "GET", - response: { - status: 200, - body: { - id: 1, - name: "John Doe modified", - }, - }, -}; - -const getUser2 = { - url: "/api/users/:id", - method: "GET", - response: { - status: 200, - body: { - id: 2, - name: "Jane Doe modified", - }, - }, -}; - -const getRealUser = { - url: "/api/users/:id", - method: "GET", - response: (req, res) => { - const userId = req.params.id; - const user = INITIAL_USERS.find((userData) => userData.id === Number(userId)); - if (user) { - res.status(200); - res.send(user); - } else { - res.status(404); - res.send({ - message: "User not found", - }); - } - }, -}; - -module.exports = { - getUsers, - getUser, - getUser2, - getRealUser, -}; diff --git a/test/e2e/fixtures/files-watch/new-fixtures/users.js b/test/e2e/fixtures/files-watch/new-fixtures/users.js deleted file mode 100644 index e764ff9..0000000 --- a/test/e2e/fixtures/files-watch/new-fixtures/users.js +++ /dev/null @@ -1,43 +0,0 @@ -/* -Copyright 2019 Javier Brea - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ - -const INITIAL_USERS = [ - { - id: 1, - name: "John Doe new", - }, - { - id: 2, - name: "Jane Doe new", - }, -]; - -const getNewUsers = { - url: "/api/new-users", - method: "GET", - response: { - status: 200, - body: INITIAL_USERS, - }, -}; - -const getNewUser = { - url: "/api/new-users/:id", - method: "GET", - response: { - status: 200, - body: INITIAL_USERS[0], - }, -}; - -module.exports = { - getNewUsers, - getNewUser, -}; diff --git a/test/e2e/fixtures/files-watch/standard.js b/test/e2e/fixtures/files-watch/standard.js deleted file mode 100644 index 382416d..0000000 --- a/test/e2e/fixtures/files-watch/standard.js +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright 2019 Javier Brea - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -*/ - -// /mocks/behaviors.js - -const { Behavior } = require("@mocks-server/core"); - -const { getUsers, getUser, getUser2, getRealUser } = require("./fixtures/users"); -const { getNewUsers, getNewUser } = require("./new-fixtures/users"); - -const standard = new Behavior([getUsers, getUser]); - -// Extends the standard behavior adding "getUser2" fixture. -const user2 = standard.extend([getUser2]); - -// Extends the standard behavior adding "getRealUser" dynamic fixture. -const dynamic = standard.extend([getRealUser]); - -// New one created while server is running -const newOne = standard.extend([getNewUsers, getNewUser]); - -module.exports = { - standard, - user2, - dynamic, - newOne, -}; From c47618b92482eb9479be2f88fc0f18a255b97ee3 Mon Sep 17 00:00:00 2001 From: "javier.brea" Date: Mon, 21 Dec 2020 10:27:05 +0100 Subject: [PATCH 3/7] test(e2e): Avoid committing files generated in tests --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 23ebca0..96a5178 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ # tests /coverage /mocks -/test/acceptance/fixtures/files-watch +/test/e2e/fixtures/files-watch # misc .DS_Store From a014aa386beddc7196f878ecc87659d10885f60f Mon Sep 17 00:00:00 2001 From: "javier.brea" Date: Mon, 21 Dec 2020 10:30:55 +0100 Subject: [PATCH 4/7] docs(changelog): Add change --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cd55ac..f07d89b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed - chore(ci): Migrate from Travis CI to github actions - chore(deps): Support all Node.js releases that have not passed their end date +- test(e2e): Rename acceptance tests into e2e tests ### Fixed ### Removed From ce59a6642a3af02ac18df5af2a3b8d18239e55bf Mon Sep 17 00:00:00 2001 From: "javier.brea" Date: Mon, 21 Dec 2020 10:39:34 +0100 Subject: [PATCH 5/7] chore(deps): Revert add support for node 10.x --- CHANGELOG.md | 1 - package.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f07d89b..92836a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added ### Changed - chore(ci): Migrate from Travis CI to github actions -- chore(deps): Support all Node.js releases that have not passed their end date - test(e2e): Rename acceptance tests into e2e tests ### Fixed ### Removed diff --git a/package.json b/package.json index 49e1bd1..468aebf 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,6 @@ } }, "engines": { - "node": "10.x || 12.x || 14.x || 15.x" + "node": "12.x || 14.x || 15.x" } } From a4fdef6bfee29a74929e04d19e2af78f7364e87b Mon Sep 17 00:00:00 2001 From: "javier.brea" Date: Mon, 21 Dec 2020 10:48:24 +0100 Subject: [PATCH 6/7] chore(deps): Revert add support for node 10.x --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78f0b70..8b5192a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: ["10.23.0", "12.19.0", "14.15.0", "15.2.0"] + node: ["12.19.0", "14.15.0", "15.2.0"] steps: - name: Checkout uses: actions/checkout@v2 From e9eabc37ca3a7b2600ed33a40d1d0272aa85f1c3 Mon Sep 17 00:00:00 2001 From: "javier.brea" Date: Mon, 21 Dec 2020 11:16:45 +0100 Subject: [PATCH 7/7] chore(release): Upgrade version --- CHANGELOG.md | 11 +++++++++-- package-lock.json | 2 +- package.json | 2 +- sonar-project.properties | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92836a0..115957f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,11 +11,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [unreleased] ### Added ### Changed -- chore(ci): Migrate from Travis CI to github actions -- test(e2e): Rename acceptance tests into e2e tests ### Fixed ### Removed +## [1.4.7] - 2020-12-21 + +### Added +- chore(deps): Add support for Node.js v15.x + +### Changed +- chore(ci): Migrate from Travis CI to github actions +- test(e2e): Rename acceptance tests into e2e tests + ## [1.4.6] - 2020-10-27 ### Changed - chore(deps): Update dependencies diff --git a/package-lock.json b/package-lock.json index 4b8bbcc..3aad602 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@mocks-server/plugin-admin-api", - "version": "1.4.6", + "version": "1.4.7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 468aebf..de98776 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mocks-server/plugin-admin-api", - "version": "1.4.6", + "version": "1.4.7", "description": "Plugin for Mocks Server. Provides a REST API for administrating settings, fixtures and behaviors", "keywords": [ "mocks-server-plugin", diff --git a/sonar-project.properties b/sonar-project.properties index bd0e9be..249eebf 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,6 @@ sonar.organization=mocks-server sonar.projectKey=mocks-server-plugin-admin-api -sonar.projectVersion=1.4.6 +sonar.projectVersion=1.4.7 sonar.javascript.file.suffixes=.js sonar.sourceEncoding=UTF-8