Skip to content

Commit

Permalink
use custom lock command
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuwalow committed Aug 11, 2023
1 parent 147360b commit 6b31771
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,56 @@ references:
name: Reset package-lock.json
command: git checkout -- package-lock.json

commands:
# for of dynamo-lock/lock that specifies no_output_timeout
dynamo-lock_lock:
parameters:
ttl:
description: TTL of lock in seconds
type: integer
default: 600
table:
description: DynamoDB table for locks
type: string
default: ci_locks
lock_name:
description: >-
Name of the lock to acquire
This name affects which builds lock against each other. The default will
lock branches on the same project and the same branch. If you'd like to
lock all builds in a project, you could use
`${CIRCLE_PROJECT_USERNAME}_${CIRCLE_PROJECT_REPONAME}`
type: string
default: ${CIRCLE_PROJECT_USERNAME}_${CIRCLE_PROJECT_REPONAME}_${CIRCLE_BRANCH}
branches:
description: >-
Branch regex to limit locking on
This is a bash regex, so keep in mind that short escape sequences won't
work (eg `\d` - use `[0-9]` instead). The lock commands will only be
effective on branches matching this regex.
type: string
default: master|develop
steps:
- run:
name: Acquire lock
no_output_timeout: << parameters.ttl >>s
command: |-
if [[ "$CIRCLE_BRANCH" =~ << parameters.branches >> ]]; then
[[ -x "/tmp/dynolocker_linux_amd64" ]] || echo 'Please call "setup" first'
/tmp/dynolocker_linux_amd64 \
--debug \
--table "<< parameters.table >>" \
--name "<< parameters.lock_name >>" \
--ttl << parameters.ttl >> \
lock
else
echo "Skipping lock due to excluded branch"
fi
jobs:
simple_test:
parallelism: 1
Expand Down Expand Up @@ -126,10 +176,9 @@ jobs:
- *npm_install
- dynamo-lock/setup:
branches: '.*'
- dynamo-lock/lock:
- dynamo-lock_lock:
lock_name: << pipeline.parameters.browserstack_lock_name >>
ttl: << pipeline.parameters.lock_timeout_seconds >>
no_output_timeout: << pipeline.parameters.lock_timeout_seconds >>s
branches: '.*'
- run:
name: Run browserstack tests
Expand Down

0 comments on commit 6b31771

Please sign in to comment.