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

Assorted dev experience & CI fixes #138

Merged
merged 7 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to SADiLaR Container Registry
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to SADiLaR Container Registry
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: 3.12
Expand All @@ -34,7 +36,8 @@ jobs:
- name: Run linting tools
run: |
cd app/
ruff format .
ruff format --diff .
ruff check --diff .
- name: Create logging folder
run: |
sudo mkdir -p /logging
Expand Down Expand Up @@ -79,6 +82,8 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: 3.12
Expand Down Expand Up @@ -125,6 +130,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
Copy link
Contributor

Choose a reason for hiding this comment

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

To help in my understanding: how does a later git fetch work if the credentials aren't there any more?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it works because we only need public auth for the following fetch

- name: Get all commits on current main
run: git fetch origin main
- name: Log all commits we will analyse
Expand Down
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.PHONY: list up upd build stop down restart make-migrations migrate collectstatic shell logs create-super-user \
docker-stop-all create-schema test ruff-check ruff-fix ruff-format load-fixtures pre-commit-install \
dev-import-documents dev-quick-install lighthouse dev_update_vector_search docker-shell check make-messages \
compile-messages fmt lint

list:
@echo "Available commands:"
@echo "up - Start the project"
Expand Down Expand Up @@ -70,14 +75,18 @@ create-schema:
@docker compose run --rm web python manage.py graph_models -a -o schema/schema.png

test:
@docker compose run --rm web python manage.py test
@docker compose run --rm web python manage.py test $(module)

ruff-check:
@docker compose run --rm web ruff check .

lint: ruff-check

ruff-format:
@docker compose run --rm web ruff format .

fmt: ruff-format

ruff-fix:
@docker compose run --rm web ruff check --fix .

Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,17 @@ Docker Volumes for production:
.env file

* EMAIL_BACKEND_CONSOLE=False

## Notes to Developers

- When setting up the app (from scratch or from a wipe), the following commands should be run:
- (Optional) `make build`
- `make up` - wait for the database to start, then hit Control-C
- `make migrate`
- `make up` - runs the app
- To wipe the database, use `make down`
- The Django admin interface is at `/admin/`
- An admin user can be created through `make create-super-user`
- To run a single module of tests, you can pass the Makefile `module` variable on the command line. For instance, to run
only tests defined in [`test_document_admin.py`](./app/general/tests/test_document_admin.py), run
`make test module=general.tests.test_document_admin`
3 changes: 1 addition & 2 deletions app/general/tests/test_frontend.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from selenium.common import TimeoutException
from selenium.webdriver.chrome.webdriver import WebDriver, Options
from selenium.webdriver.chrome.webdriver import Options, WebDriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait


# Wait timeout in seconds
WAIT_TIMEOUT = 5

Expand Down