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

Add refactored CI pipeline #250

Merged
merged 1 commit into from
Jun 25, 2024
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
7 changes: 7 additions & 0 deletions ci/partials/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
platform: linux
inputs: [name: src]
outputs: [name: src]
run:
dir: src
path: bash
args: [-c, npm run build]
4 changes: 4 additions & 0 deletions ci/partials/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
platform: linux
inputs: [name: src]
run:
path: src/ci/tasks/deploy.sh
7 changes: 7 additions & 0 deletions ci/partials/install-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
platform: linux
inputs: [name: src]
outputs: [name: src]
run:
dir: src
path: bash
args: [-c, npm install]
15 changes: 15 additions & 0 deletions ci/partials/test-redirects.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
platform: linux
inputs:
- name: src
run:
dir: src
path: ci/docker/entrypoint.sh
args:
- bash
- -ceux
- |
docker network prune -f
docker-compose run test_client yarn test-integration
docker-compose stop
docker-compose down
docker network prune -f
239 changes: 54 additions & 185 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,88 +1,25 @@
############################
# SHARED
---
#@ load("funcs.lib.yml", "slack_hook")
#@ load("@ytt:data", "data")
#@ load("@ytt:template", "template")

env-cf: &env-cf
CF_API: https://api.fr.cloud.gov
CF_USERNAME: ((redirects-cf-username))
CF_PASSWORD: ((redirects-cf-password))
CF_ORG: gsa-18f-federalist
CF_SPACE: redirects
CF_APP_NAME: pages-redirects
CF_STACK: cflinuxfs4

node-image: &node-image
platform: linux
image_resource:
type: registry-image
source:
aws_access_key_id: ((ecr-aws-key))
aws_secret_access_key: ((ecr-aws-secret))
repository: pages-node-v20
aws_region: us-gov-west-1
tag: latest

cf-image: &cf-image
platform: linux
image_resource:
type: registry-image
source:
aws_access_key_id: ((ecr-aws-key))
aws_secret_access_key: ((ecr-aws-secret))
repository: general-task
aws_region: us-gov-west-1
tag: latest
#! SHARED

test-redirects: &test-redirects
- task: install-dependencies
config:
<<: *node-image
inputs: [name: src]
outputs: [name: src]
run:
dir: src
path: bash
args: [-c, npm install]
image: node
file: src/ci/partials/install-dependencies.yml

- task: build
config:
<<: *node-image
inputs: [name: src]
outputs: [name: src]
run:
dir: src
path: bash
args: [-c, npm run build]
image: node
file: src/ci/partials/build.yml

- in_parallel:
- task: test-redirects
privileged: true
config:
platform: linux
image_resource:
type: registry-image
source:
aws_access_key_id: ((ecr-aws-key))
aws_secret_access_key: ((ecr-aws-secret))
repository: pages-dind-v25
aws_region: us-gov-west-1
tag: latest
inputs:
- name: src
run:
dir: src
path: ci/docker/entrypoint.sh
args:
- bash
- -ceux
- |
docker network prune -f
docker-compose run test_client yarn test-integration
docker-compose stop
docker-compose down
docker network prune -f
- task: test-redirects
image: dind
privileged: true
file: src/ci/partials/test-redirects.yml

############################
# JOBS
#! JOBS

jobs:
- name: test-redirects-pull-request
Expand All @@ -99,6 +36,8 @@ jobs:
status: pending
base_context: concourse
context: test-pull-request
- get: node
- get: dind
- do: *test-redirects

on_failure:
Expand All @@ -110,14 +49,7 @@ jobs:
status: failure
base_context: concourse
context: test-pull-request
- put: slack
params:
text: |
:x: FAILED: pages redirects tests on PR into main
<$ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME/"|View build details>
channel: ((slack-channel))
username: ((slack-username))
icon_url: ((slack-icon-url))
- #@ slack_hook("failure", "tests")

on_success:
in_parallel:
Expand All @@ -128,64 +60,36 @@ jobs:
status: success
base_context: concourse
context: test-pull-request
- put: slack
params:
text: |
:white_check_mark: SUCCESS: Successfully tested pages redirects on PR into main
<$ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME/"|View build details>
channel: ((slack-channel))
username: ((slack-username))
icon_url: ((slack-icon-url))
- #@ slack_hook("success", "tests")

- name: test-and-deploy-redirects
plan:
- get: src
resource: src
trigger: true
params: { depth: 1 }
- get: pipeline-tasks
- get: general-task
- get: node
- get: dind
- do: *test-redirects

- task: deploy
config:
<<: *cf-image
inputs: [name: src]
run:
path: src/ci/tasks/deploy.sh
image: general-task
file: src/ci/partials/deploy.yml
params:
<<: *env-cf
_: #@ template.replace(data.values.env_cf_redirects)
CF_MANIFEST: src/out/manifest-prod.yml
CF_PATH: src/out
on_failure:
try:
task: cancel-api-deployment
config:
<<: *cf-image
inputs: [name: src]
run:
path: src/ci/tasks/cancel-deployment.sh
image: general-task
file: pipeline-tasks/tasks/cancel-deployment.yml
params:
<<: *env-cf
_: #@ template.replace(data.values.env_cf_redirects)

on_failure:
in_parallel:
- put: slack
params:
text: |
:x: FAILED: deployment of pages redirects
<$ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME/"|View build details>
channel: ((slack-channel))
username: ((slack-username))
icon_url: ((slack-icon-url))
on_success:
in_parallel:
- put: slack
params:
text: |
:white_check_mark: SUCCESS: Successfully deployed pages redirects
<$ATC_EXTERNAL_URL/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME/"|View build details>
channel: ((slack-channel))
username: ((slack-username))
icon_url: ((slack-icon-url))
on_failure: #@ slack_hook("failure", "deployment")
on_success: #@ slack_hook("success", "deployment")

- name: nightly-restage-redirects
plan:
Expand All @@ -194,26 +98,32 @@ jobs:
params: { depth: 1 }
- get: nightly
trigger: true
- in_parallel:
- task: restage
config:
inputs: [name: src]
<<: *cf-image
run:
path: src/ci/tasks/restage.sh
params:
<<: *env-cf
- get: general-task
- get: pipeline-tasks
- task: restage
image: general-task
file: pipeline-tasks/tasks/restage.yml
params:
_: #@ template.replace(data.values.env_cf_redirects)

- name: set-pipeline
plan:
- get: pr
- get: src
resource: pr
trigger: true
- get: pipeline-tasks
- get: general-task
- task: init
image: general-task
file: pipeline-tasks/tasks/init.yml
params:
PIPELINE_YML: src/ci/pipeline.yml
- set_pipeline: redirects
file: pr/ci/pipeline.yml
file: compiled/set-pipeline.yml
instance_vars:
deploy-env: ((deploy-env))

############################
# RESOURCES
#! RESOURCES

resources:
- name: pr
Expand Down Expand Up @@ -242,57 +152,16 @@ resources:
location: America/New_York

- name: slack
type: slack-notification
source:
url: ((slack-webhook-url))

- name: node
- name: general-task
- name: dind
- name: pipeline-tasks

############################
# RESOURCE TYPES
#! RESOURCE TYPES

resource_types:

- name: git
type: registry-image
source:
aws_access_key_id: ((ecr_aws_key))
aws_secret_access_key: ((ecr_aws_secret))
repository: git-resource
aws_region: us-gov-west-1
tag: latest

- name: slack-notification
type: registry-image
source:
aws_access_key_id: ((ecr_aws_key))
aws_secret_access_key: ((ecr_aws_secret))
repository: slack-notification-resource
aws_region: us-gov-west-1
tag: latest

- name: pull-request
type: registry-image
source:
aws_access_key_id: ((ecr_aws_key))
aws_secret_access_key: ((ecr_aws_secret))
repository: github-pr-resource
aws_region: us-gov-west-1
tag: latest

- name: time
type: registry-image
source:
aws_access_key_id: ((ecr_aws_key))
aws_secret_access_key: ((ecr_aws_secret))
repository: time-resource
aws_region: us-gov-west-1
tag: latest

- name: registry-image
type: registry-image
source:
aws_access_key_id: ((ecr_aws_key))
aws_secret_access_key: ((ecr_aws_secret))
repository: registry-image-resource
aws_region: us-gov-west-1
tag: latest
10 changes: 0 additions & 10 deletions ci/tasks/cancel-deployment.sh

This file was deleted.

10 changes: 0 additions & 10 deletions ci/tasks/restage.sh

This file was deleted.