Skip to content

Commit

Permalink
feat(#2737): Switch to Poetry in CI pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
pbanaszkiewicz committed Feb 16, 2025
1 parent 554dc2e commit 42e55e5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 36 deletions.
18 changes: 10 additions & 8 deletions .github/workflows/accessibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
continue-on-error: true # currently we expect these tests to fail
strategy:
matrix:
python-version: ["3.11"]
python-version: ["3.12"]
# two options for package: "pa11y" and "lighthouse"
# both options use axe-core ruleset for a11y tests
# pa11y runs faster and produces smaller artifacts
Expand Down Expand Up @@ -55,34 +55,36 @@ jobs:

- name: Install dependencies
run: |
python -m pip install pipenv
pipenv sync --dev
python -m pip install pipx
python -m pipx ensurepath
pipx install poetry==2.0.0
poetry sync
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18

- name: Install NodeJS dependencies
run: npm install

- name: Check migrations
run: |
pipenv run python manage.py makemigrations --dry-run --check;
poetry run python manage.py makemigrations --dry-run --check;
if [[ $? != "0" ]]; then
exit 1;
fi;
- name: Collect static files
run: |
pipenv run python manage.py collectstatic --no-input;
poetry run python manage.py collectstatic --no-input;
if [[ $? != "0" ]]; then
exit 1;
fi;
- name: Set up dev database
run: |
echo "yes" | pipenv run make dev_database
echo "yes" | poetry run make dev_database
- name: Set up Chromium
id: setup-chrome
Expand Down Expand Up @@ -112,7 +114,7 @@ jobs:

- name: Start server in background
run: |
pipenv run make serve &
poetry run make serve &
if: matrix.package == 'pa11y'

- name: Run pa11y
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.11' ]
python-version: [ '3.12' ]
test-type: ["Unit", "Migration"]
fail-fast: false

Expand Down Expand Up @@ -39,15 +39,17 @@ jobs:

- name: Install dependencies
run: |
python -m pip install pipenv
pipenv sync --dev
python -m pip install pipx
python -m pipx ensurepath
pipx install poetry==2.0.0
poetry sync
- name: Install NodeJS dependencies
run: npm install

- name: Check migrations
run: |
pipenv run python manage.py makemigrations --dry-run --check;
poetry run python manage.py makemigrations --dry-run --check;
if [[ $? != "0" ]]; then
exit 1;
fi;
Expand All @@ -60,7 +62,7 @@ jobs:

- name: Create cache tables
run: |
pipenv run python manage.py createcachetable
poetry run python manage.py createcachetable
env:
AMY_DATABASE_HOST: localhost
AMY_DATABASE_PORT: 5432
Expand All @@ -70,13 +72,13 @@ jobs:

- name: Collect static files
run: |
pipenv run python manage.py collectstatic --no-input;
poetry run python manage.py collectstatic --no-input;
if [[ $? != "0" ]]; then
exit 1;
fi;
- name: Unit tests
run: pipenv run make test
run: poetry run make test
env:
AMY_DATABASE_HOST: localhost
AMY_DATABASE_PORT: 5432
Expand All @@ -86,7 +88,7 @@ jobs:
if: matrix.test-type == 'Unit'

- name: Migration tests
run: pipenv run make test_migrations
run: poetry run make test_migrations
env:
AMY_DATABASE_HOST: localhost
AMY_DATABASE_PORT: 5432
Expand Down
31 changes: 13 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,17 @@ sudo apt-get install python3-dev libpq-dev
git config blame.ignoreRevsFile .git-blame-ignore-revs
~~~
1. Install [Pipenv](https://pipenv.pypa.io/en/latest/):
~~~
python -m pip install --user pipenv
~~~
1. Install [Poetry](https://python-poetry.org/docs/#installation).
1. Install Python dependencies:
~~~
pipenv sync --dev
poetry install
~~~
**Note:**
Pipenv will create a new virtual environment for this installation, so you don't
Poetry will create a new virtual environment for this installation, so you don't
have to create one yourself.
The `--dev` flag installs development dependencies, required e.g. for testing.
1. Install [node][nodejs] for front-end packages management.
Expand All @@ -77,21 +72,21 @@ sudo apt-get install python3-dev libpq-dev
1. Create a local instance of Postgres (in a container). This requires Docker to be installed locally.
~~~
make database
poetry run make database
~~~
1. Note: if the database container already exists, the above command will error out. Use `docker start amy-database` instead to start the database container.
1. Set up your local database with fake (development-ready) data. This will create a superuser with "admin" as both the username and password.
~~~
pipenv run make dev_database
poetry run make dev_database
~~~
1. Start a local Django development server by running:
~~~
pipenv run make serve
poetry run make serve
~~~
**Note**: this also installs front-end dependencies for AMY, including [jQuery][jquery] and [Bootstrap][bootstrap] ([full list here](https://github.com/carpentries/amy/blob/develop/package.json)).
Expand All @@ -108,14 +103,14 @@ sudo apt-get install python3-dev libpq-dev
```shell
LAST_COMMIT=`git rev-parse --short HEAD`
docker build -t amy:latest -t amy:${LAST_COMMIT} --label commit=${LAST_COMMIT} -f docker/Dockerfile .
docker build -t amy:latest -t amy:$LAST_COMMIT --label commit=$LAST_COMMIT .
```
First command sets `LAST_COMMIT` environment variable to short commit hash of the
last commit in the repository.
Second command builds `docker/Dockerfile` in `.` as a context (should be your repository
directory) with tags `amy:latest` and `amy:LAST_COMMIT`.
Second command builds `Dockerfile` in `.` as a context (should be your repository
directory) with tags `amy:latest` and `amy:$LAST_COMMIT`.
## Upgrading
Expand All @@ -142,7 +137,7 @@ directory) with tags `amy:latest` and `amy:LAST_COMMIT`.
1. Update back-end dependencies:
~~~
pipenv sync --dev
poetry sync
~~~
1. Update front-end dependencies:
Expand All @@ -154,19 +149,19 @@ directory) with tags `amy:latest` and `amy:LAST_COMMIT`.
1. (Optional) make fresh development-ready database:
~~~
pipenv run make dev_database
poetry run make dev_database
~~~
1. Run database migrations (note: this is included in the `make dev_database` step above):
~~~~
pipenv run python manage.py migrate
poetry run python manage.py migrate
~~~~
1. Enjoy your new version of AMY:
~~~
pipenv run make serve
poetry run make serve
~~~
Expand Down
4 changes: 2 additions & 2 deletions lighthouserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module.exports = {
"http://127.0.0.1:8000/workshops/workshop_staff/",
"http://127.0.0.1:8000/account/logout/"
],
startServerCommand: 'pipenv run make serve',
startServerCommand: 'poetry run make serve',
puppeteerScript: 'puppeteer-script.js',
numberOfRuns: 1
},
Expand All @@ -86,4 +86,4 @@ module.exports = {
}
}
}
};
};

0 comments on commit 42e55e5

Please sign in to comment.