Skip to content

Commit

Permalink
Add extra features to jobs (#245)
Browse files Browse the repository at this point in the history
* Cache branch default false

* Add extra features to jobs

* Add test for new features
  • Loading branch information
marboledacci authored Dec 5, 2024
1 parent 84232a2 commit 8848afb
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 15 deletions.
16 changes: 16 additions & 0 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,22 @@ workflows:
command: |
rm ~/project/sample/pnpm-lock.yaml
rm ~/project/sample/yarn.lock
- node/test:
filters: *filters
name: node-test-no-junit-new-features
app-dir: "~/project/sample"
cache-version: v1
executor: machine
parallelism: 4
post_install_steps:
- run: |
echo "Packages installed"
setup:
- run:
name: Remove other lock files
command: |
rm ~/project/sample/pnpm-lock.yaml
rm ~/project/sample/yarn.lock
- node/test:
filters: *filters
name: node-test-with-coverage
Expand Down
2 changes: 1 addition & 1 deletion src/commands/install-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ parameters:
description: Change the default cache version if you need to clear the cache for any reason.
include-branch-in-cache-key:
type: boolean
default: true
default: false
description: >
If true, this cache bucket will only apply to jobs within the same branch.
Expand Down
16 changes: 12 additions & 4 deletions src/jobs/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ description: |
Simple drop-in job to run commands for your Node.js application automatically.
parameters:
parallelism:
type: integer
default: 1
description: The number of parallel jobs to run. See https://circleci.com/docs/parallelism-faster-jobs/
pkg-manager:
type: enum
enum: ['npm', 'yarn', 'yarn-berry', 'pnpm']
Expand All @@ -15,6 +19,10 @@ parameters:
type: steps
description: Provide any optional steps you would like to run prior to installing the node dependencies. This is a good place to install global modules.
default: []
post_install_steps:
type: steps
description: Provide any optional steps you would like to run after installing the node dependencies.
default: []
npm-run:
type: string
default: ''
Expand Down Expand Up @@ -44,7 +52,7 @@ parameters:
default: ''
include-branch-in-cache-key:
type: boolean
default: true
default: false
description: >
If true, this cache bucket will only apply to jobs within the same branch.
cache-path:
Expand Down Expand Up @@ -76,11 +84,10 @@ parameters:
executor:
type: executor
default: default
description: |
The name of executor to use.
description: The name of executor to use.

executor: <<parameters.executor>>

parallelism: <<parameters.parallelism>>
steps:
- checkout
- steps: << parameters.setup >>
Expand All @@ -94,6 +101,7 @@ steps:
cache-only-lockfile: <<parameters.cache-only-lockfile>>
with-cache: <<parameters.with-cache>>
check-cache: <<parameters.check-cache>>
- steps: << parameters.post_install_steps >>
- run:
name: Run <<parameters.pkg-manager>> <<parameters.npm-run>>
working_directory: <<parameters.app-dir>>
Expand Down
28 changes: 18 additions & 10 deletions src/jobs/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ description: |
Simple drop-in job to test your Node.js application automatically.
parameters:
parallelism:
type: integer
default: 1
description: The number of parallel jobs to run. See https://circleci.com/docs/parallelism-faster-jobs/
pkg-manager:
type: enum
enum: ['npm', 'yarn', 'yarn-berry', 'pnpm']
Expand All @@ -15,6 +19,10 @@ parameters:
type: steps
description: Provide any optional steps you would like to run prior to installing the node dependencies. This is a good place to install global modules.
default: []
post_install_steps:
type: steps
description: Provide any optional steps you would like to run after installing the node dependencies.
default: []
run-command:
type: string
default: 'test'
Expand Down Expand Up @@ -51,7 +59,7 @@ parameters:
The code coverage files will be uploaded to artifacts for this workflow.
include-branch-in-cache-key:
type: boolean
default: true
default: false
description: >
If true, this cache bucket will only apply to jobs within the same branch.
cache-path:
Expand Down Expand Up @@ -83,11 +91,10 @@ parameters:
executor:
type: executor
default: default
description: |
The name of executor to use.
description: The name of executor to use.

executor: <<parameters.executor>>

parallelism: <<parameters.parallelism>>
steps:
- checkout
- steps: << parameters.setup >>
Expand All @@ -101,6 +108,7 @@ steps:
cache-only-lockfile: <<parameters.cache-only-lockfile>>
with-cache: <<parameters.with-cache>>
check-cache: <<parameters.check-cache>>
- steps: << parameters.post_install_steps >>
- when: # Run tests for NPM, without test results
condition:
and:
Expand Down Expand Up @@ -250,25 +258,25 @@ steps:
working_directory: <<parameters.app-dir>>
command: pnpm run <<parameters.run-command>> --reporter mocha-multi --reporter-options spec=-,mocha-junit-reporter=-
- when: # upload test results if a path was given
condition: << parameters.test-results-path >>
steps:
store_test_results:
path: << parameters.test-results-path >>
condition: << parameters.test-results-path >>
steps:
- store_test_results:
path: << parameters.test-results-path >>
- when: # upload test results if jest was automatically configured and test-results-path is not specified
condition:
and:
- equal: [jest, << parameters.test-results-for >>]
- equal: ['', << parameters.test-results-path >>]
steps:
store_test_results:
- store_test_results:
path: <<parameters.app-dir>>/junit.xml
- when: # upload test results if mocha was automatically configured and test-results-path is not specified
condition:
and:
- equal: [mocha, << parameters.test-results-for >>]
- equal: ['', << parameters.test-results-path >>]
steps:
store_test_results:
- store_test_results:
path: <<parameters.app-dir>>/test-results.xml
- when: # upload coverage files if test-coverage-path was configured
condition: <<parameters.test-coverage-path>>
Expand Down

0 comments on commit 8848afb

Please sign in to comment.