Skip to content

Commit

Permalink
Cache .local for a faster poetry installation (#4328)
Browse files Browse the repository at this point in the history
* experiment with cached pip cache dir

* small change

* small change

* correct cache keys

* small change

* small change

* exact key

* less slang

* try this

* use --help in example

* reuse vitualenv

* small sample change

* silly

* silly

* small sample change

* possibly skip

* small sample change

* cache pip cache first

* small sample change

* debug

* debug

* ignore snok

* small sample change

* custom path

* print version

* --version

* print version

* try that

* small change

* unique ids

* small change

* louder

* small change

* tidying up

* small change

* small change
  • Loading branch information
peterbe authored Jul 27, 2021
1 parent 054bcb9 commit 3217b5b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
25 changes: 13 additions & 12 deletions .github/workflows/pr-deployer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,31 @@ jobs:
with:
python-version: "3.8"

- name: Install Python poetry
uses: snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/[email protected]
with:
path: deployer/.venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('.github/workflows/pr-deployer.yml') }}

- name: Load cached .local
uses: actions/[email protected]
with:
path: ~/.local
key: dotlocal-${{ runner.os }}-${{ hashFiles('.github/workflows/pr-deployer.yml') }}

- name: Install Python poetry
uses: snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install deployer
run: |
cd deployer
poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'

- name: Display Python & Poetry version
run: |
python --version
poetry --version
- name: Lint Python code
run: |
source deployer/.venv/bin/activate
Expand Down
12 changes: 6 additions & 6 deletions deployer/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Deployer

The Yari deployer does two things. First, it's used to upload document
The Yari Deployer does two things. First, it's used to upload document
redirects, pre-built document pages, static files (e.g. JS, CSS, and
image files), and sitemap files into an existing AWS S3 bucket. Since
we serve MDN document pages from an S3 bucket via a CloudFront CDN,
Expand All @@ -13,7 +13,7 @@ their corresponding S3 keys.

## Getting started

You can install it globally or in a virtualenv environment. Whichever you
You can install it globally or in a `virtualenv` environment. Whichever you
prefer.

```sh
Expand All @@ -28,7 +28,7 @@ with regards to configuring AWS access credentials.
## Uploads

The `poetry run deployer upload DIRECTORY` command uploads files as well as redirects
into an existing S3 bucket. Currently, we have three main S3 buckets that we
into an existing S3 bucket. Currently, we have three S3 buckets that we
upload into: `mdn-content-dev` (for variations or experimental versions of
the site), `mdn-content-stage`, and `mdn-content-prod`.

Expand All @@ -46,7 +46,7 @@ most likely what you'll want for uploads to the `mdn-content-stage` and
bucket, the prefix is often used to specify a different folder for each
variation of the site that is being reviewed/considered.

When uploading files (not redirects), the deployer is intelligent about
When uploading files (not redirects), the Deployer is intelligent about
what it uploads. If only uploads files whose content has changed, skipping
the rest. However, since the `cache-control` attribute of a file is not
considered part of its content, if you'd like to change the `cache-control`
Expand Down Expand Up @@ -307,10 +307,10 @@ poetry install
That should have installed the CLI:

```sh
poetry run deployer
poetry run deployer --help
```

If you wanna make a PR, make sure it's formatted with `black` and
If you want to make a PR, make sure it's formatted with `black` and
passes `flake8`.

You can check that all files are `flake8` fine by running:
Expand Down

0 comments on commit 3217b5b

Please sign in to comment.