diff --git a/.circleci/config.yml b/.circleci/config.yml index d7c9574cb348d3bff6d005d16c529527b7cc8950..9ec5895ab711b3e5cc2eec5ef9210da95e76f668 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -47,56 +47,6 @@ services_steps: &services_steps - store_test_results: path: junit -package_steps: &package_steps - steps: - - checkout - - - run: - name: Install node and npm - command: | - set +e - export NVM_DIR="/opt/circleci/.nvm" - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - nvm install v14 - nvm use v14 - npm install -g npm - - # Run the package tests on each currently supported node version. See: - # https://github.com/badges/shields/blob/master/badge-maker/README.md#node-version-support - # https://nodejs.org/en/about/releases/ - - - run: - environment: - mocha_reporter: mocha-junit-reporter - MOCHA_FILE: junit/badge-maker/v12/results.xml - NODE_VERSION: v12 - CYPRESS_INSTALL_BINARY: 0 - NPM_CONFIG_ENGINE_STRICT: 'false' - name: Run package tests on Node 12 - command: scripts/run_package_tests.sh - - - run: - environment: - mocha_reporter: mocha-junit-reporter - MOCHA_FILE: junit/badge-maker/v14/results.xml - NODE_VERSION: v14 - CYPRESS_INSTALL_BINARY: 0 - NPM_CONFIG_ENGINE_STRICT: 'false' - name: Run package tests on Node 14 - command: scripts/run_package_tests.sh - - - run: - environment: - mocha_reporter: mocha-junit-reporter - MOCHA_FILE: junit/badge-maker/v16/results.xml - NODE_VERSION: v16 - CYPRESS_INSTALL_BINARY: 0 - name: Run package tests on Node 16 - command: scripts/run_package_tests.sh - - - store_test_results: - path: junit - jobs: integration: docker: @@ -172,12 +122,6 @@ jobs: when: always command: npm run build - package: - machine: - image: 'ubuntu-2004:202111-02' - - <<: *package_steps - services: docker: - image: cimg/node:16.15 @@ -249,10 +193,6 @@ workflows: filters: branches: ignore: gh-pages - - package: - filters: - branches: - ignore: gh-pages - services: filters: branches: diff --git a/.github/actions/package-tests/action.yml b/.github/actions/package-tests/action.yml new file mode 100644 index 0000000000000000000000000000000000000000..8ddedc3d09cc3c9e0a5f5b0237b6db45ac1c2ae6 --- /dev/null +++ b/.github/actions/package-tests/action.yml @@ -0,0 +1,26 @@ +name: 'Package tests' +description: 'Run package tests and check types' +runs: + using: 'composite' + steps: + - name: Tests + if: always() + run: npm run test:package -- --reporter json --reporter-option 'output=reports/package-tests.json' + shell: bash + + - name: Type Checks + if: always() + run: | + set -o pipefail + npm run check-types:package 2>&1 | tee reports/package-types.txt + shell: bash + + - name: Write Markdown Summary + if: always() + run: | + node scripts/mocha2md.js 'Package Tests' reports/package-tests.json >> $GITHUB_STEP_SUMMARY + echo '# Package Types' >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + cat reports/package-types.txt >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + shell: bash diff --git a/.github/workflows/test-package-cli.yml b/.github/workflows/test-package-cli.yml new file mode 100644 index 0000000000000000000000000000000000000000..082197020bc96a091c3c41413390a7c13587a4ae --- /dev/null +++ b/.github/workflows/test-package-cli.yml @@ -0,0 +1,44 @@ +name: Package CLI +on: + pull_request: + push: + branches-ignore: + - 'gh-pages' + +# Smoke test (render a badge with the CLI) with only the package +# dependencies installed. + +jobs: + test-package-cli: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - node: '14' + engine-strict: 'false' + - node: '16' + engine-strict: 'false' + - node: '18' + engine-strict: 'true' + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Node JS ${{ inputs.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + + - name: Install dependencies + env: + CYPRESS_INSTALL_BINARY: 0 + NPM_CONFIG_ENGINE_STRICT: ${{ matrix.engine-strict }} + run: | + cd badge-maker + npm install + npm link + + - name: Render a badge with the CLI + run: | + cd badge-maker + badge cactus grown :green @flat diff --git a/.github/workflows/test-package-lib.yml b/.github/workflows/test-package-lib.yml new file mode 100644 index 0000000000000000000000000000000000000000..aa733eb233ee6b8805f57b2075d3a270e69c3c0f --- /dev/null +++ b/.github/workflows/test-package-lib.yml @@ -0,0 +1,32 @@ +name: Package Library +on: + pull_request: + push: + branches-ignore: + - 'gh-pages' + +jobs: + test-package-lib: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - node: '14' + engine-strict: 'false' + - node: '16' + engine-strict: 'true' + - node: '18' + engine-strict: 'false' + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup + uses: ./.github/actions/setup + with: + node-version: ${{ matrix.node }} + env: + NPM_CONFIG_ENGINE_STRICT: ${{ matrix.engine-strict }} + + - name: Package tests + uses: ./.github/actions/package-tests diff --git a/badge-maker/CHANGELOG.md b/badge-maker/CHANGELOG.md index 3cf6c3c37f06f6d69fa25e73050b90403e026ecf..619785c2300c267bc2af6fe551d93e52dd470d96 100644 --- a/badge-maker/CHANGELOG.md +++ b/badge-maker/CHANGELOG.md @@ -2,7 +2,7 @@ ## 4.0.0 [WIP] -- Drop compatibility with Node 10 +- Drop compatibility with Node < 14 ## 3.3.1 diff --git a/badge-maker/package.json b/badge-maker/package.json index fc6702acb71ba63bc4716f3c9b0f4c0e3ae0c6b1..374ce547934a100101cd6989bec8c6c63908b1cf 100644 --- a/badge-maker/package.json +++ b/badge-maker/package.json @@ -26,7 +26,7 @@ "badge": "lib/badge-cli.js" }, "engines": { - "node": ">= 12", + "node": ">= 14", "npm": ">= 6" }, "collective": { diff --git a/scripts/run_package_tests.sh b/scripts/run_package_tests.sh deleted file mode 100755 index b83bd39c948efa62c64b51436dd3b3019474e82e..0000000000000000000000000000000000000000 --- a/scripts/run_package_tests.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# https://discuss.circleci.com/t/switch-nodejs-version-on-machine-executor-solved/26675/3 - -# Start off less strict to work around various nvm errors. -set -e -export NVM_DIR="/opt/circleci/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" -nvm install $NODE_VERSION -nvm use $NODE_VERSION - -# Stricter. -set -euo pipefail -node --version - -# Install the shields.io dependencies. -npm ci - -# Run the package tests. -npm run test:package -npm run check-types:package - -# Delete the full shields.io dependency tree -rm -rf node_modules/ - - -# Run a smoke test (render a badge with the CLI) with only the package -# dependencies installed. -cd badge-maker - -npm install # install only the package dependencies for this test -npm link -badge cactus grown :green @flat -rm package-lock.json && rm -rf node_modules/ # clean up package dependencies