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

Make the template project compatible with startproject #20

Merged
merged 1 commit into from
Dec 6, 2023

Conversation

a-musing-moose
Copy link
Contributor

@a-musing-moose a-musing-moose commented Dec 1, 2023

Adds the necessary place holders for ensuring the template project can be used with the Django startproject command.

  • Placeholders added to template file (mostly {{ project_name }})
  • Really basic usage example in README
  • Github action workflow to ensure that the repository is capable of creating a valid project

The Github action workflow startproject performs the following to ensure that we can create a valid project from this repositoiry:

  1. Checkout code
  2. Install Django. Poetry and Invoke
  3. Run the startproject Django command specifying the template directory as the source
  4. Poetry install the project created in the previous step
  5. Run invoke check on the project - which runs all the static analysis, linting and tests

Closes #19

@a-musing-moose a-musing-moose force-pushed the start-project branch 17 times, most recently from 696c1fa to 2dece40 Compare December 5, 2023 05:47
@a-musing-moose a-musing-moose marked this pull request as ready for review December 5, 2023 05:47
Copy link
Contributor

@jadedarko jadedarko left a comment

Choose a reason for hiding this comment

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

I really appreciate your doing this, Jon

I had wondered if we might want to use cookiecutter for this, but the inbuilt django method is much more straight-forward, especially when there aren't yet any variants

.github/workflows/startproject.yml Outdated Show resolved Hide resolved
Copy link

Choose a reason for hiding this comment

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

note: there's some hardening that we should do at some point, but it's more for consistency than anything serious so I'm happy to leave it as is (and also to do the follow-up PR)

If you're interested, see ackama/rails-template#513 and related for the hardening changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not familiar with workflow permissions. I am assuming that since I am never attempting to make any changes to the repo during the workflow run I should be safe to just lock all the steps to read only (with a global no permissions at all)?

If so then I don't see any reason not to include it as part of this PR.

Copy link

Choose a reason for hiding this comment

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

yup and we also want to set persist-credentials: false on actions/checkout calls

Comment on lines 14 to 15
runs-on: ubuntu-latest
permissions:
contents: read
Copy link

@G-Rath G-Rath Dec 6, 2023

Choose a reason for hiding this comment

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

nitpick: I'm thinking that since we're always going to have permissions now, we should have it as the first property for consistency, but it's not super important

Suggested change
runs-on: ubuntu-latest
permissions:
contents: read
permissions:
contents: read
runs-on: ubuntu-latest

- 5432:5432

steps:
- uses: actions/checkout@v4
Copy link

Choose a reason for hiding this comment

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

suggestion: we should explicitly disable persisted credentials since they're not needed for this workflow

Suggested change
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
persist-credentials: false

Adds the necessary place holders for ensuring the `template` project can
be used with the Django `startproject` command.

Also adds a Github workflow for the repository itself that ensure the
repository can be used to create a valid Django project.
@a-musing-moose a-musing-moose merged commit b5603f5 into main Dec 6, 2023
1 check passed
@a-musing-moose a-musing-moose deleted the start-project branch December 6, 2023 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for startproject
3 participants