diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..8b5192a --- /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: ["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/.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 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..92836a0 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 +- test(e2e): Rename acceptance tests into e2e tests ### 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..468aebf 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": "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/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