Skip to content

Commit

Permalink
updates: fixes and renames (#106)
Browse files Browse the repository at this point in the history
* updates: fixes and renames

* updates: lint

---------

Co-authored-by: Emma Doyle <[email protected]>
  • Loading branch information
emmeowzing and Emma Doyle authored Dec 20, 2023
1 parent b1f5f2a commit f0060f7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
9 changes: 6 additions & 3 deletions src/commands/filter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ parameters:
description: Forcibly build all the modules
type: boolean
default: false
default-branch:
base-revision:
description: The default branch of the repository.
type: string
default: main
Expand Down Expand Up @@ -59,7 +59,10 @@ parameters:
project-type:
description: Can be either GitHub (gh), GitLab, or BitBucket (bb).
type: enum
enum: [github, gitlab, bitbucket]
enum:
- github
- gitlab
- bitbucket
default: github
cache:
description: Whether or not to cache (i.e. you're calling these commands in your own job, not 'continue').
Expand All @@ -76,7 +79,7 @@ steps:
SH_AUTO_DETECT: << parameters.auto-detect >>
SH_CIRCLE_ORGANIZATION: << parameters.circle-organization >>
SH_CIRCLE_TOKEN: << parameters.circle-token >>
SH_DEFAULT_BRANCH: << parameters.default-branch >>
SH_DEFAULT_BRANCH: << parameters.base-revision >>
SH_DYNAMIC_CONTINUATION_DEBUG: << parameters.debug >>
SH_FORCE_ALL: << parameters.force-all >>
SH_INCLUDE_CONFIG_CHANGES: << parameters.include-config-changes >>
Expand Down
5 changes: 4 additions & 1 deletion src/commands/reduce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ parameters:
project-type:
description: Can be either GitHub (gh) or BitBucket (bb).
type: enum
enum: [github, gitlab, bitbucket]
enum:
- github
- gitlab
- bitbucket
default: github
circle-token:
description: Token to authenticate with CircleCI
Expand Down
16 changes: 12 additions & 4 deletions src/jobs/continue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ parameters:
default: python
resource-class:
type: enum
enum: [small, medium, large, xlarge, 2xlarge]
enum:
- small
- medium
- large
- xlarge
- 2xlarge
default: small
description: Resource class to run this job with.

Expand All @@ -26,7 +31,7 @@ parameters:
description: Forcibly run all modules.
type: boolean
default: false
default-branch:
base-revision:
description: Default branch of the repository.
type: string
default: main
Expand Down Expand Up @@ -80,7 +85,10 @@ parameters:
project-type:
description: Can be either GitHub (github), GitLab (gitlab), or BitBucket (bitbucket).
type: enum
enum: [github, gitlab, bitbucket]
enum:
- github
- gitlab
- bitbucket
default: github
jq-version:
description:
Expand Down Expand Up @@ -154,7 +162,7 @@ steps:
modules: << parameters.modules >>
modules-filtered: << parameters.modules-filtered >>
force-all: << parameters.force-all >>
default-branch: << parameters.default-branch >>
base-revision: << parameters.base-revision >>
root-config: << parameters.root-config >>
reporting-window: << parameters.reporting-window >>
circle-organization: << parameters.circle-organization >>
Expand Down
20 changes: 8 additions & 12 deletions src/scripts/filter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,16 @@ debug()


# Parse environment variables referencing env vars set by CircleCI.
if [ "${SH_CIRCLE_TOKEN:0:1}" = '$' ]; then
_CIRCLE_TOKEN="$(eval echo "$SH_CIRCLE_TOKEN")"
else
_CIRCLE_TOKEN="$SH_CIRCLE_TOKEN"
fi
while [ "${SH_CIRCLE_TOKEN:0:1}" = '$' ]; do
SH_CIRCLE_TOKEN="$(eval echo "$SH_CIRCLE_TOKEN")"
done

if [ "${SH_CIRCLE_ORGANIZATION:0:1}" = '$' ]; then
_CIRCLE_ORGANIZATION="$(eval echo "$SH_CIRCLE_ORGANIZATION")"
else
_CIRCLE_ORGANIZATION="$SH_CIRCLE_ORGANIZATION"
fi
while [ "${SH_CIRCLE_ORGANIZATION:0:1}" = '$' ]; do
SH_CIRCLE_ORGANIZATION="$(eval echo "$SH_CIRCLE_ORGANIZATION")"
done

# CircleCI API token should be set.
if [ -z "$_CIRCLE_TOKEN" ]; then
if [ -z "$SH_CIRCLE_TOKEN" ]; then
error "must set CircleCI token for successful authentication."
exit 1
fi
Expand Down Expand Up @@ -105,7 +101,7 @@ fi


# Add each module to `modules-filtered` if 1) `force-all` is set to `true`, or 2) there is a diff against main at HEAD, or 3) no workflow runs have occurred on the default branch for this project in the past $SH_REPORTING_WINDOW days.
if [ "$SH_FORCE_ALL" -eq 1 ] || { [ "$SH_REPORTING_WINDOW" != "" ] && [ "$(curl -s -X GET --url "https://circleci.com/api/v2/insights/${SH_PROJECT_TYPE}/${_CIRCLE_ORGANIZATION}/${CIRCLE_PROJECT_REPONAME}/workflows?reporting-window=${SH_REPORTING_WINDOW}" --header "Circle-Token: ${_CIRCLE_TOKEN}" | jq -r "[ .items[].name ] | length")" -eq "0" ]; }; then
if [ "$SH_FORCE_ALL" -eq 1 ] || { [ "$SH_REPORTING_WINDOW" != "" ] && [ "$(curl -s -X GET --url "https://circleci.com/api/v2/insights/${SH_PROJECT_TYPE}/${SH_CIRCLE_ORGANIZATION}/${CIRCLE_PROJECT_REPONAME}/workflows?reporting-window=${SH_REPORTING_WINDOW}" --header "Circle-Token: ${SH_CIRCLE_TOKEN}" | jq -r "[ .items[].name ] | length")" -eq "0" ]; }; then
info "force-all set: running all workflows."
printf "%s" "$SH_MODULES" | awk NF | while read -r module; do
module_dots="$(sed 's@\/@\.@g' <<< "$module")"
Expand Down

0 comments on commit f0060f7

Please sign in to comment.