migrate package tests to GHA (#8351)

migrate package tests to GHA
This commit is contained in:
chris48s
2022-09-05 21:00:20 +01:00
committed by GitHub
parent d9842c0ceb
commit cf83fb3235
7 changed files with 104 additions and 96 deletions

View File

@@ -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:

View File

@@ -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

44
.github/workflows/test-package-cli.yml vendored Normal file
View File

@@ -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

32
.github/workflows/test-package-lib.yml vendored Normal file
View File

@@ -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

View File

@@ -2,7 +2,7 @@
## 4.0.0 [WIP]
- Drop compatibility with Node 10
- Drop compatibility with Node < 14
## 3.3.1

View File

@@ -26,7 +26,7 @@
"badge": "lib/badge-cli.js"
},
"engines": {
"node": ">= 12",
"node": ">= 14",
"npm": ">= 6"
},
"collective": {

View File

@@ -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