1*90c8c64dSAndroid Build Coastguard Worker# fetchartifact 2*90c8c64dSAndroid Build Coastguard Worker 3*90c8c64dSAndroid Build Coastguard WorkerThis is a Python interface to http://go/fetchartifact, which is used for 4*90c8c64dSAndroid Build Coastguard Workerfetching artifacts from http://go/ab. 5*90c8c64dSAndroid Build Coastguard Worker 6*90c8c64dSAndroid Build Coastguard Worker## Usage 7*90c8c64dSAndroid Build Coastguard Worker 8*90c8c64dSAndroid Build Coastguard Worker```python 9*90c8c64dSAndroid Build Coastguard Workerfrom fetchartifact import fetchartifact 10*90c8c64dSAndroid Build Coastguard Worker 11*90c8c64dSAndroid Build Coastguard Worker 12*90c8c64dSAndroid Build Coastguard Workerasync def main() -> None: 13*90c8c64dSAndroid Build Coastguard Worker artifacts = await fetch_artifact( 14*90c8c64dSAndroid Build Coastguard Worker branch="aosp-master-ndk", 15*90c8c64dSAndroid Build Coastguard Worker target="linux", 16*90c8c64dSAndroid Build Coastguard Worker build="1234", 17*90c8c64dSAndroid Build Coastguard Worker pattern="android-ndk-*.zip", 18*90c8c64dSAndroid Build Coastguard Worker ) 19*90c8c64dSAndroid Build Coastguard Worker for artifact in artifacts: 20*90c8c64dSAndroid Build Coastguard Worker print(f"Downloaded {artifact}") 21*90c8c64dSAndroid Build Coastguard Worker``` 22*90c8c64dSAndroid Build Coastguard Worker 23*90c8c64dSAndroid Build Coastguard Worker## Development 24*90c8c64dSAndroid Build Coastguard Worker 25*90c8c64dSAndroid Build Coastguard WorkerFor first time set-up, install https://python-poetry.org/, then run 26*90c8c64dSAndroid Build Coastguard Worker`poetry install` to install the project's dependencies. 27*90c8c64dSAndroid Build Coastguard Worker 28*90c8c64dSAndroid Build Coastguard WorkerThis project uses mypy and pylint for linting, black and isort for 29*90c8c64dSAndroid Build Coastguard Workerauto-formatting, and pytest for testing. All of these tools will be installed 30*90c8c64dSAndroid Build Coastguard Workerautomatically, but you may want to configure editor integration for them. 31*90c8c64dSAndroid Build Coastguard Worker 32*90c8c64dSAndroid Build Coastguard WorkerTo run any of the tools poetry installed, you can either prefix all your 33*90c8c64dSAndroid Build Coastguard Workercommands with `poetry run` (as in `poetry run pytest`), or you can run 34*90c8c64dSAndroid Build Coastguard Worker`poetry shell` to enter a shell with all the tools on the `PATH`. The following 35*90c8c64dSAndroid Build Coastguard Workerinstructions assume you've run `poetry shell` first. 36*90c8c64dSAndroid Build Coastguard Worker 37*90c8c64dSAndroid Build Coastguard WorkerTo run the linters: 38*90c8c64dSAndroid Build Coastguard Worker 39*90c8c64dSAndroid Build Coastguard Worker```bash 40*90c8c64dSAndroid Build Coastguard Workermypy fetchartifact tests 41*90c8c64dSAndroid Build Coastguard Workerpylint fetchartifact tests 42*90c8c64dSAndroid Build Coastguard Worker``` 43*90c8c64dSAndroid Build Coastguard Worker 44*90c8c64dSAndroid Build Coastguard WorkerTo auto-format the code (though I recommend configuring your editor to do this 45*90c8c64dSAndroid Build Coastguard Workeron save): 46*90c8c64dSAndroid Build Coastguard Worker 47*90c8c64dSAndroid Build Coastguard Worker```bash 48*90c8c64dSAndroid Build Coastguard Workerisort . 49*90c8c64dSAndroid Build Coastguard Workerblack . 50*90c8c64dSAndroid Build Coastguard Worker``` 51*90c8c64dSAndroid Build Coastguard Worker 52*90c8c64dSAndroid Build Coastguard WorkerTo run the tests and generate coverage: 53*90c8c64dSAndroid Build Coastguard Worker 54*90c8c64dSAndroid Build Coastguard Worker```bash 55*90c8c64dSAndroid Build Coastguard Workerpytest --cov=fetchartifact 56*90c8c64dSAndroid Build Coastguard Worker``` 57*90c8c64dSAndroid Build Coastguard Worker 58*90c8c64dSAndroid Build Coastguard WorkerOptionally, pass `--cov-report=html` to generate an HTML report, or 59*90c8c64dSAndroid Build Coastguard Worker`--cov-report=xml` to generate an XML report for your editor. 60*90c8c64dSAndroid Build Coastguard Worker 61*90c8c64dSAndroid Build Coastguard WorkerSome tests require network access. If you need to run the tests in an 62*90c8c64dSAndroid Build Coastguard Workerenvironment that cannot access the Android build servers, add 63*90c8c64dSAndroid Build Coastguard Worker`-m "not requires_network"` to skip those tests. Only a mock service can be 64*90c8c64dSAndroid Build Coastguard Workertested without network access. 65