Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lets just try dockah #15585

Merged
merged 77 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
610a4cf
lets just try dockah
ewdurbin Mar 13, 2024
fa266e1
here
ewdurbin Mar 13, 2024
b657159
hm?
ewdurbin Mar 13, 2024
94447d9
ghcr?
ewdurbin Mar 13, 2024
33c9609
login
ewdurbin Mar 13, 2024
b5635ae
use da cache
ewdurbin Mar 13, 2024
08f5231
hehe
ewdurbin Mar 13, 2024
9617f25
f
ewdurbin Mar 13, 2024
e2207ee
perms
ewdurbin Mar 13, 2024
bf62731
big dumb
ewdurbin Mar 13, 2024
e8ef0b9
oh lala
ewdurbin Mar 13, 2024
674df60
hipshot
ewdurbin Mar 13, 2024
07f1f3c
?
ewdurbin Mar 13, 2024
0decba0
that's no kubes
ewdurbin Mar 13, 2024
0acbded
oh yeah
ewdurbin Mar 13, 2024
b0fe768
connect up da services
ewdurbin Mar 13, 2024
864903f
oh that is simpler
ewdurbin Mar 13, 2024
d05e83b
paths?
ewdurbin Mar 13, 2024
d768e24
restore da matrix, neo
ewdurbin Mar 13, 2024
4a65dcd
hmmmmm
ewdurbin Mar 13, 2024
bd4560e
don't locale me
ewdurbin Mar 13, 2024
c7b06a8
maybe bash
ewdurbin Mar 13, 2024
52b10ad
omfg
ewdurbin Mar 13, 2024
6bb72e0
straws!
ewdurbin Mar 13, 2024
b18d269
restore matrix, neo
ewdurbin Mar 13, 2024
cb2f9a9
hmmmmmmmmmm
ewdurbin Mar 13, 2024
0aa5f30
ooo
ewdurbin Mar 13, 2024
6af126d
hold on docs 4 now
ewdurbin Mar 13, 2024
57fb2be
split up docs stuff
ewdurbin Mar 13, 2024
157441b
GHA doesn't have git anymore
ewdurbin Mar 13, 2024
ce6e50b
i hate this uid/gidshit
ewdurbin Mar 13, 2024
285afe8
🤦
ewdurbin Mar 13, 2024
a19c5fd
just skip for now
ewdurbin Mar 13, 2024
153c653
whoami
ewdurbin Mar 13, 2024
ac8afa6
pro
ewdurbin Mar 13, 2024
f01600a
allup
ewdurbin Mar 13, 2024
28b54b8
CI!!!
ewdurbin Mar 13, 2024
36c2077
cache it all
ewdurbin Mar 13, 2024
8629f4d
Revert "GHA doesn't have git anymore"
ewdurbin Mar 13, 2024
879a6c1
mount the whole shebang
ewdurbin Mar 13, 2024
a356e2e
env in container
ewdurbin Mar 13, 2024
e5f76d4
wront spot
ewdurbin Mar 13, 2024
d40a9ef
argumentsssss
ewdurbin Mar 13, 2024
0c66f4b
am fog
ewdurbin Mar 13, 2024
e651330
hm
ewdurbin Mar 14, 2024
0c708ee
no?
ewdurbin Mar 14, 2024
ea18ba5
when in doubt
ewdurbin Mar 14, 2024
3675a5b
?
ewdurbin Mar 14, 2024
c99e2db
?
ewdurbin Mar 14, 2024
02b0b6d
set it aside for now
ewdurbin Mar 14, 2024
f3794fa
okay now to fight git?
ewdurbin Mar 14, 2024
9bf195e
hold
ewdurbin Mar 14, 2024
5048aaa
ref: https://github.com/actions/checkout/issues/1487
ewdurbin Mar 14, 2024
86060af
allup
ewdurbin Mar 14, 2024
dd3bacc
byapss
ewdurbin Mar 14, 2024
51fd10c
validate
ewdurbin Mar 14, 2024
ef0beac
No, I will not be squashing all that, witness my garbage.
ewdurbin Mar 14, 2024
1551e5e
not sure if neccessary
ewdurbin Mar 14, 2024
8c3bc52
too slow and doesn't capture RUN caches anyway
ewdurbin Mar 14, 2024
e1614d5
nose clean
ewdurbin Mar 14, 2024
dc90ffe
no, we wanted that :)
ewdurbin Mar 14, 2024
64a839b
Merge branch 'main' into gha_docker
ewdurbin Mar 14, 2024
11d76d1
oh, right this is what enables the gha docker cache
ewdurbin Mar 14, 2024
ccf44d4
more caching cannot hurt
ewdurbin Mar 14, 2024
f03fd35
test cachin
ewdurbin Mar 14, 2024
1bdb9f5
oh, right
ewdurbin Mar 14, 2024
30acbe4
Revert "test cachin"
ewdurbin Mar 14, 2024
a7e40fa
test all the caches
ewdurbin Mar 14, 2024
ef0ebcc
test the caches
ewdurbin Mar 14, 2024
dba0c7b
test cache
ewdurbin Mar 14, 2024
293bb1b
test caching and validate deps task
ewdurbin Mar 14, 2024
d8b5ea8
test test test
ewdurbin Mar 14, 2024
6519269
reverts
ewdurbin Mar 14, 2024
9e3a588
test code only change
ewdurbin Mar 14, 2024
8ad6742
does caching work in container runs?
ewdurbin Mar 14, 2024
8f9faa6
revert test change
ewdurbin Mar 14, 2024
2f1eed3
Merge branch 'main' into gha_docker
ewdurbin Mar 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
118 changes: 72 additions & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,102 @@ on:
workflow_dispatch: # generally only for the "combine-prs" workflow
permissions:
contents: read
packages: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
deps:
build:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install platform dependencies
run: |
sudo apt -y update
sudo apt -y install libcurl4-openssl-dev libssl-dev pkg-config libxml2-dev libxslt-dev
- uses: actions/setup-python@v5
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exposes the necessary variables for the gha cache type to work for docker layers, see https://docs.docker.com/build/cache/backends/gha/#authentication

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache RUN --mount=type=cache /var/cache/apt
uses: actions/cache@v3
with:
python-version-file: '.python-version'
- name: pip cache
uses: actions/cache@v4
path: var-cache-apt
key: var-cache-apt-${{ hashFiles('Dockerfile') }}
restore-keys: |
var-cache-apt-
- name: Cache RUN --mount=type=cache /var/lib/apt
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: pip-${{ runner.os }}
- name: Cache built Python environment
uses: actions/cache@v4
path: var-lib-apt
key: var-lib-apt-${{ hashFiles('Dockerfile') }}
restore-keys: |
var-lib-apt-
- name: Cache RUN --mount=type=cache /root/.cache/pip
uses: actions/cache@v3
with:
path: root-cache-pip
key: root-cache-pip-${{ hashFiles('requirements/*.txt') }}
restore-keys: |
root-cache-pip-
- name: Cache RUN --mount=type=cache /root/.npm
uses: actions/cache@v3
with:
path: root-npm
key: root-npm-${{ hashFiles('package.json', 'package-lock.json') }}
restore-keys: |
root-npm-
- name: inject var-cache-apt into docker
uses: reproducible-containers/buildkit-cache-dance@v2.1.4
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements/*.txt') }}
- name: Install Python dependencies
cache-source: var-cache-apt
cache-target: /var/cache/apt
skip-extraction: ${{ steps.cache-var-cache-apt.outputs.cache-hit }}
- name: inject var-lib-apt into docker
uses: reproducible-containers/buildkit-cache-dance@v2.1.4
with:
cache-source: var-lib-apt
cache-target: /var/lib/apt
skip-extraction: ${{ steps.cache-var-lib-apt.outputs.cache-hit }}
- name: inject root-cache-pip into docker
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these combined with the normal "cache" steps help us persist RUN --mount=type=cache caches between runs improving our pip/apt/npm install times.

uses: reproducible-containers/buildkit-cache-dance@v2.1.4
with:
cache-source: root-cache-pip
cache-target: /root/.cache/pip
skip-extraction: ${{ steps.cache-root-cache-pip.outputs.cache-hit }}
- name: inject root-npm into docker
uses: reproducible-containers/buildkit-cache-dance@v2.1.4
with:
cache-source: root-npm
cache-target: /root/.npm
skip-extraction: ${{ steps.cache-root-npm.outputs.cache-hit }}
- name: Build Docker Image
run: |
pip install -U setuptools wheel pip
pip install -r requirements.txt --no-deps
pip install -r requirements/dev.txt
pip check
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
di marked this conversation as resolved.
Show resolved Hide resolved
docker buildx build --build-arg="DEVEL=yes" --build-arg="CI=yes" --cache-to type=gha,mode=max --cache-from type=gha --push -t ghcr.io/pypi/warehouse:ci-${{ github.run_id }} .
test:
# Time out if our test suite has gotten hung
timeout-minutes: 15
needs: deps
needs: build
strategy:
matrix:
include:
- name: Tests
command: bin/tests --postgresql-host localhost
command: bin/tests --postgresql-host postgres
- name: Lint
command: bin/lint
- name: User Documentation
command: bin/user-docs
- name: Developer Documentation
command: bin/dev-docs
- name: Dependencies
command: bin/github-actions-deps
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something goes wrong trying to run git in the container. without the gha specific deps job... we burn an extra minute of CI every run :/

command: bin/deps
- name: Licenses
command: bin/licenses
- name: Translations
command: bin/translations
- name: User Documentation
command: bin/user-docs
- name: Developer Documentation
command: bin/dev-docs
runs-on: ubuntu-latest
container:
image: ghcr.io/pypi/warehouse:ci-${{ github.run_id }}
env:
BILLING_BACKEND: warehouse.subscriptions.services.MockStripeBillingService api_base=http://stripe:12111 api_version=2020-08-27
services:
postgres:
image: ${{ (matrix.name == 'Tests') && 'postgres:14.11' || '' }}
Expand All @@ -77,31 +119,15 @@ jobs:
ports:
- 12111:12111
name: ${{ matrix.name }}
env:
BILLING_BACKEND: warehouse.subscriptions.services.MockStripeBillingService api_base=http://localhost:12111 api_version=2020-08-27
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install platform dependencies
run: |
sudo apt -y update
sudo apt -y install libcurl4-openssl-dev libssl-dev pkg-config libxml2-dev libxslt-dev
- uses: actions/setup-python@v5
with:
python-version-file: '.python-version'
- name: Cache mypy results
if: ${{ (matrix.name == 'Lint') }}
uses: actions/cache@v4
with:
path: |
dev/.mypy_cache
key: ${{ runner.os }}-mypy-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements/*.txt') }}
- name: Restore built Python environment from deps
uses: actions/cache/restore@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'requirements/*.txt') }}
# Since we don't install deps again, we fail if we can't restore the cache (timeout, etc)
fail-on-cache-miss: true
key: ${{ runner.os }}-mypy-${{ hashFiles('requirements.txt', 'requirements/*.txt') }}
- name: Run ${{ matrix.name }}
run: ${{ matrix.command }}
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ FROM python:3.11.8-slim-bookworm as build
# test dependencies.
ARG DEVEL=no

# Define whether we're building a CI image. This will include all the docs stuff
# as well for the matrix!
ARG CI=no

# To enable Ipython in the development environment set to yes (for using ipython
# as the warehouse shell interpreter,
# i.e. 'docker compose run --rm web python -m warehouse shell --type=ipython')
Expand Down Expand Up @@ -176,6 +180,7 @@ RUN --mount=type=cache,target=/root/.cache/pip \
-r /tmp/requirements/deploy.txt \
-r /tmp/requirements/main.txt \
$(if [ "$DEVEL" = "yes" ]; then echo '-r /tmp/requirements/tests.txt -r /tmp/requirements/lint.txt'; fi) \
$(if [ "$CI" = "yes" ]; then echo '-r /tmp/requirements/docs-dev.txt -r /tmp/requirements/docs-user.txt -r /tmp/requirements/docs-blog.txt'; fi ) \
&& pip check \
&& find /opt/warehouse -name '*.pyc' -delete

Expand All @@ -198,6 +203,10 @@ WORKDIR /opt/warehouse/src/
# test dependencies.
ARG DEVEL=no

# Define whether we're building a CI image. This will include all the docs stuff
# as well for the matrix!
ARG CI=no

# This is a work around because otherwise postgresql-client bombs out trying
# to create symlinks to these directories.
RUN set -x \
Expand All @@ -211,8 +220,9 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
set -x \
&& apt-get update \
&& apt-get install --no-install-recommends -y \
libpq5 libxml2 libxslt1.1 libcurl4 \
libpq5 libxml2 libxslt1.1 libcurl4 \
$(if [ "$DEVEL" = "yes" ]; then echo 'bash libjpeg62 postgresql-client build-essential libffi-dev libxml2-dev libxslt-dev libpq-dev libcurl4-openssl-dev libssl-dev vim'; fi) \
$(if [ "$CI" = "yes" ]; then echo 'git'; fi) \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Expand Down
19 changes: 0 additions & 19 deletions bin/github-actions-deps

This file was deleted.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This is only used for dependabot and Github Actions CI
# This is only used for dependabot
-r requirements/main.txt
-r requirements/deploy.txt
-r requirements/docs-dev.txt
Expand Down
2 changes: 1 addition & 1 deletion warehouse/forklift/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def process_formdata(self, valuelist):

# TODO: Eventually this whole validation thing should move to the packaging
# library and we should just call that. However until PEP 426 is done
# that library won't have an API for this.
# that library won't have an API for this. ref: #14718
ewdurbin marked this conversation as resolved.
Show resolved Hide resolved
class MetadataForm(forms.Form):
# Metadata version
metadata_version = wtforms.StringField(
Expand Down
2 changes: 1 addition & 1 deletion warehouse/locale/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build-mos: compile-pot
translations: compile-pot
ifneq ($(GITHUB_ACTIONS), false)
cd ../../; \
git diff --quiet ./warehouse/locale/messages.pot || (echo "There are outstanding translations, run 'make translations' and commit the changes."; exit 1)
cmp -s ./warehouse/locale/messages.pot /opt/warehouse/src/warehouse/locale/messages.pot || (echo "There are outstanding translations, run 'make translations' and commit the changes."; exit 1)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this leverages the fact that we have a copy of the messages.pot from the build step since git diff doesn't work in the container.

else
endif

Expand Down