Page MenuHomePhabricator

Add `script` check type and environment variables
ClosedPublic

Authored by thcipriani on Feb 9 2018, 5:35 PM.

Details

Maniphest Tasks
T154612: Add DEPLOY_DIR env var to scap command checks
Reviewers
mmodell
demon
mobrovac
bd808
awight
Group Reviewers
Release-Engineering-Team
Commits
rMSCA286585b112ae: Add `script` check type and environment variables
Patch without arc
git checkout -b D970 && curl -L https://phabricator.wikimedia.org/D970?download=true | git apply
Summary

As scap has seen increasing adoption, one common pattern that has
emerged is to use the command check type to run a script. Often this
script will act on the revision currently being deployed, and the script
itself may be part of the newly deployed code. This can be problematic
as the the final path (i.e., /srv/deployment/[repo]) is a symlink that
points to different revisions at different stages of deployment. That
is, during fetch and config_deploy the final path points to the old
revision. In all subsequent stages, the final path points to the new
revision.

To simplify this pattern, this commit introduces two changes: a script
check type, and new check environment variables for use in commands and
scripts.

script checks are file names of executable files within the
scap/scripts directory. This allows the old means of executing
scripts:

checks:
  fetch_checks:
    type: command
    stage: fetch
    command: bash scap/fetch_check.sh

to be written as:

checks:
  fetch_checks:
    type: script
    stage: fetch
    command: fetch_check.sh

This ensures that the script being executed will always be the latest
version, no matter at what stage of deployment it is called.

Further, within a script, the environment variables $SCAP_FINAL_PATH
and $SCAP_REV_PATH can be used to refer to the final path (i.e.,
/srv/deployment/[repo]) and the in-progress deployment path (i.e.,
/srv/deployment/[repo]-cache/revs/[revision]).

This should address concerns raised in T154612.

Diff Detail

Repository
rMSCA Scap
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

thcipriani created this revision.Feb 9 2018, 5:35 PM
Restricted Application added a reviewer: Release-Engineering-Team. · View Herald TranscriptFeb 9 2018, 5:35 PM
Restricted Application added a project: Release-Engineering-Team. · View Herald Transcript
thcipriani updated this revision to Diff 2548.Feb 9 2018, 7:00 PM
  • Remove Dockerfile.ci pip cache
thcipriani requested review of this revision.Feb 9 2018, 7:04 PM

Thanks for taking this on! I like the scap/scripts solution, for my use case it feels much cleaner than the cwd or environment variable workarounds.

mmodell accepted this revision.Feb 13 2018, 3:31 PM

Looks good. Tests pass. Good work @thcipriani!

This revision is now accepted and ready to land.Feb 13 2018, 3:31 PM
thcipriani updated this revision to Diff 2563.Feb 14 2018, 5:08 PM

Rebase after Dockerfile.ci changes

This revision was automatically updated to reflect the committed changes.