-
Notifications
You must be signed in to change notification settings - Fork 9
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: implement tag-based deployment #2213
Changes from all commits
2d4a46b
29dc273
41cd38b
395b249
1b141fd
6921e20
d3aa8c8
8910c31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
.git/ | ||
.github/ | ||
.vscode/ | ||
**/__pycache__/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: Cypress tests | ||
|
||
on: push | ||
on: [push, workflow_call] | ||
|
||
defaults: | ||
run: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: Pytest | ||
|
||
on: [push, pull_request] | ||
on: [push, pull_request, workflow_call] | ||
|
||
jobs: | ||
pytest: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
name: UI & a11y tests | ||
|
||
on: | ||
workflow_call: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: [main, test, prod] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ trigger: | |
branches: | ||
include: | ||
- main | ||
- test | ||
- prod | ||
- refs/tags/20??.??.?*-rc?* | ||
- refs/tags/20??.??.?* | ||
# only run for changes to Terraform files | ||
paths: | ||
include: | ||
|
@@ -26,8 +26,14 @@ stages: | |
value: $[variables['Build.SourceBranchName']] | ||
- name: TARGET | ||
value: $[variables['System.PullRequest.TargetBranch']] | ||
- name: IS_TAG | ||
value: $[startsWith(variables['Build.SourceBranch'], 'refs/tags/')] | ||
steps: | ||
- bash: python terraform/pipeline/workspace.py | ||
- bash: | | ||
python terraform/pipeline/workspace.py | ||
|
||
TAG_TYPE=$(python terraform/pipeline/tag.py) | ||
echo "##vso[task.setvariable variable=tag_type;isOutput=true]$TAG_TYPE" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These lines could be normalized to move the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. Great, I'll create an issue to come back to this later. |
||
displayName: Set environment-related variables | ||
# save the values | ||
# https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#use-outputs-in-a-different-job | ||
|
@@ -39,18 +45,22 @@ stages: | |
condition: eq(dependencies.environment.outputs['env_select.service_connection'], 'Development') | ||
variables: | ||
workspace: $[ dependencies.environment.outputs['env_select.workspace'] ] | ||
tag_type: $[ dependencies.environment.outputs['env_select.tag_type'] ] | ||
steps: | ||
- template: pipeline/deploy.yml | ||
parameters: | ||
service_connection: Development | ||
workspace: $(workspace) | ||
tag_type: $(tag_type) | ||
- job: prod | ||
dependsOn: environment | ||
condition: eq(dependencies.environment.outputs['env_select.service_connection'], 'Production') | ||
variables: | ||
workspace: $[ dependencies.environment.outputs['env_select.workspace'] ] | ||
tag_type: $[ dependencies.environment.outputs['env_select.tag_type'] ] | ||
steps: | ||
- template: pipeline/deploy.yml | ||
parameters: | ||
service_connection: Production | ||
workspace: $(workspace) | ||
tag_type: $(tag_type) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
import re | ||
|
||
REASON = os.environ["REASON"] | ||
# use variable corresponding to tag triggers | ||
SOURCE = os.environ["INDIVIDUAL_SOURCE"] | ||
IS_TAG = os.environ["IS_TAG"].lower() == "true" | ||
|
||
if REASON == "IndividualCI" and IS_TAG: | ||
if re.fullmatch(r"20\d\d.\d\d.\d+-rc\d+", SOURCE): | ||
tag_type = "test" | ||
elif re.fullmatch(r"20\d\d.\d\d.\d+", SOURCE): | ||
tag_type = "prod" | ||
else: | ||
tag_type = None | ||
else: | ||
tag_type = None | ||
|
||
print(tag_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised we didn't need to change this line so that the
workspace
variable on line 47 is set correctly, but it seems to be working - the workspace was selected correctly in the pipeline runs for this branch.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's probably because this line didn't change, in that the
workspace
is still set as an output variable byworkspace.py
: https://github.com/cal-itp/benefits/pull/2213/files/f4304d09dd1bf08a2797f165ba7d603cd0743a48#diff-33a8fda4d235c86352a2629618f4d0829b626df6084edef709ad22d97e8f80fcR52