Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wip/backup/print config message #11

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
#
# This build use extensive use of parameters
# https://circleci.com/docs/reusing-config/#using-the-parameters-declaration
#
# And Conditional Steps
# https://circleci.com/docs/reusing-config/#defining-conditional-steps

version: 2.1

orbs:
node: circleci/[email protected]

commands:
project-setup:
parameters:
working-dir:
type: string
node-version:
type: string
windows:
type: boolean
default: false
steps:
- checkout:
path: << parameters.working-dir >>
- when:
condition:
equal: [ true, << parameters.windows >> ]
steps:
- run:
name: nvm-install
command: choco install nvm -y
- run:
name: node-install
command: |
Start-Process powershell -verb runAs -Args "-start GeneralProfile"
nvm install << parameters.node-version >>
nvm use << parameters.node-version >>
- run:
name: npm-install
command: npm ci
- when:
condition:
equal: [ false, << parameters.windows >> ]
steps:
- node/install:
node-version: << parameters.node-version >>
install-yarn: false
- node/install-packages:
check-cache: always
pkg-manager: npm
with-cache: false

lint-test:
steps:
- run:
command: npm run posttest

unit-test:
steps:
- run:
command: npm run test


executors:
linux: # a Linux VM running Ubuntu 20.04
docker:
- image: cimg/base:2024.01
working_directory: /home/circleci/project/c8
macos: # macos executor running Xcode
macos:
xcode: 14.2.0
working_directory: /Users/distiller/project/c8
win:
machine:
image: 'windows-server-2019-vs2019:2023.10.1'
resource_class: windows.medium
shell: powershell.exe -ExecutionPolicy Bypass
working_directory: C:\Users\circleci\project\c8

jobs:
# Refactor to a command
test:
parameters:
os:
type: string
node-version:
type: string
executor: << parameters.os >>
steps:
- when:
condition:
equal: [ linux, << parameters.os >> ]
steps:
- project-setup:
node-version: << parameters.node-version >>
working-dir: /home/circleci/project/c8
- when:
condition:
equal: [ win , << parameters.os >> ]
steps:
- project-setup:
node-version: << parameters.node-version >>
working-dir: C:\Users\circleci\project\c8
windows: true
- when:
condition:
equal: [ macos, << parameters.os >> ]
steps:
- project-setup:
node-version: << parameters.node-version >>
working-dir: /Users/distiller/project/c8
- lint-test
- unit-test

workflows:
matrix-test:
jobs:
- test:
matrix:
parameters:
os: [win, linux, macos]
node-version: ["14.21.3", "16.20.2", "18.19.0", "20.11.0"]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Here is a list of common options. Run `c8 --help` for the full list and document
| `--per-file` | check thresholds per file | `boolean` | `false` |
| `--temp-directory` | directory V8 coverage data is written to and read from | `string` | `process.env.NODE_V8_COVERAGE` |
| `--clean` | should temp files be deleted before script execution | `boolean` | `true` |
| `--print-config` | prints the derived configuration between defaults and a detected configuration file or a file passed as an argument | `boolean` | `false`
| `--print-config-format` | format in which to print the derived configuration. Either text or json. | `string` | `text`

## Checking for "full" source coverage using `--all`

Expand Down
19 changes: 18 additions & 1 deletion lib/parse-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const { applyExtends } = require('yargs/helpers')
const parser = require('yargs-parser')
const { resolve } = require('path')

const { printConfig } = require('./print-config.js')

function buildYargs (withCommands = false) {
const yargs = Yargs([])
.usage('$0 [opts] [script] [opts]')
Expand Down Expand Up @@ -158,8 +160,19 @@ function buildYargs (withCommands = false) {
describe: 'supplying --merge-async will merge all v8 coverage reports asynchronously and incrementally. ' +
'This is to avoid OOM issues with Node.js runtime.'
})
.options('print-config', {
default: false,
type: 'boolean',
describe: 'Print the derived configuration between command line parameters and loaded configuration file'
})
// Todo: refactor. Use parse-args options.
.options('print-config-format', {
default: 'text',
type: 'string',
choices: ['text', 'json'],
describe: 'Format to print the configuration in. Accepted formats are either text or json'
})
.pkgConf('c8')
.demandCommand(1)
.check((argv) => {
if (!argv.tempDirectory) {
argv.tempDirectory = resolve(argv.reportsDir, 'tmp')
Expand All @@ -181,6 +194,10 @@ function buildYargs (withCommands = false) {
// }
// })

printConfig(yargs, hideInstrumenteeArgs)

yargs.demandCommand(1)

const checkCoverage = require('./commands/check-coverage')
const report = require('./commands/report')
if (withCommands) {
Expand Down
Loading