diff --git a/.circleci/config.yml b/.circleci/config.yml index d94d1ab254c502e4c3561fd94fd4913747535863..d7c9574cb348d3bff6d005d16c529527b7cc8950 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,47 +1,5 @@ version: 2 -main_steps: &main_steps - steps: - - checkout - - - run: - name: Install dependencies - command: | - npm ci - environment: - # https://docs.cypress.io/guides/getting-started/installing-cypress.html#Skipping-installation - # We don't need to install the Cypress binary in jobs that aren't actually running Cypress. - CYPRESS_INSTALL_BINARY: 0 - - - run: - name: Linter - when: always - command: npm run lint - - - run: - name: Core tests - when: always - environment: - mocha_reporter: mocha-junit-reporter - MOCHA_FILE: junit/core/results.xml - command: npm run test:core - - - run: - name: Entrypoint tests - when: always - environment: - mocha_reporter: mocha-junit-reporter - MOCHA_FILE: junit/entrypoint/results.xml - command: npm run test:entrypoint - - - store_test_results: - path: junit - - - run: - name: 'Prettier check (quick fix: `npm run prettier`)' - when: always - command: npm run prettier:check - integration_steps: &integration_steps steps: - checkout @@ -140,20 +98,6 @@ package_steps: &package_steps path: junit jobs: - main: - docker: - - image: cimg/node:16.15 - - <<: *main_steps - - main@node-17: - docker: - - image: cimg/node:17.9 - environment: - NPM_CONFIG_ENGINE_STRICT: 'false' - - <<: *main_steps - integration: docker: - image: cimg/node:16.15 @@ -297,14 +241,6 @@ workflows: on-commit: jobs: - - main: - filters: - branches: - ignore: gh-pages - - main@node-17: - filters: - branches: - ignore: gh-pages - integration@node-17: filters: branches: @@ -346,12 +282,6 @@ workflows: # filters: # branches: # ignore: gh-pages - # - main: - # requires: - # - npm-install - # - main@node-latest: - # requires: - # - npm-install # - frontend: # requires: # - npm-install diff --git a/.github/actions/core-tests/action.yml b/.github/actions/core-tests/action.yml new file mode 100644 index 0000000000000000000000000000000000000000..9f5f1e4d31488f38417b33d608a8127327f229e3 --- /dev/null +++ b/.github/actions/core-tests/action.yml @@ -0,0 +1,21 @@ +name: 'Core tests' +description: 'Run core and entrypoint tests' +runs: + using: 'composite' + steps: + - name: Core tests + if: always() + run: npm run test:core -- --reporter json --reporter-option 'output=reports/core.json' + shell: bash + + - name: Entrypoint tests + if: always() + run: npm run test:entrypoint -- --reporter json --reporter-option 'output=reports/entrypoint.json' + shell: bash + + - name: Write Markdown Summary + if: always() + run: | + node scripts/mocha2md.js Core reports/core.json >> $GITHUB_STEP_SUMMARY + node scripts/mocha2md.js Entrypoint reports/entrypoint.json >> $GITHUB_STEP_SUMMARY + shell: bash diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000000000000000000000000000000000000..0c516f018df2450febbbbd1d65c00ce77802e120 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,25 @@ +name: 'Set up project' +description: 'Set up project' +inputs: + node-version: + description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0.' + required: true + cypress: + description: 'Install Cypress binary: 0 or 1' + # https://docs.cypress.io/guides/getting-started/installing-cypress.html#Skipping-installation + # We don't need to install the Cypress binary in jobs that aren't actually running Cypress. + required: false + default: 0 +runs: + using: 'composite' + steps: + - name: Install Node JS ${{ inputs.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ inputs.node-version }} + + - name: Install dependencies + env: + CYPRESS_INSTALL_BINARY: ${{ inputs.cypress }} + run: npm ci + shell: bash diff --git a/.github/workflows/test-lint.yml b/.github/workflows/test-lint.yml new file mode 100644 index 0000000000000000000000000000000000000000..b05c8f8b349a153a3befd9077383b12599ef3b7a --- /dev/null +++ b/.github/workflows/test-lint.yml @@ -0,0 +1,26 @@ +name: Lint +on: + pull_request: + push: + branches-ignore: + - 'gh-pages' + +jobs: + test-lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup + uses: ./.github/actions/setup + with: + node-version: 16 + + - name: ESLint + if: always() + run: npm run lint + + - name: 'Prettier check (quick fix: `npm run prettier`)' + if: always() + run: npm run prettier:check diff --git a/.github/workflows/test-main-17.yml b/.github/workflows/test-main-17.yml new file mode 100644 index 0000000000000000000000000000000000000000..daabb51cc12f5dc6dc1ef25ae0c5d90a37ff6938 --- /dev/null +++ b/.github/workflows/test-main-17.yml @@ -0,0 +1,23 @@ +name: Main@node 17 +on: + pull_request: + push: + branches-ignore: + - 'gh-pages' + +jobs: + test-main-17: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup + uses: ./.github/actions/setup + with: + node-version: 17 + env: + NPM_CONFIG_ENGINE_STRICT: 'false' + + - name: Core tests + uses: ./.github/actions/core-tests diff --git a/.github/workflows/test-main.yml b/.github/workflows/test-main.yml new file mode 100644 index 0000000000000000000000000000000000000000..e07463cd21ac05c1b27c55befce91b4b7aec4534 --- /dev/null +++ b/.github/workflows/test-main.yml @@ -0,0 +1,21 @@ +name: Main +on: + pull_request: + push: + branches-ignore: + - 'gh-pages' + +jobs: + test-main: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup + uses: ./.github/actions/setup + with: + node-version: 16 + + - name: Core tests + uses: ./.github/actions/core-tests diff --git a/scripts/mocha2md.js b/scripts/mocha2md.js new file mode 100644 index 0000000000000000000000000000000000000000..6c9f4a009a6441347623767baa3dcf374bcc4dda --- /dev/null +++ b/scripts/mocha2md.js @@ -0,0 +1,36 @@ +import fs from 'fs' + +let data +let title + +try { + if (process.argv.length < 4) { + throw new Error() + } + title = process.argv[2] + data = JSON.parse(fs.readFileSync(process.argv[3])) +} catch (e) { + process.stdout.write('failed to write summary\n') + process.exit(1) +} + +process.stdout.write(`# ${title}\n\n`) + +if (data.stats.passes > 0) { + process.stdout.write(`✔ ${data.stats.passes} passed\n`) +} +if (data.stats.failures > 0) { + process.stdout.write(`✖ ${data.stats.failures} failed\n\n`) +} + +if (data.stats.failures > 0) { + for (const test of data.tests) { + if (test.err && Object.keys(test.err).length > 0) { + process.stdout.write(`### ${test.title}\n\n`) + process.stdout.write(`${test.fullTitle}\n\n`) + process.stdout.write('```\n') + process.stdout.write(`${test.err.stack}\n`) + process.stdout.write('```\n\n') + } + } +}