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

refactor: Migrate to orb tools 11 config #43

Merged
merged 5 commits into from
Oct 7, 2022
Merged
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
119 changes: 26 additions & 93 deletions .circleci/config.yml
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,102 +1,35 @@
version: 2.1

setup: true
orbs:
sam: circleci/aws-sam-serverless@<<pipeline.parameters.dev-orb-version>>
orb-tools: circleci/orb-tools@10.0

# Pipeline Parameters
## These parameters are used internally by orb-tools. Skip to the Jobs section.
parameters:
run-integration-tests:
description: An internal flag to prevent integration test from running before a development version has been created.
type: boolean
default: false
dev-orb-version:
description: >
The development version of the orb to test.
This value is automatically adjusted by the "trigger-integration-tests-workflow" job to correspond with the specific version created by the commit and should not be edited.
A "dev:alpha" version must exist for the initial pipeline run.
type: string
default: "dev:alpha"
orb-tools: circleci/orb-tools@11.1
shellcheck: circleci/shellcheck@3.1

jobs:
# Define one or more jobs which will utilize your orb's commands and parameters to validate your changes.
test_local_invoke:
machine:
image: ubuntu-2004:202101-01
steps:
- checkout
- sam/install:
version: v1.23.0 # Fixed until sam-cli issue is resolved https://github.com/aws/aws-sam-cli/issues/2927
- sam/local-start-api:
template: "./sample_test/sam-app/template.yaml"
endpoint: "hello"
filters: &filters
tags:
only: /.*/

workflows:
# Prior to producing a development orb (which requires credentials) basic validation, linting, and even unit testing can be performed.
# This workflow will run on every commit
test-pack:
unless: << pipeline.parameters.run-integration-tests >>
lint-pack:
jobs:
- orb-tools/lint # Lint Yaml files
- orb-tools/pack # Pack orb source
# Publish development version(s) of the orb.
- orb-tools/publish-dev:
- orb-tools/lint:
filters: *filters
- orb-tools/pack:
filters: *filters
- orb-tools/review:
filters: *filters
- shellcheck/check:
filters: *filters
- orb-tools/publish:
orb-name: circleci/aws-sam-serverless
context: orb-publisher # A restricted context containing your private publishing credentials. Will only execute if approved by an authorized user.
requires:
- orb-tools/lint
- orb-tools/pack
# Trigger an integration workflow to test the
# dev:${CIRCLE_SHA1:0:7} version of your orb
- orb-tools/trigger-integration-tests-workflow:
name: trigger-integration-dev
context: orb-publisher
vcs-type: << pipeline.project.type >>
requires:
- orb-tools/publish-dev

# This `integration-test_deploy` workflow will only run
# when the run-integration-tests pipeline parameter is set to true.
# It is meant to be triggered by the "trigger-integration-tests-workflow"
# job, and run tests on <your orb>@dev:${CIRCLE_SHA1:0:7}.
integration-test_deploy:
when: << pipeline.parameters.run-integration-tests >>
jobs:
# Run any integration tests defined within the `jobs` key.
- test_local_invoke:
context: [CPE_ORBS_AWS]
- sam/deploy:
capabilities: CAPABILITY_IAM, CAPABILITY_NAMED_IAM
name: deploy-job-test-app
template: "./sample_test/sam-app/template.yaml"
stack-name: "orb-deploy-job-test-1"
s3-bucket: "sam-orb-testing"
context: [CPE_ORBS_AWS]
# python_version: "3.7.0" not used in container builds, adds significant time to job
- sam/deploy:
capabilities: CAPABILITY_IAM, CAPABILITY_NAMED_IAM
name: deploy-job-test-container
template: "./sample_test/sam-container/template.yaml"
stack-name: "orb-deploy-job-test-2"
image-repositories: $DEMO_IMG_URI
context: [CPE_ORBS_AWS]
validate: false
# python_version: "3.7.0" not used in container builds, adds significant time to job
# Publish a semver version of the orb. relies on
# the commit subject containing the text "[semver:patch|minor|major|skip]"
# as that will determine whether a patch, minor or major
# version will be published or if publishing should
# be skipped.
# e.g. [semver:patch] will cause a patch version to be published.
- orb-tools/dev-promote-prod-from-commit-subject:
orb-name: circleci/aws-sam-serverless
bot-token-variable: GHI_TOKEN
[orb-tools/lint, orb-tools/review, orb-tools/pack, shellcheck/check]
# Use a context to hold your publishing token.
context: orb-publisher
add-pr-comment: false
fail-if-semver-not-indicated: true
publish-version-tag: false
requires:
- test_local_invoke
filters:
branches:
only: master
filters: *filters
# Triggers the next workflow in the Orb Development Kit.
- orb-tools/continue:
pipeline-number: << pipeline.number >>
vcs-type: << pipeline.project.type >>
requires: [orb-tools/publish]
filters: *filters
60 changes: 60 additions & 0 deletions .circleci/test-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
version: 2.1
orbs:
sam: circleci/aws-sam-serverless@dev:<<pipeline.git.revision>>
orb-tools: circleci/orb-tools@11.1
filters: &filters
tags:
only: /.*/
jobs:
# Define one or more jobs which will utilize your orb's commands and parameters to validate your changes.
test_local_invoke:
machine:
image: ubuntu-2004:202101-01
steps:
- checkout
- sam/install:
version: 1.57.0
- sam/local-start-api:
template: "./sample_test/sam-app/template.yaml"
endpoint: "hello"
workflows:
test-deploy:
jobs:
# Make sure to include "filters: *filters" in every test job you want to run as part of your deployment.
- test_local_invoke:
context: [CPE_ORBS_AWS]
filters: *filters
- sam/deploy:
capabilities: CAPABILITY_IAM, CAPABILITY_NAMED_IAM
name: deploy-job-test-app
template: "./sample_test/sam-app/template.yaml"
stack-name: "orb-deploy-job-test-1"
s3-bucket: "sam-orb-testing"
context: [CPE_ORBS_AWS]
filters: *filters
- sam/deploy:
capabilities: CAPABILITY_IAM, CAPABILITY_NAMED_IAM
name: deploy-job-test-container
template: "./sample_test/sam-container/template.yaml"
stack-name: "orb-deploy-job-test-2"
image-repositories: $DEMO_IMG_URI
context: [CPE_ORBS_AWS]
validate: false
filters: *filters
- orb-tools/pack:
filters: *filters
- orb-tools/publish:
orb-name: circleci/aws-sam-serverless
vcs-type: << pipeline.project.type >>
pub-type: production
requires:
- orb-tools/pack
- test_local_invoke
- deploy-job-test-app
- deploy-job-test-container
context: orb-publisher
filters:
branches:
ignore: /.*/
tags:
only: /^v[0-9]+\.[0-9]+\.[0-9]+$/
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"yaml.schemas": {
"https://json.schemastore.org/circleciconfig.json": "file:///Users/kyletryon/Documents/Projects/aws-sam-serverless-orb/src/jobs/deploy.yml"
}
}
7 changes: 7 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends: relaxed

rules:
line-length:
max: 200
allow-non-breakable-inline-mappings: true

2 changes: 1 addition & 1 deletion sample_test/sam-app/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Resources:
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python3.6
Runtime: python3.9
Events:
HelloWorld:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Expand Down
Loading