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

[maykinmedia/open-api-framework#96] Add quick-start.yml #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
47 changes: 47 additions & 0 deletions .github/workflows/quick-start.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: quick-start

on:
workflow_call:
inputs:
fixtures:
required: false
type: string

superuser:
required: false
type: string

web_service:
required: false
type: string

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Start docker containers
run: docker compose up -d --build || ( docker compose logs >&2 && exit 1; )
Copy link
Contributor

Choose a reason for hiding this comment

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

For my information: is the explicit exit 1 needed, wouldn't the build/bringing the containers up failing cause a non zero exit code by itself? In any case I think it's fine to use this to make sure the job fails if there are any errors

- name: Wait for migrations to finish
run: |
echo "Waiting for migrations to complete..."
until ! docker compose exec -T web src/manage.py showmigrations | grep -q '\[ \]'; do
echo "Migrations not finished, waiting..."
sleep 3
done
- name: Load fixtures
if: ${{ inputs.fixtures != '' }}
run: docker compose exec -T web src/manage.py loaddata ${{ inputs.fixtures }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it work if you pass multiple fixture names to fixtures?

- name: Create superuser
run: |
SUPERUSER="${{ inputs.superuser || 'admin' }}"
WEB_SERVICE="${{ inputs.web_service || 'web' }}"
Comment on lines +37 to +38
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're not testing logging in in this job, I don't think we have to make these variable, but as long as it's not required to pass them it's fine by me to leave this as is

docker compose exec -T $WEB_SERVICE src/manage.py createsuperuser --username $SUPERUSER --email [email protected] --no-input
- name: Check main page
run: |
curl_status=$(curl -w '%{http_code}' -o /dev/null -s http://localhost:8000/)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it might be good to make the port number variable (with 8000 as the default), currently all of them are probably 8000, but if we introduce any other numbers it's good to have this prepared for that

if [[ $curl_status != 200 ]]; then
printf "Index page responds with ${curl_status} status.\r\n\r\n" >&2
curl -i http://localhost:8000
exit 1
fi