Skip to content

Commit

Permalink
Group Buildkite pipeline anchors (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
72636c authored Jul 13, 2021
1 parent 5b00ffa commit e9a71d4
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 98 deletions.
7 changes: 7 additions & 0 deletions .changeset/few-ligers-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'skuba': patch
---

**template:** Group Buildkite pipeline anchors

This provides a bit more structure to our `pipeline.yml`s and allows anchored plugins to be recognised by Renovate.
32 changes: 18 additions & 14 deletions template/greeter/.buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
configs:
- &aws-sm
seek-oss/aws-sm#v2.0.0:
environments:
- &prod
agents:
queue: <%- prodBuildkiteQueueName %>
env:
NPM_READ_TOKEN: arn:aws:secretsmanager:ap-southeast-2:987872074697:secret:npm/npm-read-token
ENVIRONMENT: prod

- &docker-ecr-cache
seek-oss/docker-ecr-cache#v1.5.0:
build-args:
- NPM_READ_TOKEN
cache-on:
- package.json
- yarn.lock
target: dev-deps
plugins:
- &aws-sm
seek-oss/aws-sm#v2.0.0:
env:
NPM_READ_TOKEN: arn:aws:secretsmanager:ap-southeast-2:987872074697:secret:npm/npm-read-token

- &prod
agents:
queue: <%- prodBuildkiteQueueName %>
- &docker-ecr-cache
seek-oss/docker-ecr-cache#v1.5.0:
build-args:
- NPM_READ_TOKEN
cache-on:
- package.json
- yarn.lock
target: dev-deps

steps:
- <<: *prod
Expand Down
113 changes: 65 additions & 48 deletions template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,82 @@
dev-agent: &dev-agent
agents:
queue: <%- devBuildkiteQueueName %>
configs:
environments:
- &dev
agents:
queue: <%- devBuildkiteQueueName %>

prod-agent: &prod-agent
agents:
queue: <%- prodBuildkiteQueueName %>
- &prod
agents:
queue: <%- prodBuildkiteQueueName %>

plugins: &plugins
seek-oss/aws-sm#v2.3.1:
env:
NPM_READ_TOKEN: arn:aws:secretsmanager:ap-southeast-2:987872074697:secret:npm/npm-read-token
docker#v3.8.0:
volumes:
- /workdir/node_modules
- /workdir/lib
environment:
- NPM_READ_TOKEN
seek-oss/docker-ecr-cache#v1.11.0:
build-args:
- NPM_READ_TOKEN
cache-on:
- package.json
- yarn.lock
plugins:
- &aws-sm
seek-oss/aws-sm#v2.3.1:
env:
NPM_READ_TOKEN: arn:aws:secretsmanager:ap-southeast-2:987872074697:secret:npm/npm-read-token

- &docker
docker#v3.8.0:
volumes:
- /workdir/lib
- /workdir/node_modules

- &docker-ecr-cache
seek-oss/docker-ecr-cache#v1.11.0:
build-args:
- NPM_READ_TOKEN
cache-on:
- package.json
- yarn.lock

base-steps:
- &deploy
concurrency: 1
plugins:
- *aws-sm
- *docker-ecr-cache
- *docker
retry:
manual:
# Only use this if you need to roll back a deployment ASAP.
# Always follow up with a proper revert or fix in Git history.
permit_on_passed: true

steps:
- label: ':yarn: :eslint: Lint and :jest: unit test'
<<: *dev-agent
plugins:
<<: *plugins
key: test
- <<: *dev
label: 🧪 Test & Lint
commands:
- echo "+++ yarn test:ci"
- echo '+++ yarn test:ci'
- yarn test
- echo "--- yarn lint"
- echo '--- yarn lint'
- yarn lint

- label: 'Build & CDK Deploy Staging :shipit:'
<<: *dev-agent
plugins:
<<: *plugins
depends_on:
- test
- *aws-sm
- *docker-ecr-cache
- *docker

- wait
- block: 🙋🏻‍♀️ Deploy Dev
branches: '!master'

- <<: *dev
<<: *deploy
label: 🤞 Deploy Dev
commands:
- echo "--- Building code"
- echo '--- yarn build'
- yarn build
- echo "--- Running CDK deploy to staging"
- echo '+++ yarn deploy:dev'
- yarn deploy:dev
concurrency: 1
concurrency_group: '<%- repoName %>/deploy/dev'
key: deploy-dev

- label: 'Build & CDK Deploy Production :shipit:'
branches: 'master'
<<: *prod-agent
plugins:
<<: *plugins
depends_on:
- test
- <<: *prod
<<: *deploy
label: 🚀 Deploy Prod
branches: master
commands:
- echo "--- Building code"
- echo '--- yarn build'
- yarn build
- echo "--- Running CDK deploy to production"
- echo '+++ yarn deploy:prod'
- yarn deploy:prod
concurrency: 1
concurrency_group: '<%- repoName %>/deploy/prod'
depends_on: deploy-dev
2 changes: 1 addition & 1 deletion template/lambda-sqs-worker-cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"test": "skuba test",
"test:ci": "skuba test --coverage",
"test:watch": "skuba test --watch",
"package": "yarn --prod --modules-folder ./lib/node_modules",
"package": "yarn install --ignore-optional --ignore-scripts --modules-folder ./lib/node_modules --non-interactive --offline --production",
"deploy:dev": "cdk deploy appStack --require-approval never --context stage=dev",
"deploy:prod": "cdk deploy appStack --require-approval never --context stage=prod"
}
Expand Down
74 changes: 39 additions & 35 deletions template/lambda-sqs-worker/.buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,64 @@ env:
VERSION: ${BUILDKITE_COMMIT:0:7}.${BUILDKITE_BUILD_NUMBER}

configs:
- &aws-sm
seek-oss/aws-sm#v2.0.0:
environments:
- &dev
agents:
queue: <%- devBuildkiteQueueName %>
env:
NPM_READ_TOKEN: arn:aws:secretsmanager:ap-southeast-2:987872074697:secret:npm/npm-read-token
ENVIRONMENT: dev

- &docker-ecr-cache
seek-oss/docker-ecr-cache#v1.5.0:
build-args:
- NPM_READ_TOKEN
cache-on:
- package.json
- yarn.lock
target: dev-deps
- &prod
agents:
queue: <%- prodBuildkiteQueueName %>
env:
ENVIRONMENT: prod

- &deploy
concurrency: 1
plugins:
- *aws-sm
- *docker-ecr-cache
- docker-compose#v3.7.0:
dependencies: false
run: app
retry:
manual:
# Only use this if you need to roll back a deployment ASAP.
# Always follow up with a proper revert or fix in Git history.
permit_on_passed: true
plugins:
- &aws-sm
seek-oss/aws-sm#v2.0.0:
env:
NPM_READ_TOKEN: arn:aws:secretsmanager:ap-southeast-2:987872074697:secret:npm/npm-read-token

- &dev
agents:
queue: <%- devBuildkiteQueueName %>
env:
ENVIRONMENT: dev
- &docker-ecr-cache
seek-oss/docker-ecr-cache#v1.5.0:
build-args:
- NPM_READ_TOKEN
cache-on:
- package.json
- yarn.lock
target: dev-deps

- &prod
agents:
queue: <%- prodBuildkiteQueueName %>
env:
ENVIRONMENT: prod
base-steps:
- &deploy
concurrency: 1
plugins:
- *aws-sm
- *docker-ecr-cache
- docker-compose#v3.7.0:
dependencies: false
run: app
retry:
manual:
# Only use this if you need to roll back a deployment ASAP.
# Always follow up with a proper revert or fix in Git history.
permit_on_passed: true

steps:
- <<: *prod
label: 🧪 Test & Lint
commands:
- echo '+++ yarn test:ci'
- yarn test:ci
- echo '+++ yarn lint'
- echo '--- yarn lint'
- yarn lint
plugins:
- *aws-sm
- *docker-ecr-cache
- docker-compose#v3.7.0:
run: app

- wait
- block: 🙋🏻‍♀️ Deploy Dev
branches: '!master'

Expand Down

0 comments on commit e9a71d4

Please sign in to comment.