Skip to content

Commit

Permalink
adding ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Long Nguyen authored and Long Nguyen committed Mar 25, 2021
1 parent 5cd3021 commit e74c19d
Show file tree
Hide file tree
Showing 5 changed files with 612 additions and 0 deletions.
361 changes: 361 additions & 0 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,361 @@
---
#
# ci/pipeline.yml
#
# Pipeline structure file for a Go Project pipeline
#
# DO NOT MAKE CHANGES TO THIS FILE. Instead, modify
# ci/settings.yml and override what needs overridden.
# This uses spruce, so you have some options there.
#
# author: James Hunt <[email protected]>
# created: 2016-03-30

meta:
name: (( param "Please name your pipeline" ))
release: (( concat meta.name " Release" ))
target: (( param "Please identify the name of the target Concourse CI" ))
pipeline: (( grab meta.name ))

git:
email: (( param "Please provide the git email for automated commits" ))
name: (( param "Please provide the git name for automated commits" ))

go:
version: 1.13
module: (( concat "github.com/" meta.github.owner "/" meta.github.repo ))
cmd_module: (( grab meta.go.module ))
binary: (( grab meta.github.repo ))
force_static_binary: false

image:
name: starkandwayne/concourse-go
tag: (( grab meta.go.version ))

aws:
bucket: (( concat meta.pipeline "-pipeline" ))
region_name: us-east-1
access_key: (( param "Please set your AWS Access Key ID" ))
secret_key: (( param "Please set your AWS Secret Key ID" ))

github:
uri: (( concat "[email protected]:" meta.github.owner "/" meta.github.repo ))
owner: (( param "Please specify the name of the user / organization that owns the Github repository" ))
repo: (( param "Please specify the name of the Github repository" ))
branch: master
private_key: (( param "Please generate an SSH Deployment Key for this repo and specify it here" ))
access_token: (( param "Please generate a Personal Access Token and specify it here" ))

slack:
webhook: (( param "Please specify your Slack Incoming Webhook Integration URL" ))
notification: '(( concat ":sadpanda: " meta.pipeline " build failed!<br>URL-GOES-HERE" ))'
channel: (( param "Please specify the channel (#name) or user (@user) to send messages to" ))
username: concourse
icon: http://cl.ly/image/3e1h0H3H2s0P/concourse-logo.png
fail_moji: ":airplane_arriving:"
success_moji: ":airplane_departure:"
upset_moji: ":sad_panda:"
fail_url: '(( concat "<" meta.url "/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME| Concourse Failure! " meta.slack.upset_moji ">" ))'

url: (( param "What is the URL for the Concourse instance this pipeline is located on?" ))

groups:
- name: (( grab meta.pipeline ))
jobs:
- test
- test-pr
- rc
- shipit
- major
- minor
- bump-patch

jobs:
- name: test
public: true
serial: true
plan:
- do:
- { get: git, trigger: true }
- task: test
config:
platform: linux
image_resource:
type: docker-image
source:
repository: (( grab meta.image.name ))
tag: (( grab meta.image.tag ))
inputs:
- name: git
path: (( concat "gopath/src/" meta.go.module ))
run:
path: (( concat "./gopath/src/" meta.go.module "/ci/scripts/test" ))
args: []
params:
MODULE: (( grab meta.go.module ))
on_failure:
put: notify
params:
channel: (( grab meta.slack.channel ))
username: (( grab meta.slack.username ))
icon_url: (( grab meta.slack.icon ))
text: '(( concat meta.slack.fail_url " " meta.pipeline ": test job failed" ))'

- name: test-pr
public: true
serial: true
plan:
- do:
- { get: git-pull-requests, trigger: true, version: every }
- put: git-pull-requests
params:
path: git-pull-requests
status: pending
- task: test
config:
platform: linux
image_resource:
type: docker-image
source:
repository: (( grab meta.image.name ))
tag: (( grab meta.image.tag ))
inputs:
- name: git-pull-requests
path: (( concat "gopath/src/" meta.go.module ))
run:
path: (( concat "./gopath/src/" meta.go.module "/ci/scripts/test" ))
args: []
params:
MODULE: (( grab meta.go.module ))
on_success:
put: git-pull-requests
params:
path: git-pull-requests
status: success
on_failure:
put: git-pull-requests
params:
path: git-pull-requests
status: failure
- task: pr-success-message
config:
platform: linux
image_resource:
type: docker-image
source:
repository: (( grab meta.image.name ))
tag: (( grab meta.image.tag ))
inputs:
- { name: git-pull-requests }
outputs:
- { name: message }
run:
path: sh
args:
- -ce
- |
cd git-pull-requests
pr_url=$(git config --get pullrequest.url)
cd -
echo "<${pr_url}|Pull request passed test> Merge when ready: ${pr_url}" > message/body
on_failure:
put: notify
params:
channel: (( grab meta.slack.channel ))
username: (( grab meta.slack.username ))
icon_url: (( grab meta.slack.icon ))
text: '(( concat meta.slack.fail_url " " meta.pipeline ": test job failed" ))'

- name: rc
public: true
plan:
- do:
- in_parallel:
- { get: git, trigger: true, passed: [test] }
- { get: version, trigger: true, params: {pre: rc} }
- put: shipit-version
params: {file: version/number}
on_failure:
put: notify
params:
channel: (( grab meta.slack.channel ))
username: (( grab meta.slack.username ))
icon_url: (( grab meta.slack.icon ))
text: '(( concat meta.slack.fail_url " " meta.pipeline ": rc job failed" ))'

- name: bump-patch
public: true
plan:
- do:
- { get: version, trigger: true, params: { bump: patch, pre: rc }, passed: [shipit] } # bump rc + patch, so that subesquent version bumps can trigger a new bump-patch
- { put: version, params: { file: version/number} }
on_failure:
put: notify
params:
channel: (( grab meta.slack.channel ))
username: (( grab meta.slack.username ))
icon_url: (( grab meta.slack.icon ))
text: '(( concat meta.slack.fail_url " " meta.pipeline ": bump-patch job failed" ))'

- name: minor
public: true
plan:
- do:
- { get: version, trigger: false, params: {bump: minor} }
- { put: version, params: {file: version/number} }
on_failure:
put: notify
params:
channel: (( grab meta.slack.channel ))
username: (( grab meta.slack.username ))
icon_url: (( grab meta.slack.icon ))
text: '(( concat meta.slack.fail_url " " meta.pipeline ": minor job failed" ))'

- name: major
public: true
plan:
- do:
- { get: version, trigger: false, params: {bump: major} }
- { put: version, params: {file: version/number} }
on_failure:
put: notify
params:
channel: (( grab meta.slack.channel ))
username: (( grab meta.slack.username ))
icon_url: (( grab meta.slack.icon ))
text: '(( concat meta.slack.fail_url " " meta.pipeline ": major job failed" ))'

- name: shipit
public: true
serial: true
plan:
- do:
- in_parallel:
- { get: version, resource: shipit-version, passed: [rc], params: {bump: final} }
- { get: git, passed: [rc] }
- task: release
config:
image_resource:
type: docker-image
source:
repository: (( grab meta.image.name ))
tag: (( grab meta.image.tag ))
platform: linux
inputs:
- name: version
- name: git
path: (( concat "gopath/src/" meta.go.module ))
outputs:
- name: gh
- name: pushme
run:
path: (( concat "./gopath/src/" meta.go.module "/ci/scripts/shipit" ))
args: []
params:
BINARY: (( grab meta.go.binary ))
REPO_ROOT: (( concat "gopath/src/" meta.go.module ))
VERSION_FROM: version/number
RELEASE_NAME: (( grab meta.release ))
RELEASE_ROOT: gh
REPO_OUT: pushme
BRANCH: (( grab meta.github.branch ))
CMD_PKG: (( grab meta.go.cmd_module ))
STATIC_BINARY: (( grab meta.go.force_static_binary ))
GIT_EMAIL: (( grab meta.git.email ))
GIT_NAME: (( grab meta.git.name ))
- put: version
params: { bump: final }
- put: git
params:
rebase: true
repository: pushme/git
- put: github
params:
name: gh/name
tag: gh/tag
body: gh/notes.md
globs: [gh/artifacts/*]
- in_parallel:
- put: notify
params:
channel: (( grab meta.slack.channel ))
username: (( grab meta.slack.username ))
icon_url: (( grab meta.slack.icon ))
#I want this to actually print out the safe version, but for now.... may as well print _something_
#text_file: notifications/message
text: A new version of safe was released!
on_failure:
put: notify
params:
channel: (( grab meta.slack.channel ))
username: (( grab meta.slack.username ))
icon_url: (( grab meta.slack.icon ))
text: '(( concat meta.slack.fail_url " " meta.pipeline ": shipit job failed" ))'

resource_types:
- name: slack-notification
type: docker-image
source:
repository: cfcommunity/slack-notification-resource

- name: pull-request
type: docker-image
source:
repository: jtarchie/pr

resources:
- name: git
type: git
check_every: 60m
webhook_token: ((webhook.token))
source:
uri: (( grab meta.github.uri ))
branch: (( grab meta.github.branch ))
private_key: (( grab meta.github.private_key ))

- name: version
type: semver
source :
driver: s3
bucket: (( grab meta.aws.bucket ))
region_name: (( grab meta.aws.region_name ))
key: version
access_key_id: (( grab meta.aws.access_key ))
secret_access_key: (( grab meta.aws.secret_key ))
initial_version: (( grab meta.initial_version || "0.0.1" ))

- name: shipit-version
type: semver
source :
driver: s3
bucket: (( grab meta.aws.bucket ))
region_name: (( grab meta.aws.region_name ))
key: shipit-version
access_key_id: (( grab meta.aws.access_key ))
secret_access_key: (( grab meta.aws.secret_key ))
initial_version: (( grab meta.initial_version || "0.0.1" ))

- name: notify
check_every: 24h
type: slack-notification
source:
url: (( grab meta.slack.webhook ))

- name: github
type: github-release
check_every: 60m
webhook_token: ((webhook.token))
source:
user: (( grab meta.github.owner ))
repository: (( grab meta.github.repo ))
access_token: (( grab meta.github.access_token ))

- name: git-pull-requests
type: pull-request
check_every: 60m
webhook_token: ((webhook.token))
source:
access_token: (( grab meta.github.access_token ))
private_key: (( grab meta.github.private_key ))
repo: (( concat meta.github.owner "/" meta.github.repo ))
base: (( grab meta.github.branch ))
Loading

0 comments on commit e74c19d

Please sign in to comment.