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

Initial repository and Wagtail setup #3

Merged
merged 39 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
925a2dc
Bump Python version to 3.12
zerolab Oct 16, 2024
360c800
Drop black and update dev dependencies
zerolab Oct 16, 2024
a046737
Add pre-commit config
zerolab Oct 16, 2024
64dcdb8
Update makefile
zerolab Oct 16, 2024
7763f84
Add CODEOWNERS
zerolab Oct 17, 2024
1112eb8
Add scripts to load the DS assets
zerolab Oct 17, 2024
23c6c45
Add FE tooling
zerolab Oct 17, 2024
7c4dfd8
Lint (prettier)
zerolab Oct 17, 2024
4757b58
Drop the placeholder app and tests
zerolab Oct 17, 2024
1a95641
Add the Wagtail skeleton
zerolab Oct 17, 2024
0c26f8f
Add Docker setup
zerolab Oct 17, 2024
8a210a5
Build the docker image in CI
zerolab Oct 17, 2024
a5c2aa6
Lint with ruff
zerolab Oct 17, 2024
63e3798
Run tests in CI
zerolab Oct 18, 2024
659b2c0
Add basic docs
zerolab Oct 18, 2024
a3a98b8
Add a Heroku config file
zerolab Oct 18, 2024
77a113c
Disable Megalinter
zerolab Oct 18, 2024
3428cd8
Update mypy configuration
zerolab Oct 18, 2024
103baff
Use the alpha pylint config
zerolab Oct 18, 2024
cc66dbd
Add type hints
zerolab Oct 18, 2024
390c38e
Add the type hinting docs
zerolab Oct 21, 2024
6463dfe
Fix webpack image copying
zerolab Oct 21, 2024
3f72065
Add djhtml to dev dependencies
zerolab Oct 21, 2024
cfba62b
Update code owners file with TL agreed format
zerolab Oct 21, 2024
7c7a443
Update README
zerolab Oct 21, 2024
1184c1a
Tidy up coverage config
zerolab Oct 21, 2024
c5e099b
Convert existing tests to pytest
zerolab Oct 21, 2024
65454ad
Switch to the Wagtail eslint/stylelint front-end tooling configuration
zerolab Oct 22, 2024
86993a8
Tidy up based on code review
zerolab Oct 22, 2024
6995629
Update pylint config
zerolab Oct 23, 2024
e558582
LInt
zerolab Oct 23, 2024
911ad39
Add missing django-settings-module for pylint-django
zerolab Oct 23, 2024
5a30698
Tweak developer instructions in README
zerolab Oct 24, 2024
4e5a24d
Tidy up post code review, redux
zerolab Oct 25, 2024
fd00f85
Placate pylint
zerolab Oct 25, 2024
d557079
Further tidy ups
zerolab Oct 25, 2024
3d09dc7
Improve load-design-system-templates step
zerolab Oct 25, 2024
61dc92d
Further tidy ups
zerolab Oct 28, 2024
a7d4449
Update TOC
zerolab Oct 28, 2024
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
4 changes: 2 additions & 2 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ default_branch: main
dependabot_open_pull_requests_limit: 10
dismiss_stale_reviews: false
enable_dependabot_version_updates: true
module_name: dis_wagtail
module_name: cms
package_manager: poetry
repo_settings: custom
repository_description: The Django Wagtail CMS for managing and publishing content
for the Office for National Statistics (ONS)
for the Office for National Statistics (ONS)
repository_name: dis-wagtail
repository_owner: ONSdigital
repository_visibility: public
Expand Down
1 change: 1 addition & 0 deletions .design-system-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
70.0.17
3 changes: 3 additions & 0 deletions .docker/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
web: python manage.py runserver 0.0.0.0:8000
scheduler: python manage.py scheduler
frontend: npm run start:reload
10 changes: 10 additions & 0 deletions .docker/bashrc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Note: This file is loaded on all environments, even production.

alias dj="django-admin"

if [ -n "$DEVCONTAINER" ]
then
alias djrun="django-admin runserver 0.0.0.0:8000"
alias djrunplus="python manage.py runserver_plus 0.0.0.0:8000"
alias honcho="honcho -f .docker/Procfile"
fi
50 changes: 50 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/Dockerfile
/docker-compose.yml
/docker-compose.override.yml.example

.git
**/__pycache__
*.pyc
.DS_Store
*.swp
/venv/
/.venv/
/static/
/media/
/tmp/
/.vagrant/
/Vagrantfile.local
node_modules/
coverage
/npm-debug.log
/.idea/
/.devcontainer/
/.mypy_cache/

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

/database_dumps

/cms/static_compiled
/cms/settings/local.py

/cms/jinja2/assets/styles/print.css
/cms/jinja2/components
/cms/jinja2/layout
9 changes: 9 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
coverage
/cms/jinja2
/cms/static_compiled
/static
venv
.mypy_cache
.venv
.coverage
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
root: true,
// See https://github.com/wagtail/eslint-config-wagtail for rules.
extends: ['@wagtail/eslint-config-wagtail', 'plugin:@typescript-eslint/recommended'],
};
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Describe what actually happened. Include details like error messages or unexpect

Any relevant technical information. Include as much information as possible, including:

- **Operating System**:
- **Browser/Application Version**:
- **Additional relevant software versions**:
- **Operating System**:
- **Browser/Application Version**:
- **Additional relevant software versions**:

### Proposed Solutions (Optional)

Expand Down
8 changes: 4 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ updates:
gh-security-updates:
applies-to: security-updates
patterns:
- "*"
- '*'

gh-version-updates:
applies-to: version-updates
patterns:
- "*"
- '*'

# Enable Security updates for Python package manager
- package-ecosystem: pip
Expand All @@ -40,9 +40,9 @@ updates:
py-security-updates:
applies-to: security-updates
patterns:
- "*"
- '*'

py-version-updates:
applies-to: version-updates
patterns:
- "*"
- '*'
2 changes: 1 addition & 1 deletion .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ changelog:
- Documentation
- title: Other Changes
labels:
- "*"
- '*'
108 changes: 103 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ on: # yamllint disable-line rule:truthy
branches: [main]

concurrency:
group: "${{ github.head_ref || github.ref }}-${{ github.workflow }}"
group: '${{ github.head_ref || github.ref }}-${{ github.workflow }}'
cancel-in-progress: true

jobs:
lint-test:
name: Lint and Test
runs-on: ubuntu-22.04
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry==1.7.1
run: pipx install poetry==1.8.3 # keep in sync with pyproject.toml

- name: Set up Python
uses: actions/setup-python@v5
Expand All @@ -31,6 +30,105 @@ jobs:

- name: Lint Python
run: make lint
- name: Lint HTML
run: make lint-html

lint-front-end:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Install npm dependencies
run: npm ci --no-audit
- name: CSS linting
run: npm run lint:css
- name: JS linting
run: npm run lint:js
- name: Prettier
run: npm run format

compile_static:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- id: node-cache
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/.nvmrc') }}-${{ hashFiles('**/package-lock.json') }}
- if: steps.node-cache.outputs.cache-hit != 'true'
run: npm ci --no-audit
- run: npm run build:prod
- uses: actions/upload-artifact@v4
with:
name: static
path: cms/static_compiled/

test-python:
runs-on: ubuntu-latest
needs:
- lint
- lint-front-end
- compile_static

env:
DJANGO_SETTINGS_MODULE: cms.settings.test
DATABASE_URL: postgres://postgres:postgres@localhost/postgres # pragma: allowlist secret
ENABLE_DJANGO_DEFENDER: 'false'
POSTGRES_HOST_AUTH_METHOD: trust
SECRET_KEY: fake_secret_key_to_run_tests # pragma: allowlist secret

services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres # pragma: allowlist secret
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v4
- name: Install Poetry
run: pipx install poetry==1.8.3 # keep in sync with pyproject.toml

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: .python-version
cache: poetry

- name: Install dependencies
run: make install-dev

- uses: actions/download-artifact@v4
with:
name: static
path: cms/static_compiled/

- name: Fetch Design System templates
run: make load-design-system-templates
- name: collectstatic
run: poetry run ./manage.py collectstatic --verbosity 0 --noinput --clear
- name: System checks
run: poetry run ./manage.py check
- name: Check for missing migrations
run: poetry run ./manage.py makemigrations --check --noinput
- name: Create cache table
run: poetry run ./manage.py createcachetable
- name: Test
run: make test

docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build Docker Image
run: docker build --target release -t ons .
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ on: # yamllint disable-line rule:truthy

schedule:
# Run on a daily interval at 12pm UTC
- cron: "0 12 * * *"
- cron: '0 12 * * *'

concurrency:
group: "${{ github.head_ref || github.ref }}-${{ github.workflow }}"
group: '${{ github.head_ref || github.ref }}-${{ github.workflow }}'
cancel-in-progress: true

jobs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ env:
REPORTERS_MARKDOWN_TYPE: simple

concurrency:
group: "${{ github.head_ref || github.ref }}-${{ github.workflow }}"
group: '${{ github.head_ref || github.ref }}-${{ github.workflow }}'
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -134,8 +134,8 @@ jobs:
!contains(github.event.head_commit.message, 'skip fix')
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
commit-message: "[MegaLinter] Apply linters automatic fixes"
title: "[MegaLinter] Apply linters automatic fixes"
commit-message: '[MegaLinter] Apply linters automatic fixes'
title: '[MegaLinter] Apply linters automatic fixes'
labels: bot

- name: Create PR output
Expand Down Expand Up @@ -195,4 +195,4 @@ jobs:
github.head_ref ||
github.ref
}}
commit_message: "[MegaLinter] Apply linters fixes"
commit_message: '[MegaLinter] Apply linters fixes'
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,21 @@ copier_scripts/

# DS_Store files
.DS_Store

#
# Project-specific
#

# DS
/cms/settings/local.py

/cms/jinja2/assets/styles/print.css
/cms/jinja2/components
/cms/jinja2/layout
/cms/static_compiled

node_modules/
static/

# mkdocs
/site
2 changes: 1 addition & 1 deletion .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ FILEIO_REPORTER: false
# Use yml file to allow the use of comments. Megalinter's default is .markdown-lint.json
MARKDOWN_MARKDOWNLINT_CONFIG_FILE: .markdown-lint.yml

YAML_V8R_FILTER_REGEX_EXCLUDE: "dependabot.yml" # Dependabot yaml in SchemaStore is currently not up to date. Dependabot is validated on push by GitHub by default.
YAML_V8R_FILTER_REGEX_EXCLUDE: 'dependabot.yml' # Dependabot yaml in SchemaStore is currently not up to date. Dependabot is validated on push by GitHub by default.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
Loading
Loading