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

chore(ci): Refactor the ci pipeline to improve dry-ness #251

Merged
merged 1 commit into from
Jul 9, 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: 0 additions & 7 deletions ci/partials/build.yml

This file was deleted.

7 changes: 0 additions & 7 deletions ci/partials/install-dependencies.yml

This file was deleted.

94 changes: 45 additions & 49 deletions ci/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
---
#@ load("funcs.lib.yml", "slack_hook")
#@ load("funcs.lib.yml", "slack_hook", "pr_hook")
#@ load("@ytt:data", "data")
#@ load("@ytt:template", "template")

#@ env = data.values.env

#! SHARED

test-redirects: &test-redirects
- task: install-dependencies
image: node
file: src/ci/partials/install-dependencies.yml
file: pipeline-tasks/tasks/run-command.yml
params:
COMMAND: npm install

- task: build
image: node
file: src/ci/partials/build.yml
file: pipeline-tasks/tasks/run-command.yml
params:
COMMAND: npm run build

- task: test-redirects
image: dind
Expand All @@ -22,52 +28,56 @@ test-redirects: &test-redirects
#! JOBS

jobs:
- name: test-redirects-pull-request
- name: set-pipeline
plan:
- get: src
params:
#@ if/end env != 'test':
params: { depth: 1 }
#@ if/end env == 'test':
integration_tool: checkout
trigger: true
- get: pipeline-tasks
- get: general-task
- task: boot
image: general-task
file: pipeline-tasks/tasks/boot.yml
params:
ENV_OVERRIDE: ((deploy-env))
- set_pipeline: self
file: compiled/set-pipeline.yml
instance_vars:
deploy-env: ((deploy-env))

#@ if/end env == 'test':
- name: test-redirects
plan:
- get: src
passed: [set-pipeline]
resource: pr
trigger: true
version: every
- put: src
resource: pr
params:
path: src
status: pending
base_context: concourse
context: test-pull-request
- #@ pr_hook("pending", "run-tests")
- get: pipeline-tasks
- get: node
- get: dind
- do: *test-redirects

on_failure:
in_parallel:
- put: src
resource: pr
params:
path: src
status: failure
base_context: concourse
context: test-pull-request
- #@ pr_hook("failure", "run-tests")
- #@ slack_hook("failure", "tests")

on_success:
in_parallel:
- put: src
resource: pr
params:
path: src
status: success
base_context: concourse
context: test-pull-request
- #@ pr_hook("success", "run-tests")
- #@ slack_hook("success", "tests")

#@ if env == 'deploy':
- name: test-and-deploy-redirects
plan:
- get: src
resource: src
passed: [set-pipeline]
trigger: true
params: { depth: 1 }
- get: pipeline-tasks
- get: general-task
- get: node
Expand All @@ -91,11 +101,10 @@ jobs:
on_failure: #@ slack_hook("failure", "deployment")
on_success: #@ slack_hook("success", "deployment")

- name: nightly-restage-redirects
- name: nightly-restage
plan:
- get: src
resource: src
params: { depth: 1 }
passed: [set-pipeline]
- get: nightly
trigger: true
- get: general-task
Expand All @@ -105,28 +114,13 @@ jobs:
file: pipeline-tasks/tasks/restage.yml
params:
_: #@ template.replace(data.values.env_cf_redirects)

- name: set-pipeline
plan:
- 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: compiled/set-pipeline.yml
instance_vars:
deploy-env: ((deploy-env))
#@ end

#! RESOURCES

resources:
- name: pr
#@ if/end env == 'test':
- name: src
type: pull-request
check_every: 1m
source:
Expand All @@ -136,6 +130,7 @@ resources:
disable_forks: true
ignore_drafts: false

#@ if env == 'deploy':
- name: src
type: git
icon: github
Expand All @@ -150,6 +145,7 @@ resources:
start: 12:00 AM
stop: 1:00 AM
location: America/New_York
#@ end

- name: slack
- name: node
Expand Down