Skip to content

Commit

Permalink
Bug 1801665: Add staging URL to .arcconfig check (r=sheehan)
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D162580

--HG--
extra : moz-landing-system : lando
  • Loading branch information
zzzeid committed Nov 22, 2022
1 parent 5cc1e9b commit 3e065a6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ commands to provide better ergonomics and good testing defaults.

The test runner and all it's dependencies are contained in a Docker image.
The state of your version-control-tools checkout is mounted into the container
built from that image and tests are run inside the contianer using the source
built from that image and tests are run inside the container using the source
on your host's filesystem. To do this, a `.env` file must be created to tell
the container about which user on the host system is running the tests.

Expand Down
7 changes: 4 additions & 3 deletions hghooks/mozhghooks/check/prevent_conduit_arcconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
REJECT_MESSAGE = b"""
Push contains unwanted changes to `.arcconfig` files.
Please ensure `.arcconfig` points to the Phab dev server for
Please ensure `.arcconfig` points to the Phab dev or stage servers for
`conduit-testing` repos.
"""

ARCCONFIG_PATH = b".arcconfig"

DEV_PHAB_URL = "https://phabricator-dev.allizom.org/"
STAGE_PHAB_URL = "https://phabricator.allizom.org/"


class PreventConduitArcconfig(PreTxnChangegroupCheck):
Expand Down Expand Up @@ -55,8 +56,8 @@ def post_check(self) -> bool:
except json.JSONDecodeError as exc:
raise error.Abort(b"Could not decode `.arcconfig` to JSON.") from exc

if arcconfig["phabricator.uri"].startswith(DEV_PHAB_URL):
# Latest state of `.arcconfig` maintains dev URL.
if arcconfig["phabricator.uri"].startswith((DEV_PHAB_URL, STAGE_PHAB_URL)):
# Latest state of `.arcconfig` maintains dev/stage URL.
return True

# `.arcconfig` has been updated to point to the wrong server (prod).
Expand Down
26 changes: 20 additions & 6 deletions hghooks/tests/test-prevent-arcconfig.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$ . $TESTDIR/hghooks/tests/common.sh

`conduit-testing` repos should only allow the dev phab server in `.arcconfig`.
`conduit-testing` repos should only allow the dev/stage phab server in `.arcconfig`.

$ hg init conduit-testing
$ configurehooks conduit-testing
Expand All @@ -16,6 +16,15 @@
adding file changes
added 1 changesets with 1 changes to 1 files

$ echo '{"phabricator.uri":"https://phabricator.allizom.org/"}' > .arcconfig
$ hg ci -q -A -m "add .arcconfig"
$ hg push
pushing to $TESTTMP/conduit-testing
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
$ echo '{"phabricator.uri":"https://phabricator.services.mozilla.com/"}' > .arcconfig
$ hg ci -q -A -m "update .arcconfig to bad value"
$ hg push
Expand All @@ -25,12 +34,12 @@
adding manifests
adding file changes

************************** ERROR ***************************
******************************* ERROR ********************************
Push contains unwanted changes to `.arcconfig` files.

Please ensure `.arcconfig` points to the Phab dev server for
Please ensure `.arcconfig` points to the Phab dev or stage servers for
`conduit-testing` repos.
************************************************************
**********************************************************************

transaction abort!
rollback completed
Expand All @@ -42,17 +51,22 @@ Pushes that update `.arcconfig` and then revert it should be allowed.
$ echo '{"phabricator.uri":"https://phabricator-dev.allizom.org/"}' > .arcconfig
$ hg ci -q -A -m "revert .arcconfig to correct value"
$ hg log -G
@ changeset: 2:743d41d3d1de
@ changeset: 3:bde208bc21b1
| tag: tip
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: revert .arcconfig to correct value
|
o changeset: 1:dcd947bcda7b
o changeset: 2:ea1f594b7cd1
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: update .arcconfig to bad value
|
o changeset: 1:4ed1c3bebe91
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
| summary: add .arcconfig
|
o changeset: 0:58f2675adc14
user: test
date: Thu Jan 01 00:00:00 1970 +0000
Expand Down

0 comments on commit 3e065a6

Please sign in to comment.