Skip to content

Commit

Permalink
feat: add sonarcloud job and example (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankorstore-haddowg authored May 2, 2023
1 parent 80cc84e commit 004d334
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/examples/basic-pass-fast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ usage:
resource_class: small
steps:
- toolbelt/pass-fast:
pipeline-id: << pipeline.id >>
steps:
- run:
name: Some work you dont want to repeat
Expand Down
1 change: 1 addition & 0 deletions src/examples/parallel-pass-fast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ usage:
parallelism: 2
steps:
- toolbelt/pass-fast:
pipeline-id: << pipeline.id >>
steps:
- run:
name: Some work you dont want to repeat
Expand Down
29 changes: 29 additions & 0 deletions src/examples/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
description: >
Perform a sonarcloud scan including uploading test and coverage reports form a previous job
usage:
version: 2.1
orbs:
toolbelt: ankorstore/[email protected]
workflows:
fail-fast-example:
jobs:
- test
- toolbelt/sonarcloud:
pipeline-id: << pipeline.id >>
test-job: test
branch: << pipeline.git.branch >><<pipeline.git.tag>>
reports-pattern: path/to/reports/.*
requires:
- test
jobs:
test:
docker:
- image: cimg/base
resource_class: small
steps:
- run:
name: Run tests
command: echo "Run some tests and produce test and coverage reports";
- store_artifacts:
name: Store reports
path: path/to/reports
66 changes: 66 additions & 0 deletions src/jobs/sonarcloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
description: >
Perform a SonarCloud Scan
First collects test results and test coverage from prior job artifacts.
parameters:
pipeline-id:
type: string
description: The CircleCI Pipeline ID ( << pipeline.id >> )
app-dir:
default: /home/circleci/project
description: >-
Path to the directory containing your composer.json file. Not needed if
composer.json lives in the working directory.
type: string
main-branch:
type: string
default: master
description: The main branch of the repository
branch:
type: string
description: >-
The current branch name ( << pipeline.git.branch >> ).
Required to ensure the baseline is updated correctly on the main-branch
resource-class:
default: medium
description: Configure the executor resource class
enum:
- small
- medium
- medium+
- large
- xlarge
- 2xlarge
- 2xlarge+
type: enum
test-job:
description: >-
The test job or jobs from which to download test report and coverage artifacts.
For multiple jobs the list must be comma separated.
You can use regex if you start your name with ^.
type: string
reports-pattern:
description: >-
A regex pattern for the test report and coverage
artifact path(s) to be downloaded
type: string
default: build/.*
docker:
- image: cimg/node:lts
resource_class: << parameters.resource-class >>
working_directory: << parameters.app-dir >>
steps:
- pass-fast:
pipeline-id: << parameters.pipeline-id >>
steps:
- run:
name: Clean Checkout directory
command: rm -rf /home/circleci/project/*
- checkout:
path: /home/circleci/project
- get-job-artifacts:
job-name: << parameters.test-job >>
path-pattern: << parameters.reports-pattern >>
- sonar-scan:
branch: << parameters.branch >>
main-branch: << parameters.main-branch >>

0 comments on commit 004d334

Please sign in to comment.