Skip to content

Commit

Permalink
Umar/2168 separately track publish date and build date (#2284)
Browse files Browse the repository at this point in the history
* added build dates for site build tracking

* added update for publish and build dates

* added migration file

* updated unit test for build date

* fixed publish_webiste unit test

* fixed unit test for status update for unpublished site

* updated variable names for mass_build and individual pipeline timestamps

* fixed variable names

Revert "fixed variable names"

This reverts commit d8fdacf0e0c9ad1afbbe9b292dcae5107cc3ed84.

fixed variable names

removed publish status key updates in mas builds

* fixed tests

* Added publish and build date detail in readme

* fixed line number for secret

* Update README.md

Co-authored-by: pt2302 <[email protected]>

* Update README.md

Co-authored-by: pt2302 <[email protected]>

---------

Co-authored-by: pt2302 <[email protected]>
  • Loading branch information
umar8hassan and pt2302 authored Oct 1, 2024
1 parent 87fd973 commit f678729
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"filename": "README.md",
"hashed_secret": "be4fc4886bd949b369d5e092eb87494f12e57e5b",
"is_verified": false,
"line_number": 246
"line_number": 247
}
]
},
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ OCW Studio manages deployments for OCW courses.
- [Enabling Concourse-CI integration](#enabling-concourse-ci-integration)
- [Running a Local Concourse Docker Container](#running-a-local-concourse-docker-container)
- [End to end testing of site pipelines](#end-to-end-testing-of-site-pipelines)
- [Publish And Build Dates](#publish-and-build-dates)
- [Running OCW Studio on Apple Silicon](#running-ocw-studio-on-apple-silicon)
- [Video Workflow](#video-workflow)
- [Enabling YouTube integration](#enabling-youtube-integration)
Expand Down Expand Up @@ -409,6 +410,11 @@ You should now have a pipeline in Concourse called `e2e-test-pipeline`. Run this
- Deploy them to Minio
- Run Playwright tests against the output

### Publish And Build Dates

- Publishing the site from Studio for live and draft versions updates the website properties `(live_build_date, publish_date)` and `(draft_build_date, draft_publish_date)`, respectively.
- Running the mass build for live and draft versions only updates the website properties `live_build_date` and `draft_build_date`, respectively.

# Running OCW Studio on Apple Silicon

Currently, the default Docker image for Concourse is not compatible with Apple Silicon. Therefore, run the following command prior to running `docker-compose up`:
Expand Down
5 changes: 2 additions & 3 deletions content_sync/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from content_sync.decorators import is_publish_pipeline_enabled, is_sync_enabled
from content_sync.models import ContentSyncState
from content_sync.pipelines.base import BasePipeline
from websites.constants import PUBLISH_STATUS_ERRORED, PUBLISH_STATUS_NOT_STARTED
from websites.constants import PUBLISH_STATUS_ERRORED
from websites.models import Website, WebsiteContent

log = logging.getLogger()
Expand Down Expand Up @@ -186,9 +186,8 @@ def publish_website( # pylint: disable=too-many-arguments
update_kwargs = {}
# Need to update additional fields
update_kwargs = {
f"{version}_publish_status": PUBLISH_STATUS_NOT_STARTED,
f"{version}_publish_status_updated_on": now_in_utc(),
f"has_unpublished_{version}": False,
f"{version}_build_date": now_in_utc(),
**update_kwargs,
}
except: # pylint:disable=bare-except
Expand Down
2 changes: 0 additions & 2 deletions content_sync/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,8 @@ def test_publish_website( # pylint:disable=redefined-outer-name,too-many-argume
pipeline.trigger_pipeline_build.assert_not_called()
pipeline.unpause_pipeline.assert_not_called()
assert getattr(website, f"latest_build_id_{version}") is None
assert getattr(website, f"{version}_publish_status") == PUBLISH_STATUS_NOT_STARTED
assert getattr(website, f"has_unpublished_{version}") is False
assert getattr(website, f"{version}_last_published_by") is None
assert getattr(website, f"{version}_publish_status_updated_on") is not None
if len(prepublish_actions) > 0 and prepublish:
mock_api_funcs.mock_import_string.assert_any_call("some.Action")
mock_api_funcs.mock_import_string.return_value.assert_any_call(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.15 on 2024-08-29 19:47

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("websites", "0056_add_hide_download_field"),
]

operations = [
migrations.AddField(
model_name="website",
name="draft_build_date",
field=models.DateTimeField(blank=True, null=True),
),
migrations.AddField(
model_name="website",
name="live_build_date",
field=models.DateTimeField(blank=True, null=True),
),
]
2 changes: 2 additions & 0 deletions websites/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class Website(TimestampedModel):
publish_date = models.DateTimeField(null=True, blank=True)
has_unpublished_live = models.BooleanField(default=False)
latest_build_id_live = models.IntegerField(null=True, blank=True)
live_build_date = models.DateTimeField(null=True, blank=True)
live_publish_status = models.CharField( # noqa: DJ001
max_length=20,
blank=True,
Expand All @@ -114,6 +115,7 @@ class Website(TimestampedModel):
has_unpublished_draft = models.BooleanField(default=False)
latest_build_id_draft = models.IntegerField(null=True, blank=True)
live_publish_status_updated_on = models.DateTimeField(null=True, blank=True)
draft_build_date = models.DateTimeField(null=True, blank=True)
draft_publish_status = models.CharField( # noqa: DJ001
max_length=20,
null=True,
Expand Down

0 comments on commit f678729

Please sign in to comment.